@verax-ai/body 0.4.7 → 0.4.8
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/demo.js +9 -23
- package/dist/init-local.js +1 -21
- package/dist/shipped-policy.d.ts +9 -0
- package/dist/shipped-policy.js +31 -0
- package/package.json +3 -3
package/dist/demo.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import {
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
|
-
import {
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { join } from "node:path";
|
|
7
6
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
8
7
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
9
8
|
import { exportJWK, generateKeyPair, SignJWT } from "jose";
|
|
10
9
|
import { verifyLedger } from "@verax-ai/proxy";
|
|
11
10
|
import { runApprove } from "./approve-cli.js";
|
|
12
11
|
import { listen } from "./server.js";
|
|
12
|
+
import { shippedPolicyPath } from "./shipped-policy.js";
|
|
13
13
|
const NOT_SHOWN = "Not shown here: data masking arrives with a downstream server such as Conarium; statement reconciliation needs a real statement (verax reconcile).";
|
|
14
14
|
const NOT_SHOWN_WITH_CONARIUM = "Not shown here: a real database (these are Conarium's sample rows); statement reconciliation needs a real statement (verax reconcile).";
|
|
15
15
|
const NPX_DOWNLOAD_LINE = "npx will download @conarium-ai/core from npm and run it as a child process; a cold download takes longer.\n";
|
|
@@ -37,29 +37,15 @@ function redact(text, token) {
|
|
|
37
37
|
return text;
|
|
38
38
|
return text.split(token).join("[token]");
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
resolved = null;
|
|
48
|
-
}
|
|
49
|
-
const candidates = [
|
|
50
|
-
resolved,
|
|
51
|
-
join(here, "..", "..", "proxy", "policy", "default.json"),
|
|
52
|
-
join(here, "..", "..", "@verax-ai", "proxy", "policy", "default.json"),
|
|
53
|
-
];
|
|
54
|
-
for (const path of candidates) {
|
|
55
|
-
if (path && existsSync(path))
|
|
56
|
-
return path;
|
|
57
|
-
}
|
|
58
|
-
throw new Error("demo: shipped policy file not found");
|
|
40
|
+
function demoPolicyPath() {
|
|
41
|
+
const path = shippedPolicyPath();
|
|
42
|
+
if (path === null)
|
|
43
|
+
throw new Error("demo: shipped policy file not found");
|
|
44
|
+
return path;
|
|
59
45
|
}
|
|
60
46
|
/** Shipped default plus message.send egress and a spend rule, written under the temp dir. */
|
|
61
47
|
function writeDemoPolicy(stateDir, withConarium) {
|
|
62
|
-
const shipped = JSON.parse(readFileSync(
|
|
48
|
+
const shipped = JSON.parse(readFileSync(demoPolicyPath(), "utf8"));
|
|
63
49
|
const document = {
|
|
64
50
|
...shipped,
|
|
65
51
|
egress: [EGRESS_HOST],
|
package/dist/init-local.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { chmodSync, existsSync, lstatSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
4
|
import { beginWinOwnerRun, endWinOwnerRun, ensureTokenParent, mkdirLeaf, restrictToOwnerWin32, SystemToolError } from "./install.js";
|
|
6
5
|
import { calculateJwkThumbprint, exportJWK, exportPKCS8, generateKeyPair, importPKCS8, SignJWT, } from "jose";
|
|
7
6
|
import { EX_CONFIG } from "./config.js";
|
|
7
|
+
import { shippedPolicyPath } from "./shipped-policy.js";
|
|
8
8
|
const ISSUER = "verax-local";
|
|
9
9
|
const SUBJECT = "local-agent";
|
|
10
10
|
const SCOPE = "verax:read verax:memory";
|
|
@@ -65,26 +65,6 @@ export function envFileJwksMissing(env) {
|
|
|
65
65
|
return "env file sets neither VERAX_JWKS_FILE nor VERAX_JWKS_URL";
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
|
-
function shippedPolicyPath() {
|
|
69
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
70
|
-
let resolved = null;
|
|
71
|
-
try {
|
|
72
|
-
resolved = join(dirname(fileURLToPath(import.meta.resolve("@verax-ai/proxy/package.json"))), "policy", "default.json");
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
resolved = null;
|
|
76
|
-
}
|
|
77
|
-
const candidates = [
|
|
78
|
-
resolved,
|
|
79
|
-
join(here, "..", "..", "proxy", "policy", "default.json"),
|
|
80
|
-
join(here, "..", "..", "@verax-ai", "proxy", "policy", "default.json"),
|
|
81
|
-
];
|
|
82
|
-
for (const path of candidates) {
|
|
83
|
-
if (path && existsSync(path))
|
|
84
|
-
return path;
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
68
|
/** POSIX keeps owner-only mode. Windows grants the current user only outside install mode. */
|
|
89
69
|
function ownerOnly(path, grantOwner) {
|
|
90
70
|
if (process.platform === "win32") {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default policy ships inside @verax-ai/proxy as policy/default.json.
|
|
3
|
+
* The proxy exports only its entry, not its package.json, so the file is
|
|
4
|
+
* found one directory above that entry (dist/index.js). That holds wherever
|
|
5
|
+
* npm put the proxy: next to the body, under the body's own node_modules
|
|
6
|
+
* (npm install -g does not hoist) or in an npx cache. The two sibling paths
|
|
7
|
+
* cover a checkout of this repository.
|
|
8
|
+
*/
|
|
9
|
+
export declare function shippedPolicyPath(): string | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
/**
|
|
5
|
+
* The default policy ships inside @verax-ai/proxy as policy/default.json.
|
|
6
|
+
* The proxy exports only its entry, not its package.json, so the file is
|
|
7
|
+
* found one directory above that entry (dist/index.js). That holds wherever
|
|
8
|
+
* npm put the proxy: next to the body, under the body's own node_modules
|
|
9
|
+
* (npm install -g does not hoist) or in an npx cache. The two sibling paths
|
|
10
|
+
* cover a checkout of this repository.
|
|
11
|
+
*/
|
|
12
|
+
export function shippedPolicyPath() {
|
|
13
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
let fromEntry = null;
|
|
15
|
+
try {
|
|
16
|
+
fromEntry = join(dirname(fileURLToPath(import.meta.resolve("@verax-ai/proxy"))), "..", "policy", "default.json");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
fromEntry = null;
|
|
20
|
+
}
|
|
21
|
+
const candidates = [
|
|
22
|
+
fromEntry,
|
|
23
|
+
join(here, "..", "..", "proxy", "policy", "default.json"),
|
|
24
|
+
join(here, "..", "..", "@verax-ai", "proxy", "policy", "default.json"),
|
|
25
|
+
];
|
|
26
|
+
for (const path of candidates) {
|
|
27
|
+
if (path && existsSync(path))
|
|
28
|
+
return path;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verax-ai/body",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
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.8",
|
|
30
|
+
"@verax-ai/proxy": "^0.4.8",
|
|
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.",
|