@mneme-ai/core 2.60.0 → 2.62.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/dist/agent_manifest.d.ts.map +1 -1
- package/dist/agent_manifest.js +11 -0
- package/dist/agent_manifest.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/mirrage/conscience_ladder.d.ts +35 -0
- package/dist/mirrage/conscience_ladder.d.ts.map +1 -0
- package/dist/mirrage/conscience_ladder.js +39 -0
- package/dist/mirrage/conscience_ladder.js.map +1 -0
- package/dist/mirrage/heuristics.d.ts +40 -0
- package/dist/mirrage/heuristics.d.ts.map +1 -0
- package/dist/mirrage/heuristics.js +105 -0
- package/dist/mirrage/heuristics.js.map +1 -0
- package/dist/mirrage/index.d.ts +160 -0
- package/dist/mirrage/index.d.ts.map +1 -0
- package/dist/mirrage/index.js +296 -0
- package/dist/mirrage/index.js.map +1 -0
- package/dist/mirrage/sentence_splitter.d.ts +22 -0
- package/dist/mirrage/sentence_splitter.d.ts.map +1 -0
- package/dist/mirrage/sentence_splitter.js +86 -0
- package/dist/mirrage/sentence_splitter.js.map +1 -0
- package/dist/passport/index.d.ts +166 -0
- package/dist/passport/index.d.ts.map +1 -0
- package/dist/passport/index.js +369 -0
- package/dist/passport/index.js.map +1 -0
- package/dist/passport/policy.d.ts +34 -0
- package/dist/passport/policy.d.ts.map +1 -0
- package/dist/passport/policy.js +75 -0
- package/dist/passport/policy.js.map +1 -0
- package/dist/passport/trust_score.d.ts +46 -0
- package/dist/passport/trust_score.d.ts.map +1 -0
- package/dist/passport/trust_score.js +64 -0
- package/dist/passport/trust_score.js.map +1 -0
- package/dist/truth_gate/claims.d.ts.map +1 -1
- package/dist/truth_gate/claims.js +38 -0
- package/dist/truth_gate/claims.js.map +1 -1
- package/dist/truth_gate/probes.d.ts.map +1 -1
- package/dist/truth_gate/probes.js +116 -0
- package/dist/truth_gate/probes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.61.0 — PASSPORT: capability-based security for MCP.
|
|
3
|
+
*
|
|
4
|
+
* Pre-v2.61, every MCP tool was equal-trust: an agent could ask for
|
|
5
|
+
* `shell.exec` the same way it asks for `read_file`. This is the
|
|
6
|
+
* security model of "all root" — exactly what a CISO refuses.
|
|
7
|
+
*
|
|
8
|
+
* PASSPORT introduces capability tokens. Before calling a sensitive
|
|
9
|
+
* tool, an agent must request a HMAC-signed passport from Mneme.
|
|
10
|
+
* Other MCP servers (or future Mneme-wrapped servers) verify the
|
|
11
|
+
* passport HMAC + scope + TTL before executing. If the requesting
|
|
12
|
+
* agent's trust score is below the tier's threshold → REFUSED.
|
|
13
|
+
*
|
|
14
|
+
* Five wild innovations (the "premium" angle beyond a JWT):
|
|
15
|
+
*
|
|
16
|
+
* 1. COMPOSED TRUST SCORE — fuses NEMESIS env-scan + verify_identity
|
|
17
|
+
* + HONEST_MIRROR weight + STEALTH score + historical approval
|
|
18
|
+
* rate into a single 0..1. Per-signal weighted; transparent
|
|
19
|
+
* for audit. Hand-written single-scores can lie; fused signals
|
|
20
|
+
* resist gaming.
|
|
21
|
+
*
|
|
22
|
+
* 2. CAPABILITY DELEGATION CHAIN — passport.delegate(parent, scope)
|
|
23
|
+
* creates a CHILD passport with strictly-reduced scope + parent
|
|
24
|
+
* reference. Verifier walks the chain to attribute every call to
|
|
25
|
+
* the originating agent. Cycles + scope-expansion attempts are
|
|
26
|
+
* refused.
|
|
27
|
+
*
|
|
28
|
+
* 3. HMAC-CHAINED AUDIT LEDGER — every issuance + verification +
|
|
29
|
+
* revocation appends to `.mneme/passport/ledger.jsonl` with
|
|
30
|
+
* HMAC chain. Tamper-evident; works offline; survives daemon
|
|
31
|
+
* restart. Court-admissible audit trail.
|
|
32
|
+
*
|
|
33
|
+
* 4. REVOCATION CASCADE — revoking a parent passport auto-revokes
|
|
34
|
+
* every child issued via delegation. Atomic propagation; no
|
|
35
|
+
* dangling permissions after a vendor incident.
|
|
36
|
+
*
|
|
37
|
+
* 5. POLICY OVERRIDES — `.mneme/passport/policy.json` lets users
|
|
38
|
+
* tighten DEFAULT_POLICY (e.g. require multi-party for
|
|
39
|
+
* destructive tier). Pinned + drift-detectable like SKELETON
|
|
40
|
+
* KEY snapshots — silent policy tampering is detectable.
|
|
41
|
+
*
|
|
42
|
+
* Pure ESM. Defensive — never throws.
|
|
43
|
+
*/
|
|
44
|
+
import { createHmac, randomBytes } from "node:crypto";
|
|
45
|
+
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
46
|
+
import { dirname, join } from "node:path";
|
|
47
|
+
import { computeTrust } from "./trust_score.js";
|
|
48
|
+
import { classifyTier, resolveTier } from "./policy.js";
|
|
49
|
+
const KEY_ENV = "MNEME_PASSPORT_KEY";
|
|
50
|
+
const DEFAULT_KEY = "mneme-passport-v1";
|
|
51
|
+
function keyOf() { return process.env[KEY_ENV] ?? DEFAULT_KEY; }
|
|
52
|
+
/* ── Token encoding ─────────────────────────────────────────────── */
|
|
53
|
+
function canonicalJson(o) {
|
|
54
|
+
// Deterministic key ordering for HMAC stability.
|
|
55
|
+
// Drop keys with undefined values (JSON.stringify default behavior).
|
|
56
|
+
if (o === undefined)
|
|
57
|
+
return "null"; // shouldn't surface at top level
|
|
58
|
+
if (o === null || typeof o !== "object")
|
|
59
|
+
return JSON.stringify(o);
|
|
60
|
+
if (Array.isArray(o))
|
|
61
|
+
return "[" + o.map((x) => canonicalJson(x === undefined ? null : x)).join(",") + "]";
|
|
62
|
+
const entries = Object.entries(o).filter(([, v]) => v !== undefined);
|
|
63
|
+
entries.sort(([a], [b]) => a.localeCompare(b));
|
|
64
|
+
return "{" + entries.map(([k, v]) => JSON.stringify(k) + ":" + canonicalJson(v)).join(",") + "}";
|
|
65
|
+
}
|
|
66
|
+
function signClaims(claims) {
|
|
67
|
+
return createHmac("sha256", keyOf()).update(canonicalJson(claims)).digest("hex");
|
|
68
|
+
}
|
|
69
|
+
function encodeToken(claims, hmac) {
|
|
70
|
+
const body = Buffer.from(canonicalJson(claims), "utf8").toString("base64url");
|
|
71
|
+
return `${body}.${hmac}`;
|
|
72
|
+
}
|
|
73
|
+
export function decodePassport(token) {
|
|
74
|
+
if (typeof token !== "string")
|
|
75
|
+
return null;
|
|
76
|
+
const dot = token.indexOf(".");
|
|
77
|
+
if (dot <= 0)
|
|
78
|
+
return null;
|
|
79
|
+
const body = token.slice(0, dot);
|
|
80
|
+
const hmac = token.slice(dot + 1);
|
|
81
|
+
try {
|
|
82
|
+
const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
83
|
+
if (!claims || typeof claims !== "object")
|
|
84
|
+
return null;
|
|
85
|
+
return { claims, hmac };
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function ledgerPath(cwd) {
|
|
92
|
+
return join(cwd, ".mneme", "passport", "ledger.jsonl");
|
|
93
|
+
}
|
|
94
|
+
function readLedgerLines(cwd) {
|
|
95
|
+
try {
|
|
96
|
+
return readFileSync(ledgerPath(cwd), "utf8").trim().split(/\n/).filter((l) => l.trim().length > 0);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function lastLedgerHmac(cwd) {
|
|
103
|
+
const lines = readLedgerLines(cwd);
|
|
104
|
+
if (lines.length === 0)
|
|
105
|
+
return "";
|
|
106
|
+
try {
|
|
107
|
+
return JSON.parse(lines[lines.length - 1]).hmac;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return "";
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function appendLedger(cwd, kind, jti, extra) {
|
|
114
|
+
const prevHmac = lastLedgerHmac(cwd);
|
|
115
|
+
const body = {
|
|
116
|
+
kind, at: new Date().toISOString(), jti,
|
|
117
|
+
tool: extra.tool, agent: extra.agent, verdict: extra.verdict, prevHmac,
|
|
118
|
+
};
|
|
119
|
+
const hmac = createHmac("sha256", keyOf()).update(prevHmac).update(canonicalJson(body)).digest("hex");
|
|
120
|
+
const entry = { ...body, hmac };
|
|
121
|
+
try {
|
|
122
|
+
mkdirSync(dirname(ledgerPath(cwd)), { recursive: true });
|
|
123
|
+
appendFileSync(ledgerPath(cwd), JSON.stringify(entry) + "\n");
|
|
124
|
+
}
|
|
125
|
+
catch { /* noop */ }
|
|
126
|
+
return entry;
|
|
127
|
+
}
|
|
128
|
+
/* ── Revocation ─────────────────────────────────────────────────── */
|
|
129
|
+
function revocationsPath(cwd) {
|
|
130
|
+
return join(cwd, ".mneme", "passport", "revocations.json");
|
|
131
|
+
}
|
|
132
|
+
function readRevocations(cwd) {
|
|
133
|
+
try {
|
|
134
|
+
const data = JSON.parse(readFileSync(revocationsPath(cwd), "utf8"));
|
|
135
|
+
return new Set(data.jtis ?? []);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return new Set();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function writeRevocations(cwd, set) {
|
|
142
|
+
try {
|
|
143
|
+
mkdirSync(dirname(revocationsPath(cwd)), { recursive: true });
|
|
144
|
+
writeFileSync(revocationsPath(cwd), JSON.stringify({ jtis: Array.from(set) }, null, 2));
|
|
145
|
+
}
|
|
146
|
+
catch { /* noop */ }
|
|
147
|
+
}
|
|
148
|
+
/* ── Delegation graph ───────────────────────────────────────────── */
|
|
149
|
+
function delegationGraphPath(cwd) {
|
|
150
|
+
return join(cwd, ".mneme", "passport", "delegations.json");
|
|
151
|
+
}
|
|
152
|
+
function readDelegations(cwd) {
|
|
153
|
+
try {
|
|
154
|
+
return JSON.parse(readFileSync(delegationGraphPath(cwd), "utf8"));
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return { parents: {} };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function writeDelegations(cwd, g) {
|
|
161
|
+
try {
|
|
162
|
+
mkdirSync(dirname(delegationGraphPath(cwd)), { recursive: true });
|
|
163
|
+
writeFileSync(delegationGraphPath(cwd), JSON.stringify(g, null, 2));
|
|
164
|
+
}
|
|
165
|
+
catch { /* noop */ }
|
|
166
|
+
}
|
|
167
|
+
function descendantsOf(jti, g) {
|
|
168
|
+
const set = new Set();
|
|
169
|
+
const queue = [jti];
|
|
170
|
+
while (queue.length > 0) {
|
|
171
|
+
const cur = queue.shift();
|
|
172
|
+
for (const [child, parent] of Object.entries(g.parents)) {
|
|
173
|
+
if (parent === cur && !set.has(child)) {
|
|
174
|
+
set.add(child);
|
|
175
|
+
queue.push(child);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return set;
|
|
180
|
+
}
|
|
181
|
+
/* ── Issue ──────────────────────────────────────────────────────── */
|
|
182
|
+
export function issuePassport(input) {
|
|
183
|
+
const cwd = input.cwd ?? process.cwd();
|
|
184
|
+
const tierName = input.tier ?? classifyTier(input.tool);
|
|
185
|
+
const tier = resolveTier(tierName, input.policyOverrides);
|
|
186
|
+
if (!tier)
|
|
187
|
+
return { ok: false, reason: "tier_unknown", hint: `unknown risk tier: ${tierName}` };
|
|
188
|
+
// Parent verification (delegation)
|
|
189
|
+
let parentJti;
|
|
190
|
+
if (input.parent) {
|
|
191
|
+
const parent = verifyPassport({ token: input.parent, cwd });
|
|
192
|
+
if (!parent.valid || !parent.claims) {
|
|
193
|
+
return { ok: false, reason: "parent_invalid", hint: `parent passport invalid: ${parent.reason}` };
|
|
194
|
+
}
|
|
195
|
+
// Child scope must be a strict subset of parent scope.
|
|
196
|
+
if (input.scope && parent.claims.scope) {
|
|
197
|
+
const parentScopes = new Set(parent.claims.scope);
|
|
198
|
+
for (const s of input.scope) {
|
|
199
|
+
if (!parentScopes.has(s)) {
|
|
200
|
+
return { ok: false, reason: "parent_scope_violation", hint: `child scope '${s}' not in parent scope` };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
parentJti = parent.claims.jti;
|
|
205
|
+
}
|
|
206
|
+
// Trust score
|
|
207
|
+
const trust = computeTrust(input.trustInputs ?? {});
|
|
208
|
+
if (trust.score < tier.minTrust) {
|
|
209
|
+
return {
|
|
210
|
+
ok: false, reason: "trust_too_low",
|
|
211
|
+
hint: `trust ${(trust.score * 100).toFixed(0)}% < required ${(tier.minTrust * 100).toFixed(0)}% for tier '${tierName}': ${trust.reason}`,
|
|
212
|
+
trust, tier: { ...tier, name: tierName },
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const now = Date.now();
|
|
216
|
+
const claims = {
|
|
217
|
+
tool: input.tool,
|
|
218
|
+
tier: tierName,
|
|
219
|
+
iat: new Date(now).toISOString(),
|
|
220
|
+
exp: new Date(now + tier.ttlMs).toISOString(),
|
|
221
|
+
jti: randomBytes(8).toString("hex"),
|
|
222
|
+
parentJti,
|
|
223
|
+
agent: input.agent,
|
|
224
|
+
trust: trust.score,
|
|
225
|
+
scope: input.scope,
|
|
226
|
+
};
|
|
227
|
+
const hmac = signClaims(claims);
|
|
228
|
+
const token = encodeToken(claims, hmac);
|
|
229
|
+
const passport = { claims, hmac, token };
|
|
230
|
+
// Persist delegation edge.
|
|
231
|
+
if (parentJti) {
|
|
232
|
+
const g = readDelegations(cwd);
|
|
233
|
+
g.parents[claims.jti] = parentJti;
|
|
234
|
+
writeDelegations(cwd, g);
|
|
235
|
+
}
|
|
236
|
+
// Audit ledger.
|
|
237
|
+
appendLedger(cwd, "issue", claims.jti, { tool: claims.tool, agent: claims.agent });
|
|
238
|
+
return {
|
|
239
|
+
ok: true, reason: "granted",
|
|
240
|
+
hint: `passport issued: tier=${tierName} ttl=${(tier.ttlMs / 1000).toFixed(0)}s trust=${(trust.score * 100).toFixed(0)}%`,
|
|
241
|
+
passport, trust, tier: { ...tier, name: tierName },
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
export function verifyPassport(input) {
|
|
245
|
+
const cwd = input.cwd ?? process.cwd();
|
|
246
|
+
const decoded = decodePassport(input.token);
|
|
247
|
+
if (!decoded)
|
|
248
|
+
return { valid: false, reason: "malformed" };
|
|
249
|
+
const { claims, hmac } = decoded;
|
|
250
|
+
const expected = signClaims(claims);
|
|
251
|
+
if (expected !== hmac) {
|
|
252
|
+
if (!input.noLedger)
|
|
253
|
+
appendLedger(cwd, "verify", claims.jti, { verdict: "bad_hmac", tool: claims.tool });
|
|
254
|
+
return { valid: false, reason: "bad_hmac", claims };
|
|
255
|
+
}
|
|
256
|
+
const now = Date.now();
|
|
257
|
+
const expMs = Date.parse(claims.exp);
|
|
258
|
+
if (!Number.isFinite(expMs) || now > expMs) {
|
|
259
|
+
if (!input.noLedger)
|
|
260
|
+
appendLedger(cwd, "verify", claims.jti, { verdict: "expired", tool: claims.tool });
|
|
261
|
+
return { valid: false, reason: "expired", claims };
|
|
262
|
+
}
|
|
263
|
+
const revoked = readRevocations(cwd);
|
|
264
|
+
if (revoked.has(claims.jti)) {
|
|
265
|
+
if (!input.noLedger)
|
|
266
|
+
appendLedger(cwd, "verify", claims.jti, { verdict: "revoked", tool: claims.tool });
|
|
267
|
+
return { valid: false, reason: "revoked", claims };
|
|
268
|
+
}
|
|
269
|
+
if (input.expectedTool && claims.tool !== input.expectedTool) {
|
|
270
|
+
if (!input.noLedger)
|
|
271
|
+
appendLedger(cwd, "verify", claims.jti, { verdict: "tool_mismatch", tool: claims.tool });
|
|
272
|
+
return { valid: false, reason: "tool_mismatch", claims };
|
|
273
|
+
}
|
|
274
|
+
if (input.expectedScope && input.expectedScope.length > 0) {
|
|
275
|
+
const have = new Set(claims.scope ?? []);
|
|
276
|
+
for (const s of input.expectedScope) {
|
|
277
|
+
if (!have.has(s)) {
|
|
278
|
+
if (!input.noLedger)
|
|
279
|
+
appendLedger(cwd, "verify", claims.jti, { verdict: "scope_mismatch", tool: claims.tool });
|
|
280
|
+
return { valid: false, reason: "scope_mismatch", claims };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// Build delegation chain (audit-only — revocation cascade is handled
|
|
285
|
+
// by revokePassport({cascade:true}) explicitly marking descendants.
|
|
286
|
+
// If the caller used cascade=false on revoke, they're explicitly saying
|
|
287
|
+
// descendants should remain valid — verify must honor that intent.
|
|
288
|
+
const chain = [];
|
|
289
|
+
if (claims.parentJti) {
|
|
290
|
+
const g = readDelegations(cwd);
|
|
291
|
+
let cursor = claims.parentJti;
|
|
292
|
+
const guard = new Set();
|
|
293
|
+
while (cursor && !guard.has(cursor)) {
|
|
294
|
+
guard.add(cursor);
|
|
295
|
+
chain.unshift({ ...claims, jti: cursor, tool: claims.tool });
|
|
296
|
+
cursor = g.parents[cursor];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (!input.noLedger)
|
|
300
|
+
appendLedger(cwd, "verify", claims.jti, { verdict: "valid", tool: claims.tool });
|
|
301
|
+
return { valid: true, reason: "ok", ttlMs: expMs - now, claims, chain };
|
|
302
|
+
}
|
|
303
|
+
export function revokePassport(input) {
|
|
304
|
+
const cwd = input.cwd ?? process.cwd();
|
|
305
|
+
let jti = input.jti;
|
|
306
|
+
if (!jti && input.token) {
|
|
307
|
+
const d = decodePassport(input.token);
|
|
308
|
+
if (d)
|
|
309
|
+
jti = d.claims.jti;
|
|
310
|
+
}
|
|
311
|
+
if (!jti)
|
|
312
|
+
return { ok: false, revokedJtis: [], hint: "missing jti or token" };
|
|
313
|
+
const cascade = input.cascade !== false;
|
|
314
|
+
const revoked = readRevocations(cwd);
|
|
315
|
+
revoked.add(jti);
|
|
316
|
+
const cascaded = [];
|
|
317
|
+
if (cascade) {
|
|
318
|
+
const g = readDelegations(cwd);
|
|
319
|
+
for (const desc of descendantsOf(jti, g)) {
|
|
320
|
+
if (!revoked.has(desc))
|
|
321
|
+
cascaded.push(desc);
|
|
322
|
+
revoked.add(desc);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
writeRevocations(cwd, revoked);
|
|
326
|
+
appendLedger(cwd, "revoke", jti, { verdict: cascade ? `cascade(+${cascaded.length})` : "single" });
|
|
327
|
+
return {
|
|
328
|
+
ok: true,
|
|
329
|
+
revokedJtis: [jti, ...cascaded],
|
|
330
|
+
hint: cascaded.length > 0 ? `revoked ${jti} + ${cascaded.length} delegated descendant(s)` : `revoked ${jti}`,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/* ── Ledger verify ──────────────────────────────────────────────── */
|
|
334
|
+
export function verifyLedgerChain(cwd) {
|
|
335
|
+
const lines = readLedgerLines(cwd);
|
|
336
|
+
let prevHmac = "";
|
|
337
|
+
for (let i = 0; i < lines.length; i++) {
|
|
338
|
+
let row;
|
|
339
|
+
try {
|
|
340
|
+
row = JSON.parse(lines[i]);
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
return { ok: false, rows: i, brokenAt: i };
|
|
344
|
+
}
|
|
345
|
+
if (row.prevHmac !== prevHmac)
|
|
346
|
+
return { ok: false, rows: i, brokenAt: i };
|
|
347
|
+
const expected = createHmac("sha256", keyOf()).update(prevHmac).update(canonicalJson({
|
|
348
|
+
kind: row.kind, at: row.at, jti: row.jti, tool: row.tool, agent: row.agent, verdict: row.verdict, prevHmac,
|
|
349
|
+
})).digest("hex");
|
|
350
|
+
if (expected !== row.hmac)
|
|
351
|
+
return { ok: false, rows: i, brokenAt: i };
|
|
352
|
+
prevHmac = row.hmac;
|
|
353
|
+
}
|
|
354
|
+
return { ok: true, rows: lines.length };
|
|
355
|
+
}
|
|
356
|
+
export function readLedger(cwd) {
|
|
357
|
+
return readLedgerLines(cwd).map((l) => {
|
|
358
|
+
try {
|
|
359
|
+
return JSON.parse(l);
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
}).filter((x) => x !== null);
|
|
365
|
+
}
|
|
366
|
+
/* ── Re-exports ─────────────────────────────────────────────────── */
|
|
367
|
+
export { computeTrust } from "./trust_score.js";
|
|
368
|
+
export { DEFAULT_POLICY, classifyTier, resolveTier } from "./policy.js";
|
|
369
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/passport/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,cAAc,EAAc,SAAS,EAAE,YAAY,EAAY,aAAa,EAAE,MAAM,SAAS,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAsC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAkB,YAAY,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAExG,MAAM,OAAO,GAAG,oBAAoB,CAAC;AACrC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AACxC,SAAS,KAAK,KAAa,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC;AA4ExE,uEAAuE;AAEvE,SAAS,aAAa,CAAC,CAAU;IAC/B,iDAAiD;IACjD,qEAAqE;IACrE,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,CAAC,iCAAiC;IACrE,IAAI,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,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AAuE;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.61.0 — PASSPORT policy: risk tier → required trust threshold.
|
|
3
|
+
*
|
|
4
|
+
* Each MCP tool call is classified into a risk tier. Tiers map to a
|
|
5
|
+
* minimum trust score the requesting agent must clear AND a TTL for
|
|
6
|
+
* the issued passport. Stricter tiers = shorter TTL.
|
|
7
|
+
*
|
|
8
|
+
* Default policy is conservative; users override via `mneme passport
|
|
9
|
+
* policy --set tier=value` or `.mneme/passport/policy.json`.
|
|
10
|
+
*/
|
|
11
|
+
export type RiskTier = "safe" | "read" | "write" | "network" | "destructive";
|
|
12
|
+
export interface TierConfig {
|
|
13
|
+
/** Required trust score 0..1 to grant passport. */
|
|
14
|
+
minTrust: number;
|
|
15
|
+
/** Passport TTL in milliseconds. */
|
|
16
|
+
ttlMs: number;
|
|
17
|
+
/** Human-readable description. */
|
|
18
|
+
description: string;
|
|
19
|
+
/** When true, single-agent trust is insufficient — needs multi-party. */
|
|
20
|
+
requiresMultiParty?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare const DEFAULT_POLICY: Record<RiskTier, TierConfig>;
|
|
23
|
+
/**
|
|
24
|
+
* Classify a tool name into a risk tier using lightweight heuristics.
|
|
25
|
+
* Used when the caller does not specify a tier.
|
|
26
|
+
*
|
|
27
|
+
* Order matters: most-specific first.
|
|
28
|
+
*/
|
|
29
|
+
export declare function classifyTier(toolName: string): RiskTier;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a tier config, applying an optional user override.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveTier(tier: RiskTier, overrides?: Partial<Record<RiskTier, Partial<TierConfig>>>): TierConfig;
|
|
34
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/passport/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC;AAE7E,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,CA2BvD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAYvD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CASlH"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.61.0 — PASSPORT policy: risk tier → required trust threshold.
|
|
3
|
+
*
|
|
4
|
+
* Each MCP tool call is classified into a risk tier. Tiers map to a
|
|
5
|
+
* minimum trust score the requesting agent must clear AND a TTL for
|
|
6
|
+
* the issued passport. Stricter tiers = shorter TTL.
|
|
7
|
+
*
|
|
8
|
+
* Default policy is conservative; users override via `mneme passport
|
|
9
|
+
* policy --set tier=value` or `.mneme/passport/policy.json`.
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_POLICY = {
|
|
12
|
+
safe: {
|
|
13
|
+
minTrust: 0.0,
|
|
14
|
+
ttlMs: 60 * 60 * 1000, // 1 hour
|
|
15
|
+
description: "Read-only metadata (catalog, status, version). No state mutation possible.",
|
|
16
|
+
},
|
|
17
|
+
read: {
|
|
18
|
+
minTrust: 0.30,
|
|
19
|
+
ttlMs: 30 * 60 * 1000, // 30 min
|
|
20
|
+
description: "Read user data / files / db (could exfiltrate secrets).",
|
|
21
|
+
},
|
|
22
|
+
write: {
|
|
23
|
+
minTrust: 0.60,
|
|
24
|
+
ttlMs: 10 * 60 * 1000, // 10 min
|
|
25
|
+
description: "Mutate user data / files / db (scoped writes).",
|
|
26
|
+
},
|
|
27
|
+
network: {
|
|
28
|
+
minTrust: 0.70,
|
|
29
|
+
ttlMs: 5 * 60 * 1000, // 5 min
|
|
30
|
+
description: "Outbound network call (could exfiltrate / SSRF).",
|
|
31
|
+
},
|
|
32
|
+
destructive: {
|
|
33
|
+
minTrust: 0.85,
|
|
34
|
+
ttlMs: 5 * 60 * 1000, // 5 min
|
|
35
|
+
description: "Irreversible operation (rm -rf, DROP TABLE, git push --force, terminate instance).",
|
|
36
|
+
requiresMultiParty: false, // Set true in production policy via override.
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Classify a tool name into a risk tier using lightweight heuristics.
|
|
41
|
+
* Used when the caller does not specify a tier.
|
|
42
|
+
*
|
|
43
|
+
* Order matters: most-specific first.
|
|
44
|
+
*/
|
|
45
|
+
export function classifyTier(toolName) {
|
|
46
|
+
const lower = toolName.toLowerCase();
|
|
47
|
+
// Destructive (anything that can execute arbitrary code, delete data, irreversibly mutate).
|
|
48
|
+
if (/shell|exec|spawn|bash|cmd[_.]|process[_.]|rm[_-]?(rf|fr)?|drop[_-]?(table|database)|truncate|delete[_-]?all|force[_-]?push|terminate|destroy|wipe|format/.test(lower))
|
|
49
|
+
return "destructive";
|
|
50
|
+
// Network
|
|
51
|
+
if (/fetch|http|request|post|put|delete[_-]?http|webhook|publish|broadcast|email|sms/.test(lower))
|
|
52
|
+
return "network";
|
|
53
|
+
// Write
|
|
54
|
+
if (/write|create|insert|update|patch|edit|mutate|append|set|commit|push|publish/.test(lower))
|
|
55
|
+
return "write";
|
|
56
|
+
// Read
|
|
57
|
+
if (/read|cat|fetch[_-]?file|stat|find|search|query|select|list|show/.test(lower))
|
|
58
|
+
return "read";
|
|
59
|
+
// Safe default
|
|
60
|
+
return "safe";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Resolve a tier config, applying an optional user override.
|
|
64
|
+
*/
|
|
65
|
+
export function resolveTier(tier, overrides) {
|
|
66
|
+
const base = DEFAULT_POLICY[tier];
|
|
67
|
+
const override = overrides?.[tier] ?? {};
|
|
68
|
+
return {
|
|
69
|
+
minTrust: override.minTrust ?? base.minTrust,
|
|
70
|
+
ttlMs: override.ttlMs ?? base.ttlMs,
|
|
71
|
+
description: override.description ?? base.description,
|
|
72
|
+
requiresMultiParty: override.requiresMultiParty ?? base.requiresMultiParty,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/passport/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAeH,MAAM,CAAC,MAAM,cAAc,GAAiC;IAC1D,IAAI,EAAE;QACJ,QAAQ,EAAE,GAAG;QACb,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,SAAS;QAChC,WAAW,EAAE,4EAA4E;KAC1F;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,SAAS;QAChC,WAAW,EAAE,yDAAyD;KACvE;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,SAAS;QAChC,WAAW,EAAE,gDAAgD;KAC9D;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,CAAC,GAAG,E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CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.61.0 — PASSPORT trust score.
|
|
3
|
+
*
|
|
4
|
+
* Fuses multiple signals into a single 0..1 trust score for an agent
|
|
5
|
+
* requesting capability. Composable on existing Mneme primitives —
|
|
6
|
+
* doesn't duplicate logic.
|
|
7
|
+
*
|
|
8
|
+
* Signals (weighted):
|
|
9
|
+
* - NEMESIS env-scan confidence (agent vendor known with high confidence?)
|
|
10
|
+
* - NEMESIS verify_identity verdict (claimed vs detected)
|
|
11
|
+
* - HONEST_MIRROR weight per vendor (calibrated from past performance)
|
|
12
|
+
* - STEALTH score INVERTED (stealthy agents = harder to attribute = lower trust)
|
|
13
|
+
* - Past PASSPORT request approval rate (behavior history)
|
|
14
|
+
*
|
|
15
|
+
* Each signal is optional; missing signals contribute neutral 0.5.
|
|
16
|
+
* Output: { score, reason, signals } — score is HMAC-friendly determinism.
|
|
17
|
+
*/
|
|
18
|
+
export interface TrustInputs {
|
|
19
|
+
/** NEMESIS env-scan confidence 0..1 (how sure are we of the vendor identity). */
|
|
20
|
+
envScanConfidence?: number;
|
|
21
|
+
/** NEMESIS verify_identity verdict if available. */
|
|
22
|
+
identityVerdict?: "CONFIRMED" | "DISPUTED" | "IMPOSSIBLE" | "INCONCLUSIVE";
|
|
23
|
+
/** HONEST_MIRROR per-vendor weight 0..1 (calibrated honesty). */
|
|
24
|
+
honestMirrorWeight?: number;
|
|
25
|
+
/** STEALTH score 0..1 (1 = perfectly anonymous; lower trust for sensitive ops). */
|
|
26
|
+
stealthScore?: number;
|
|
27
|
+
/** Past PASSPORT approval rate 0..1 (count approved / total requested). */
|
|
28
|
+
historicalApprovalRate?: number;
|
|
29
|
+
/** Per-capability-class score (e.g. write_fs has been used successfully 50× without incident). */
|
|
30
|
+
perCapabilityScore?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface TrustResult {
|
|
33
|
+
/** Final fused score 0..1. */
|
|
34
|
+
score: number;
|
|
35
|
+
/** Plain-English explanation. */
|
|
36
|
+
reason: string;
|
|
37
|
+
/** Per-signal breakdown (transparency for audit). */
|
|
38
|
+
signals: Array<{
|
|
39
|
+
name: string;
|
|
40
|
+
value: number;
|
|
41
|
+
weight: number;
|
|
42
|
+
contribution: number;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
export declare function computeTrust(inputs: TrustInputs): TrustResult;
|
|
46
|
+
//# sourceMappingURL=trust_score.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust_score.d.ts","sourceRoot":"","sources":["../../src/passport/trust_score.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,WAAW;IAC1B,iFAAiF;IACjF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,eAAe,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,CAAC;IAC3E,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kGAAkG;IAClG,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvF;AAsBD,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAmC7D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.61.0 — PASSPORT trust score.
|
|
3
|
+
*
|
|
4
|
+
* Fuses multiple signals into a single 0..1 trust score for an agent
|
|
5
|
+
* requesting capability. Composable on existing Mneme primitives —
|
|
6
|
+
* doesn't duplicate logic.
|
|
7
|
+
*
|
|
8
|
+
* Signals (weighted):
|
|
9
|
+
* - NEMESIS env-scan confidence (agent vendor known with high confidence?)
|
|
10
|
+
* - NEMESIS verify_identity verdict (claimed vs detected)
|
|
11
|
+
* - HONEST_MIRROR weight per vendor (calibrated from past performance)
|
|
12
|
+
* - STEALTH score INVERTED (stealthy agents = harder to attribute = lower trust)
|
|
13
|
+
* - Past PASSPORT request approval rate (behavior history)
|
|
14
|
+
*
|
|
15
|
+
* Each signal is optional; missing signals contribute neutral 0.5.
|
|
16
|
+
* Output: { score, reason, signals } — score is HMAC-friendly determinism.
|
|
17
|
+
*/
|
|
18
|
+
// Verdict → numeric value
|
|
19
|
+
const VERDICT_VALUE = {
|
|
20
|
+
CONFIRMED: 1.0,
|
|
21
|
+
DISPUTED: 0.3,
|
|
22
|
+
IMPOSSIBLE: 0.0,
|
|
23
|
+
INCONCLUSIVE: 0.5,
|
|
24
|
+
};
|
|
25
|
+
// Weights (sum to 1.0 across present signals).
|
|
26
|
+
const WEIGHTS = {
|
|
27
|
+
envScanConfidence: 0.20,
|
|
28
|
+
identityVerdict: 0.25,
|
|
29
|
+
honestMirrorWeight: 0.25,
|
|
30
|
+
stealthScoreInverted: 0.10,
|
|
31
|
+
historicalApprovalRate: 0.10,
|
|
32
|
+
perCapabilityScore: 0.10,
|
|
33
|
+
};
|
|
34
|
+
function clamp(x) { return Math.max(0, Math.min(1, x)); }
|
|
35
|
+
export function computeTrust(inputs) {
|
|
36
|
+
const signals = [];
|
|
37
|
+
let totalWeight = 0;
|
|
38
|
+
let weightedSum = 0;
|
|
39
|
+
const add = (name, valueOpt, weight, neutral = 0.5) => {
|
|
40
|
+
const v = typeof valueOpt === "number" && Number.isFinite(valueOpt) ? clamp(valueOpt) : neutral;
|
|
41
|
+
const present = typeof valueOpt === "number" && Number.isFinite(valueOpt);
|
|
42
|
+
if (present) {
|
|
43
|
+
signals.push({ name, value: v, weight, contribution: +(v * weight).toFixed(4) });
|
|
44
|
+
totalWeight += weight;
|
|
45
|
+
weightedSum += v * weight;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
signals.push({ name, value: v, weight: 0, contribution: 0 });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
add("envScanConfidence", inputs.envScanConfidence, WEIGHTS.envScanConfidence);
|
|
52
|
+
add("identityVerdict", inputs.identityVerdict ? VERDICT_VALUE[inputs.identityVerdict] : undefined, WEIGHTS.identityVerdict);
|
|
53
|
+
add("honestMirrorWeight", inputs.honestMirrorWeight, WEIGHTS.honestMirrorWeight);
|
|
54
|
+
add("stealthScoreInverted", typeof inputs.stealthScore === "number" ? 1 - clamp(inputs.stealthScore) : undefined, WEIGHTS.stealthScoreInverted);
|
|
55
|
+
add("historicalApprovalRate", inputs.historicalApprovalRate, WEIGHTS.historicalApprovalRate);
|
|
56
|
+
add("perCapabilityScore", inputs.perCapabilityScore, WEIGHTS.perCapabilityScore);
|
|
57
|
+
const score = totalWeight > 0 ? +(weightedSum / totalWeight).toFixed(4) : 0.5;
|
|
58
|
+
const presentCount = signals.filter((s) => s.weight > 0).length;
|
|
59
|
+
const reason = presentCount === 0
|
|
60
|
+
? "no trust signals provided — defaulting to neutral 0.5"
|
|
61
|
+
: `fused ${presentCount}/${signals.length} signals → score ${(score * 100).toFixed(0)}%`;
|
|
62
|
+
return { score, reason, signals };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=trust_score.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust_score.js","sourceRoot":"","sources":["../../src/passport/trust_score.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA0BH,0BAA0B;AAC1B,MAAM,aAAa,GAAgE;IACj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MAAM,CAAC;IAChE,MAAM,MAAM,GAAG,YAAY,KAAK,CAAC;QAC/B,CAAC,CAAC,uDAAuD;QACzD,CAAC,CAAC,SAAS,YAAY,IAAI,OAAO,CAAC,MAAM,oBAAoB,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAE3F,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../../src/truth_gate/claims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../../src/truth_gate/claims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,KAAK,CA4f9C,CAAC"}
|