@verax-ai/body 0.4.0 → 0.4.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/dist/cli.js +11 -2
- package/dist/halt.d.ts +30 -0
- package/dist/halt.js +81 -3
- package/dist/install.d.ts +16 -1
- package/dist/install.js +80 -3
- package/dist/server.js +32 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { runDemo } from "./demo.js";
|
|
|
8
8
|
import { doctorBodyLog, doctorExit, runDoctor } from "./doctor.js";
|
|
9
9
|
import { clearVeraxEnv, envFileJwksMissing, loadEnvFile, runInitLocal } from "./init-local.js";
|
|
10
10
|
import { clearCliCodeCheckPassed, defaultElevated, directoryAccess, doctorStateTarget, elevatedCommandCodeRefusal, linuxNodeLabelCheck, linuxSelinuxCheck, liveInstalledChecks, markCliCodeCheckPassed, runInstall, runUninstall, SystemToolError, unreadableSentence } from "./install.js";
|
|
11
|
-
import { runHalt } from "./halt.js";
|
|
11
|
+
import { runHalt, runResume } from "./halt.js";
|
|
12
12
|
import { main } from "./main.js";
|
|
13
13
|
import { runOperator } from "./operator-cli.js";
|
|
14
14
|
import { runReconcile } from "./reconcile-cli.js";
|
|
@@ -51,6 +51,7 @@ Usage: verax <command> [options]
|
|
|
51
51
|
effect binding, and which key answered
|
|
52
52
|
witness <stateDir> run the witness alongside a body
|
|
53
53
|
halt <stateDir> stop the body from allowing anything further
|
|
54
|
+
resume <stateDir> lift a halt; who and when go to halt-history.jsonl
|
|
54
55
|
unlock [--force] <stateDir> clear a stale ledger lock
|
|
55
56
|
|
|
56
57
|
--help, -h print this
|
|
@@ -163,6 +164,14 @@ async function dispatchCli(argv, stdout, stderr, env) {
|
|
|
163
164
|
}
|
|
164
165
|
return runHalt(stateDir, (s) => stderr.write(s));
|
|
165
166
|
}
|
|
167
|
+
if (argv[0] === "resume") {
|
|
168
|
+
const stateDir = argv[1];
|
|
169
|
+
if (!stateDir) {
|
|
170
|
+
stderr.write("verax resume <stateDir>\n");
|
|
171
|
+
return 78;
|
|
172
|
+
}
|
|
173
|
+
return runResume(stateDir, (s) => stderr.write(s));
|
|
174
|
+
}
|
|
166
175
|
if (argv[0] === "unlock") {
|
|
167
176
|
const force = argv.includes("--force");
|
|
168
177
|
const stateDir = argv.slice(1).find((a) => a !== "--force");
|
|
@@ -254,7 +263,7 @@ async function dispatchCli(argv, stdout, stderr, env) {
|
|
|
254
263
|
return runVerify(argv.slice(1), (s) => stdout.write(`${s}\n`));
|
|
255
264
|
}
|
|
256
265
|
if (argv[0] === "desktop") {
|
|
257
|
-
stderr.write("desktop-not-
|
|
266
|
+
stderr.write("desktop-not-released: the desktop panel is not in this release\n");
|
|
258
267
|
return 64;
|
|
259
268
|
}
|
|
260
269
|
if (argv[0] === "witness") {
|
package/dist/halt.d.ts
CHANGED
|
@@ -1 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The proxy refuses every call while `<stateDir>/halted` exists; that file is
|
|
3
|
+
* the switch and stays empty. Who flipped it and when goes to
|
|
4
|
+
* `halt-history.jsonl` beside it, one line per halt or resume, so the panel
|
|
5
|
+
* can say "stopped by operator-7 at 14:02" and a resume is not silent.
|
|
6
|
+
*
|
|
7
|
+
* The history is a plain append-only file, not a signed ledger record. The
|
|
8
|
+
* calls refused while halted are signed; the switch itself is not.
|
|
9
|
+
*/
|
|
10
|
+
export type HaltEvent = {
|
|
11
|
+
action: "halt" | "resume";
|
|
12
|
+
atMs: number;
|
|
13
|
+
by: string;
|
|
14
|
+
via: "cli" | "http";
|
|
15
|
+
};
|
|
16
|
+
export type HaltState = {
|
|
17
|
+
halted: boolean;
|
|
18
|
+
since?: HaltEvent;
|
|
19
|
+
};
|
|
20
|
+
export declare function readHalt(stateDir: string): HaltState;
|
|
21
|
+
/** Halting twice is one halt: the first line keeps saying who stopped it. */
|
|
22
|
+
export declare function haltBody(stateDir: string, by: string, via: HaltEvent["via"], now?: number): HaltState;
|
|
23
|
+
/**
|
|
24
|
+
* Resuming a body that is not halted changes nothing and writes nothing.
|
|
25
|
+
* The line goes to the history before the switch is removed: if it cannot be
|
|
26
|
+
* written, the append throws and the body stays halted, rather than running
|
|
27
|
+
* again with no record of who let it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resumeBody(stateDir: string, by: string, via: HaltEvent["via"], now?: number): HaltState;
|
|
1
30
|
export declare function runHalt(stateDir: string, writeErr?: (s: string) => void): number;
|
|
31
|
+
export declare function runResume(stateDir: string, writeErr?: (s: string) => void): number;
|
package/dist/halt.js
CHANGED
|
@@ -1,12 +1,90 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { userInfo } from "node:os";
|
|
2
3
|
import { join } from "node:path";
|
|
4
|
+
const SWITCH = "halted";
|
|
5
|
+
const HISTORY = "halt-history.jsonl";
|
|
6
|
+
function cliUser() {
|
|
7
|
+
try {
|
|
8
|
+
return userInfo().username || "unknown";
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return "unknown";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function appendHistory(stateDir, event) {
|
|
15
|
+
appendFileSync(join(stateDir, HISTORY), `${JSON.stringify(event)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
16
|
+
}
|
|
17
|
+
function lastHalt(stateDir) {
|
|
18
|
+
let raw;
|
|
19
|
+
try {
|
|
20
|
+
raw = readFileSync(join(stateDir, HISTORY), "utf8");
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const lines = raw.split("\n").filter((line) => line.trim() !== "");
|
|
26
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
27
|
+
try {
|
|
28
|
+
const row = JSON.parse(lines[i] ?? "");
|
|
29
|
+
if (row.action === "halt" && typeof row.atMs === "number" && typeof row.by === "string") {
|
|
30
|
+
return { action: "halt", atMs: row.atMs, by: row.by, via: row.via === "http" ? "http" : "cli" };
|
|
31
|
+
}
|
|
32
|
+
if (row.action === "resume")
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// A torn last line says nothing about who halted.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
export function readHalt(stateDir) {
|
|
42
|
+
if (!existsSync(join(stateDir, SWITCH)))
|
|
43
|
+
return { halted: false };
|
|
44
|
+
const since = lastHalt(stateDir);
|
|
45
|
+
return since ? { halted: true, since } : { halted: true };
|
|
46
|
+
}
|
|
47
|
+
/** Halting twice is one halt: the first line keeps saying who stopped it. */
|
|
48
|
+
export function haltBody(stateDir, by, via, now = Date.now()) {
|
|
49
|
+
mkdirSync(stateDir, { recursive: true, mode: 0o700 });
|
|
50
|
+
if (!existsSync(join(stateDir, SWITCH))) {
|
|
51
|
+
writeFileSync(join(stateDir, SWITCH), "", { encoding: "utf8", mode: 0o600 });
|
|
52
|
+
appendHistory(stateDir, { action: "halt", atMs: now, by, via });
|
|
53
|
+
}
|
|
54
|
+
return readHalt(stateDir);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resuming a body that is not halted changes nothing and writes nothing.
|
|
58
|
+
* The line goes to the history before the switch is removed: if it cannot be
|
|
59
|
+
* written, the append throws and the body stays halted, rather than running
|
|
60
|
+
* again with no record of who let it.
|
|
61
|
+
*/
|
|
62
|
+
export function resumeBody(stateDir, by, via, now = Date.now()) {
|
|
63
|
+
if (existsSync(join(stateDir, SWITCH))) {
|
|
64
|
+
appendHistory(stateDir, { action: "resume", atMs: now, by, via });
|
|
65
|
+
rmSync(join(stateDir, SWITCH), { force: true });
|
|
66
|
+
}
|
|
67
|
+
return readHalt(stateDir);
|
|
68
|
+
}
|
|
3
69
|
export function runHalt(stateDir, writeErr = (s) => process.stderr.write(s)) {
|
|
4
70
|
if (!stateDir) {
|
|
5
71
|
writeErr("verax halt <stateDir>\n");
|
|
6
72
|
return 78;
|
|
7
73
|
}
|
|
8
|
-
|
|
9
|
-
writeFileSync(join(stateDir, "halted"), "", { encoding: "utf8", mode: 0o600 });
|
|
74
|
+
haltBody(stateDir, cliUser(), "cli");
|
|
10
75
|
writeErr("halted\n");
|
|
11
76
|
return 0;
|
|
12
77
|
}
|
|
78
|
+
export function runResume(stateDir, writeErr = (s) => process.stderr.write(s)) {
|
|
79
|
+
if (!stateDir) {
|
|
80
|
+
writeErr("verax resume <stateDir>\n");
|
|
81
|
+
return 78;
|
|
82
|
+
}
|
|
83
|
+
if (!existsSync(join(stateDir, SWITCH))) {
|
|
84
|
+
writeErr("not halted\n");
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
resumeBody(stateDir, cliUser(), "cli");
|
|
88
|
+
writeErr("resumed\n");
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
package/dist/install.d.ts
CHANGED
|
@@ -54,7 +54,9 @@ export declare const PS_ERROR_MARK = "verax-ps-error:";
|
|
|
54
54
|
* AppData directory and must not receive install files.
|
|
55
55
|
* On Windows, PSModulePath is only the System32 Windows PowerShell 5.1 module
|
|
56
56
|
* directory. Without it, PowerShell 5.1 puts Documents\WindowsPowerShell\Modules
|
|
57
|
-
* first, and -NoProfile does not change that list.
|
|
57
|
+
* first, and -NoProfile does not change that list. PowerShell 5.1 still inserts
|
|
58
|
+
* Program Files\WindowsPowerShell\Modules in front of the pinned value (measured
|
|
59
|
+
* on 5.1.26100); the install trust-checks that directory as an object.
|
|
58
60
|
*/
|
|
59
61
|
export declare function systemToolEnv(platform?: NodeJS.Platform, tempDir?: string): NodeJS.ProcessEnv;
|
|
60
62
|
export declare function toolArgv(tool: string, args: readonly string[], platform?: NodeJS.Platform): string[];
|
|
@@ -315,6 +317,8 @@ export type InstallHooks = {
|
|
|
315
317
|
elevated?: () => boolean;
|
|
316
318
|
exec?: ToolExec;
|
|
317
319
|
stateExists?: (dir: string) => boolean;
|
|
320
|
+
/** Whether a `node_modules` directory on a module search path exists. Defaults to `existsSync`. */
|
|
321
|
+
moduleDirExists?: (dir: string) => boolean;
|
|
318
322
|
layout?: {
|
|
319
323
|
execPath: string;
|
|
320
324
|
bodyVersion: string;
|
|
@@ -448,6 +452,17 @@ export declare function trustTargets(file: string, platform: InstallPlatform): {
|
|
|
448
452
|
path: string;
|
|
449
453
|
ancestor: boolean;
|
|
450
454
|
}[];
|
|
455
|
+
/**
|
|
456
|
+
* The `node_modules` directories Node searches for a bare specifier that code
|
|
457
|
+
* under `start` imports: `<dir>/node_modules` for `start` and every parent, up
|
|
458
|
+
* to the root, skipping a directory that is itself named `node_modules`.
|
|
459
|
+
* Stock Windows lets any authenticated user create a folder under `C:\`, so
|
|
460
|
+
* `C:\node_modules` can be planted beside an elevated or service Node. Each
|
|
461
|
+
* one that exists is judged as an object (add-file counts). A missing one is
|
|
462
|
+
* not listed: the loader skips it, and refusing every machine for a folder
|
|
463
|
+
* that is not there would refuse them all.
|
|
464
|
+
*/
|
|
465
|
+
export declare function moduleSearchDirs(start: string, platform: InstallPlatform, exists?: (dir: string) => boolean): string[];
|
|
451
466
|
/**
|
|
452
467
|
* Another user can rename or replace this entry.
|
|
453
468
|
* An ancestor with the sticky bit is kept: only its owner can rename a child (mode 1777, the way `/tmp` works).
|
package/dist/install.js
CHANGED
|
@@ -315,7 +315,9 @@ export const PS_ERROR_MARK = "verax-ps-error:";
|
|
|
315
315
|
* AppData directory and must not receive install files.
|
|
316
316
|
* On Windows, PSModulePath is only the System32 Windows PowerShell 5.1 module
|
|
317
317
|
* directory. Without it, PowerShell 5.1 puts Documents\WindowsPowerShell\Modules
|
|
318
|
-
* first, and -NoProfile does not change that list.
|
|
318
|
+
* first, and -NoProfile does not change that list. PowerShell 5.1 still inserts
|
|
319
|
+
* Program Files\WindowsPowerShell\Modules in front of the pinned value (measured
|
|
320
|
+
* on 5.1.26100); the install trust-checks that directory as an object.
|
|
319
321
|
*/
|
|
320
322
|
export function systemToolEnv(platform = process.platform, tempDir) {
|
|
321
323
|
if (platform === "win32") {
|
|
@@ -504,6 +506,23 @@ function officialNodeRemedy(platform) {
|
|
|
504
506
|
export function nodeTrustMessage(nodePath) {
|
|
505
507
|
return `Node at ${nodePath} can be changed by your user account; install Node for all users (nodejs.org installer) and run verax install from that Node`;
|
|
506
508
|
}
|
|
509
|
+
/** A directory Node or PowerShell searches for code to load, judged apart from Node itself. */
|
|
510
|
+
function isModuleSearchDir(file) {
|
|
511
|
+
const trimmed = file.replace(/[\\/]+$/, "");
|
|
512
|
+
return /(^|[\\/])node_modules$/i.test(trimmed) || /[\\/]WindowsPowerShell[\\/]Modules$/i.test(trimmed);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* The remedy for a module directory is that directory, not a different Node:
|
|
516
|
+
* a user-writable /usr/local/lib/node_modules refuses every Node under /usr/local/lib.
|
|
517
|
+
*/
|
|
518
|
+
function moduleDirTrustMessage(dir, platform) {
|
|
519
|
+
const head = `Module directory ${dir} can be changed by your user account. An elevated install loads code from it, so the install refuses it`;
|
|
520
|
+
if (platform === "win32") {
|
|
521
|
+
return `${head}. Remove it, or leave it writable only by Administrators and SYSTEM, then run verax install again`;
|
|
522
|
+
}
|
|
523
|
+
const owner = platform === "darwin" ? "root:wheel" : "root:root";
|
|
524
|
+
return `${head}. Remove it, or make it ${owner} and not group- or other-writable (sudo chown -R ${owner} ${dir}; sudo chmod -R go-w ${dir}), then run verax install again`;
|
|
525
|
+
}
|
|
507
526
|
function nodeTrustMessageFor(nodePath, platform) {
|
|
508
527
|
const head = `Node at ${nodePath} can be changed by your user account`;
|
|
509
528
|
if (platform === "win32")
|
|
@@ -574,6 +593,10 @@ export function veraxCodeDirectories(entryUrl = import.meta.url) {
|
|
|
574
593
|
return [];
|
|
575
594
|
add(body);
|
|
576
595
|
add(path.join(body, "node_modules"));
|
|
596
|
+
// Node also searches every ancestor's node_modules, up to the drive root.
|
|
597
|
+
const hostFlavor = process.platform === "win32" ? "win32" : "linux";
|
|
598
|
+
for (const dir of moduleSearchDirs(body, hostFlavor))
|
|
599
|
+
add(dir);
|
|
577
600
|
let deps = [];
|
|
578
601
|
try {
|
|
579
602
|
const parsed = JSON.parse(readFileSync(path.join(body, "package.json"), "utf8"));
|
|
@@ -1292,6 +1315,33 @@ export function trustTargets(file, platform) {
|
|
|
1292
1315
|
ancestor: parentIsObject ? index > 1 : index > 0,
|
|
1293
1316
|
}));
|
|
1294
1317
|
}
|
|
1318
|
+
/**
|
|
1319
|
+
* The `node_modules` directories Node searches for a bare specifier that code
|
|
1320
|
+
* under `start` imports: `<dir>/node_modules` for `start` and every parent, up
|
|
1321
|
+
* to the root, skipping a directory that is itself named `node_modules`.
|
|
1322
|
+
* Stock Windows lets any authenticated user create a folder under `C:\`, so
|
|
1323
|
+
* `C:\node_modules` can be planted beside an elevated or service Node. Each
|
|
1324
|
+
* one that exists is judged as an object (add-file counts). A missing one is
|
|
1325
|
+
* not listed: the loader skips it, and refusing every machine for a folder
|
|
1326
|
+
* that is not there would refuse them all.
|
|
1327
|
+
*/
|
|
1328
|
+
export function moduleSearchDirs(start, platform, exists = existsSync) {
|
|
1329
|
+
const p = platform === "win32" ? path.win32 : path.posix;
|
|
1330
|
+
const out = [];
|
|
1331
|
+
let cur = p.normalize(start);
|
|
1332
|
+
for (;;) {
|
|
1333
|
+
if (p.basename(cur).toLowerCase() !== "node_modules") {
|
|
1334
|
+
const candidate = p.join(cur, "node_modules");
|
|
1335
|
+
if (exists(candidate))
|
|
1336
|
+
out.push(candidate);
|
|
1337
|
+
}
|
|
1338
|
+
const parent = p.dirname(cur);
|
|
1339
|
+
if (parent === cur)
|
|
1340
|
+
break;
|
|
1341
|
+
cur = parent;
|
|
1342
|
+
}
|
|
1343
|
+
return out;
|
|
1344
|
+
}
|
|
1295
1345
|
/**
|
|
1296
1346
|
* Another user can rename or replace this entry.
|
|
1297
1347
|
* An ancestor with the sticky bit is kept: only its owner can rename a child (mode 1777, the way `/tmp` works).
|
|
@@ -4587,6 +4637,10 @@ export function elevatedPreloadRefusal(env, execArgv) {
|
|
|
4587
4637
|
if (options.trim() !== "" || flagged) {
|
|
4588
4638
|
return "refusing: NODE_OPTIONS or a preload flag is set; an elevated verax runs with none";
|
|
4589
4639
|
}
|
|
4640
|
+
// NODE_PATH adds the caller's directories to the module search list of an elevated process.
|
|
4641
|
+
if ((env.NODE_PATH ?? "").trim() !== "") {
|
|
4642
|
+
return "refusing: NODE_PATH is set; an elevated verax resolves modules only from its own install";
|
|
4643
|
+
}
|
|
4590
4644
|
return null;
|
|
4591
4645
|
}
|
|
4592
4646
|
function nodeBinaryUntrusted(platform, execPath, exec, probe) {
|
|
@@ -4878,6 +4932,10 @@ async function runInstallBody(argv, hooks = {}) {
|
|
|
4878
4932
|
trustFiles.push(...trustTargets(path.win32.join(sys, "System32"), "win32"));
|
|
4879
4933
|
for (const name of WIN32_TOOLS)
|
|
4880
4934
|
trustFiles.push(...trustTargets(winToolUnder(sys, name), "win32"));
|
|
4935
|
+
// PowerShell 5.1 autoloads from here before System32, whatever PSModulePath says.
|
|
4936
|
+
const sharedModules = path.win32.join(filesRoot, "WindowsPowerShell", "Modules");
|
|
4937
|
+
if ((hooks.moduleDirExists ?? existsSync)(sharedModules))
|
|
4938
|
+
trustFiles.push(...trustTargets(sharedModules, "win32"));
|
|
4881
4939
|
// The install roots are parents of what the installer creates and locks, and stock ProgramData lets Users create
|
|
4882
4940
|
// folders. They are judged by the ancestor rule (no write-DAC, owner or delete-child for a non-admin), not as objects.
|
|
4883
4941
|
for (const root of [data, filesRoot]) {
|
|
@@ -4892,6 +4950,23 @@ async function runInstallBody(argv, hooks = {}) {
|
|
|
4892
4950
|
throw err;
|
|
4893
4951
|
}
|
|
4894
4952
|
}
|
|
4953
|
+
if (trustPlat) {
|
|
4954
|
+
// npm (run by this install) and the installed body resolve bare specifiers
|
|
4955
|
+
// through every ancestor's node_modules. Each one on disk is judged as an object.
|
|
4956
|
+
const moduleExists = hooks.moduleDirExists ?? existsSync;
|
|
4957
|
+
const starts = [
|
|
4958
|
+
(trustPlat === "win32" ? path.win32 : path.posix).dirname(layout.npmCli),
|
|
4959
|
+
codeDirFor(trustPlat, plannedEnv, posixRoot, adopted),
|
|
4960
|
+
];
|
|
4961
|
+
const seen = new Set();
|
|
4962
|
+
for (const dir of starts.flatMap((start) => moduleSearchDirs(start, trustPlat, moduleExists))) {
|
|
4963
|
+
const key = trustPlat === "win32" ? dir.toLowerCase() : dir;
|
|
4964
|
+
if (seen.has(key))
|
|
4965
|
+
continue;
|
|
4966
|
+
seen.add(key);
|
|
4967
|
+
trustFiles.push(...trustTargets(dir, trustPlat));
|
|
4968
|
+
}
|
|
4969
|
+
}
|
|
4895
4970
|
let sddlPlan = null;
|
|
4896
4971
|
if (platform === "win32") {
|
|
4897
4972
|
const root = path.win32.dirname(stateDir);
|
|
@@ -4918,7 +4993,8 @@ async function runInstallBody(argv, hooks = {}) {
|
|
|
4918
4993
|
for (const file of trustFiles) {
|
|
4919
4994
|
const acl = sddlOrMiss(cache, file.path);
|
|
4920
4995
|
if (acl.status !== 0 || windowsUserCanWrite(acl.text, { path: file.path, userSid: sid, ancestor: file.ancestor })) {
|
|
4921
|
-
|
|
4996
|
+
const said = isModuleSearchDir(file.path) ? moduleDirTrustMessage(file.path, "win32") : nodeTrustMessage(file.path);
|
|
4997
|
+
io.stderr.write(`${refuseAcl(acl.text, said)}\n`);
|
|
4922
4998
|
return EX_CONFIG;
|
|
4923
4999
|
}
|
|
4924
5000
|
}
|
|
@@ -4926,7 +5002,8 @@ async function runInstallBody(argv, hooks = {}) {
|
|
|
4926
5002
|
else {
|
|
4927
5003
|
for (const file of trustFiles) {
|
|
4928
5004
|
if (posixEntryUntrusted(file.path, file.ancestor)) {
|
|
4929
|
-
|
|
5005
|
+
const said = isModuleSearchDir(file.path) ? moduleDirTrustMessage(file.path, trustPlat) : nodeTrustMessageFor(file.path, trustPlat);
|
|
5006
|
+
io.stderr.write(`${said}\n`);
|
|
4930
5007
|
return EX_CONFIG;
|
|
4931
5008
|
}
|
|
4932
5009
|
}
|
package/dist/server.js
CHANGED
|
@@ -14,6 +14,7 @@ import { matchingInputs } from "./inputs-read.js";
|
|
|
14
14
|
import { readPolicySnapshots } from "./policy-store.js";
|
|
15
15
|
import { readHeartbeat, readInstallHealthNonce, readWitnessPulse } from "./health-extras.js";
|
|
16
16
|
import { agentsWindow } from "./agents.js";
|
|
17
|
+
import { haltBody, readHalt, resumeBody } from "./halt.js";
|
|
17
18
|
import { inventoryHealth, readInventoryFile } from "./inventory-file.js";
|
|
18
19
|
import { createBodyServices, TOOL_NAMES } from "./wiring.js";
|
|
19
20
|
import { openDownstream, parseDownstreamDocument, } from "./downstream.js";
|
|
@@ -503,7 +504,16 @@ export async function listen(config) {
|
|
|
503
504
|
const contest = req.method === "POST" && url.pathname.startsWith("/api/contest/");
|
|
504
505
|
const apiApprove = req.method === "POST" && url.pathname === "/api/approve";
|
|
505
506
|
const apiAgents = req.method === "GET" && url.pathname === "/api/agents";
|
|
506
|
-
|
|
507
|
+
const apiHalt = url.pathname === "/api/halt" && (req.method === "GET" || req.method === "POST");
|
|
508
|
+
const apiResume = req.method === "POST" && url.pathname === "/api/resume";
|
|
509
|
+
if (url.pathname !== "/mcp" &&
|
|
510
|
+
!apiLedger &&
|
|
511
|
+
!apiInventory &&
|
|
512
|
+
!contest &&
|
|
513
|
+
!apiApprove &&
|
|
514
|
+
!apiAgents &&
|
|
515
|
+
!apiHalt &&
|
|
516
|
+
!apiResume) {
|
|
507
517
|
send(res, 404, { error: "not-found" });
|
|
508
518
|
return;
|
|
509
519
|
}
|
|
@@ -544,6 +554,27 @@ export async function listen(config) {
|
|
|
544
554
|
return;
|
|
545
555
|
}
|
|
546
556
|
try {
|
|
557
|
+
if (apiHalt || apiResume) {
|
|
558
|
+
if (await refuseStaleBearer())
|
|
559
|
+
return;
|
|
560
|
+
const scopes = verified.principal.scopes;
|
|
561
|
+
const operator = scopes.has("verax:audit") || scopes.has("verax:approve");
|
|
562
|
+
// Stopping is the safe direction, so any operator session may do it.
|
|
563
|
+
// Lifting a halt lets everything through again: that is an approval of
|
|
564
|
+
// everything at once and needs the approve scope. The agent token
|
|
565
|
+
// carries neither, so an agent cannot stop itself being stopped.
|
|
566
|
+
if (!operator || (apiResume && !scopes.has("verax:approve"))) {
|
|
567
|
+
send(res, 403, { error: "scope-missing" });
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if (req.method === "GET") {
|
|
571
|
+
send(res, 200, readHalt(config.stateDir));
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
const by = verified.principal.brain;
|
|
575
|
+
send(res, 200, apiResume ? resumeBody(config.stateDir, by, "http") : haltBody(config.stateDir, by, "http"));
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
547
578
|
if (apiApprove) {
|
|
548
579
|
// Reading the ledger is not approving from it. The audit scope opens
|
|
549
580
|
// every door above; this one signs a new decision and lets money go,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verax-ai/body",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@cedulon/cose": "0.13.1",
|
|
27
27
|
"@cedulon/effect-extract": "0.13.1",
|
|
28
28
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
29
|
-
"@verax-ai/inventory": "^0.4.
|
|
30
|
-
"@verax-ai/proxy": "^0.4.
|
|
29
|
+
"@verax-ai/inventory": "^0.4.1",
|
|
30
|
+
"@verax-ai/proxy": "^0.4.1",
|
|
31
31
|
"jose": "^6.2.11"
|
|
32
32
|
},
|
|
33
33
|
"description": "VERAX body: an MCP server that decides, records and proves what an agent did.",
|