@agent-custody/state 0.13.0 → 0.15.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/README.md +0 -1
- package/dist/verify-web.js +22 -6
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -345,5 +345,4 @@ tsconfig.build.json emits dist/ for consumers; the repo itself runs the .ts dir
|
|
|
345
345
|
**Next, in the order it pays off**
|
|
346
346
|
|
|
347
347
|
1. The hosted plane, behind early access: tenanted log, then memory, then reports and a control plane, with SSO, SCIM, residency, and SIEM export. [Issue #6](https://github.com/svayatta/agent-custody/issues/6).
|
|
348
|
-
2. Write-through adapters for Letta, LangMem, and Cognee, one per user who asks. [Issue #4](https://github.com/svayatta/agent-custody/issues/4).
|
|
349
348
|
|
package/dist/verify-web.js
CHANGED
|
@@ -131,10 +131,20 @@ export async function verifyDelegationChain(env, trusted, depth = 1) {
|
|
|
131
131
|
// ---- RFC 6962 / 9162 ----
|
|
132
132
|
const leafHash = (data) => sha256(concat(new Uint8Array([0]), enc.encode(data)));
|
|
133
133
|
const nodeHash = (l, r) => sha256(concat(new Uint8Array([1]), l, r));
|
|
134
|
+
// every hash a proof check reads is 32 bytes: a proof hash and a root are each a string of 64 lowercase hex digits;
|
|
135
|
+
// sizes and indices are integers, since the loops halve them with Math.floor
|
|
136
|
+
const HASH_HEX = /^[0-9a-f]{64}$/;
|
|
137
|
+
const isHash = (x) => typeof x === "string" && HASH_HEX.test(x);
|
|
138
|
+
const isSize = (n) => Number.isSafeInteger(n) && n >= 0;
|
|
139
|
+
const EMPTY_ROOT = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
134
140
|
export async function verifyInclusion(leaf, proof, rootHex) {
|
|
141
|
+
if (!isSize(proof.leafIndex) || !isSize(proof.treeSize))
|
|
142
|
+
return false;
|
|
135
143
|
let fn = proof.leafIndex, sn = proof.treeSize - 1;
|
|
136
144
|
if (fn < 0 || sn < 0 || fn > sn)
|
|
137
145
|
return false;
|
|
146
|
+
if (leaf.length !== 32 || !isHash(rootHex) || !Array.isArray(proof.hashes) || !proof.hashes.every(isHash))
|
|
147
|
+
return false;
|
|
138
148
|
let r = leaf;
|
|
139
149
|
for (const h of proof.hashes) {
|
|
140
150
|
if (sn === 0)
|
|
@@ -157,12 +167,15 @@ export async function verifyInclusion(leaf, proof, rootHex) {
|
|
|
157
167
|
return sn === 0 && hex(r) === rootHex;
|
|
158
168
|
}
|
|
159
169
|
export async function verifyConsistency(oldSize, oldRoot, newSize, newRoot, proofHex) {
|
|
160
|
-
if (oldSize
|
|
170
|
+
if (!isSize(oldSize) || !isSize(newSize) || oldSize > newSize)
|
|
171
|
+
return false;
|
|
172
|
+
if (!isHash(oldRoot) || !isHash(newRoot) || !Array.isArray(proofHex) || !proofHex.every(isHash))
|
|
161
173
|
return false;
|
|
174
|
+
// the empty tree has one root, sha256 of nothing; any other root at size 0, old or new, is a head no log could have signed
|
|
175
|
+
if (oldSize === 0)
|
|
176
|
+
return proofHex.length === 0 && oldRoot === EMPTY_ROOT && (newSize > 0 || newRoot === EMPTY_ROOT);
|
|
162
177
|
if (oldSize === newSize)
|
|
163
178
|
return proofHex.length === 0 && oldRoot === newRoot;
|
|
164
|
-
if (oldSize === 0)
|
|
165
|
-
return proofHex.length === 0;
|
|
166
179
|
if (proofHex.length === 0)
|
|
167
180
|
return false;
|
|
168
181
|
const proof = proofHex.map(unhex);
|
|
@@ -195,6 +208,7 @@ export async function verifyConsistency(oldSize, oldRoot, newSize, newRoot, proo
|
|
|
195
208
|
const ISSUER_NOTE = {
|
|
196
209
|
gateway: "enforced outside the agent's process; the agent could neither skip nor forge this receipt",
|
|
197
210
|
sdk: "self-reported by the agent's own process; tamper-evident after issue, but nothing here was enforced outside the agent",
|
|
211
|
+
door: "enforced in front of the business's own HTTP surface; the arriving party could neither skip nor forge this receipt, and is attested only when it presented a grant",
|
|
198
212
|
};
|
|
199
213
|
const short = (s) => s.slice(0, 12);
|
|
200
214
|
async function hmacHex(secret, data) {
|
|
@@ -281,8 +295,8 @@ async function verifyOriginalAuthorization(bundle, opts) {
|
|
|
281
295
|
add("structural parts in clear", !problem, problem ?? undefined);
|
|
282
296
|
if (problem)
|
|
283
297
|
return { ok: false, checks };
|
|
284
|
-
add("authorization issued by the gateway", p.issuer.kind === "gateway" && p.issuer.keyid === sig.keyid);
|
|
285
|
-
add("authorization operation is submitted", p.operation?.status === "submitted");
|
|
298
|
+
add("authorization issued by the gateway", (p.issuer.kind === "gateway" || p.issuer.kind === "door") && p.issuer.keyid === sig.keyid, p.issuer.kind === "door" ? "a door commits a request before relaying it, as a gateway commits a call" : undefined);
|
|
299
|
+
add("authorization operation is submitted", p.issuer.kind === "door" || p.operation?.status === "submitted", p.issuer.kind === "door" ? "a door has no operations" : undefined);
|
|
286
300
|
add("authorization permits the original call", p.policy?.decision === "allow" ? Array.isArray(p.policy.errors) && p.policy.errors.length === 0 : p.policy?.decision === "deny" && p.policy.enforced === false);
|
|
287
301
|
const del = p.delegation && await verifyDelegationChain(p.delegation.envelope, opts.principalKeys);
|
|
288
302
|
add("delegation signature (principal key)", !!del?.ok);
|
|
@@ -451,7 +465,7 @@ export async function verifyBundle(bundle, opts) {
|
|
|
451
465
|
if (!add("structural parts in clear", !broken, broken ?? undefined))
|
|
452
466
|
return done(null);
|
|
453
467
|
const p = st.predicate;
|
|
454
|
-
add("issuer kind is known", p.issuer.kind === "gateway" || p.issuer.kind === "sdk", `${p.issuer.kind}${p.issuer.framework ? ` / ${p.issuer.framework}` : ""}`);
|
|
468
|
+
add("issuer kind is known", p.issuer.kind === "gateway" || p.issuer.kind === "sdk" || p.issuer.kind === "door", `${p.issuer.kind}${p.issuer.framework ? ` / ${p.issuer.framework}` : ""}`);
|
|
455
469
|
add("issuer keyid matches signer", p.issuer.keyid === sig.keyid);
|
|
456
470
|
if (opts.requireStrict) {
|
|
457
471
|
add("strict mode in force", p.issuer.kind === "gateway" && p.issuer.strict === true, p.issuer.strict === true ? undefined : "the issuer does not say it ran in strict mode");
|
|
@@ -474,6 +488,8 @@ export async function verifyBundle(bundle, opts) {
|
|
|
474
488
|
add("gateway receipt carries a delegation", p.delegation !== undefined);
|
|
475
489
|
add("gateway receipt carries a policy decision", p.policy !== null);
|
|
476
490
|
}
|
|
491
|
+
if (p.issuer.kind === "door")
|
|
492
|
+
add("door receipt carries a policy decision", p.policy !== null);
|
|
477
493
|
if (p.delegation) {
|
|
478
494
|
const del = await verifyDelegationChain(p.delegation.envelope, opts.principalKeys);
|
|
479
495
|
const d = del.ok ? del.delegation : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-custody/state",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Governed memory for AI agents: a fact ledger with provenance, valid time, rollback, lineage, certified forget, and a store that is a JSONL file, SQLite, or Postgres, built on @agent-custody/receipts",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"node": ">=22"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@agent-custody/receipts": "0.
|
|
37
|
-
"@modelcontextprotocol/sdk": "
|
|
38
|
-
"zod": "
|
|
36
|
+
"@agent-custody/receipts": "0.15.0",
|
|
37
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
38
|
+
"zod": "4.5.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@electric-sql/pglite": "0.5.8",
|
|
42
|
-
"@getzep/zep-cloud": "
|
|
43
|
-
"@types/node": "
|
|
44
|
-
"mem0ai": "
|
|
45
|
-
"typescript": "
|
|
46
|
-
"vitest": "
|
|
42
|
+
"@getzep/zep-cloud": "3.28.0",
|
|
43
|
+
"@types/node": "26.4.1",
|
|
44
|
+
"mem0ai": "3.1.8",
|
|
45
|
+
"typescript": "7.0.2",
|
|
46
|
+
"vitest": "5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"pg": ">=8"
|