mneme-ai 3.5.1 → 3.6.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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme mcpgate` (v3.6.0) — the local-first MCP gateway surface.
|
|
3
|
+
* mcpgate decide --tool <t> [--args '<json>'] [--agent a] → ALLOW / NEEDS-APPROVAL / BLOCK
|
|
4
|
+
* mcpgate audit [--verify] → the signed, offline-verifiable call ledger
|
|
5
|
+
* Every call through `gephyra serve` (HTTP MCP-proxy) and the matrix gRPC rail is gated + audited
|
|
6
|
+
* automatically; this CLI is for manual decisions + verifying the audit chain.
|
|
7
|
+
*/
|
|
8
|
+
import type { Command } from "commander";
|
|
9
|
+
export declare function registerMcpgateCommands(program: Command): void;
|
|
10
|
+
//# sourceMappingURL=mcpgate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpgate.d.ts","sourceRoot":"","sources":["../../src/commands/mcpgate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmC9D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { mcpgate, notary } from "@mneme-ai/core";
|
|
4
|
+
function out(s) { process.stdout.write(s + "\n"); }
|
|
5
|
+
export function registerMcpgateCommands(program) {
|
|
6
|
+
const k = program.command("mcpgate").description("🛂 MCP GATEWAY — gate every agent tool-call (policy + behavioral risk + skill provenance → allow / needs-approval / block) and keep a SIGNED, offline-verifiable audit ledger. Local-first; the runtime perimeter a cloud gateway can't be.");
|
|
7
|
+
k.command("decide").description("Gate one tool-call.")
|
|
8
|
+
.requiredOption("--tool <t>", "tool name").option("--args <json>", "args JSON", "{}").option("--agent <a>", "agent id", "agent").option("--json", "emit JSON")
|
|
9
|
+
.action((o) => {
|
|
10
|
+
let args = {};
|
|
11
|
+
try {
|
|
12
|
+
args = JSON.parse(o.args ?? "{}");
|
|
13
|
+
}
|
|
14
|
+
catch { /* */ }
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
let policy = {};
|
|
17
|
+
try {
|
|
18
|
+
const pp = join(cwd, ".mneme", "mcpgate", "policy.json");
|
|
19
|
+
if (existsSync(pp))
|
|
20
|
+
policy = JSON.parse(readFileSync(pp, "utf8"));
|
|
21
|
+
}
|
|
22
|
+
catch { /* */ }
|
|
23
|
+
const v = mcpgate.gateCall({ tool: o.tool, agent: o.agent, args }, policy);
|
|
24
|
+
if (o.json) {
|
|
25
|
+
out(JSON.stringify(v, null, 2));
|
|
26
|
+
if (v.decision === "block")
|
|
27
|
+
process.exitCode = 2;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const icon = v.decision === "block" ? "🔴" : v.decision === "needs-approval" ? "🟡" : "🟢";
|
|
31
|
+
out(`🛂 ${icon} ${v.decision.toUpperCase()} · ${o.tool} · risk ${v.risk} · args ${v.argsHash.slice(0, 12)}…`);
|
|
32
|
+
for (const r of v.reasons)
|
|
33
|
+
out(` • ${r}`);
|
|
34
|
+
if (v.decision === "needs-approval")
|
|
35
|
+
out(" → route to the human: mneme pager request");
|
|
36
|
+
if (v.decision === "block")
|
|
37
|
+
process.exitCode = 2;
|
|
38
|
+
});
|
|
39
|
+
k.command("audit").description("Show + verify the call audit ledger (.mneme/mcpgate/audit.jsonl).")
|
|
40
|
+
.option("--verify", "verify the hash-chain + the NOTARY-signed head OFFLINE").option("--tail <n>", "show the last N frames", "10")
|
|
41
|
+
.action((o) => {
|
|
42
|
+
const dir = join(process.cwd(), ".mneme", "mcpgate");
|
|
43
|
+
const ledger = join(dir, "audit.jsonl");
|
|
44
|
+
if (!existsSync(ledger)) {
|
|
45
|
+
out("no audit ledger yet (no gated calls)");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const frames = readFileSync(ledger, "utf8").trim().split("\n").filter(Boolean).map((l) => { try {
|
|
49
|
+
return JSON.parse(l);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
} }).filter(Boolean);
|
|
54
|
+
const tail = Math.max(1, parseInt(o.tail ?? "10", 10));
|
|
55
|
+
out(`🛂 MCP gateway audit — ${frames.length} call(s)`);
|
|
56
|
+
for (const f of frames.slice(-tail))
|
|
57
|
+
out(` #${f.seq} ${f.decision === "block" ? "🔴" : f.decision === "needs-approval" ? "🟡" : "🟢"} ${f.tool} · ${f.agent} · risk ${f.risk} · args ${f.argsHash.slice(0, 10)}…`);
|
|
58
|
+
if (o.verify) {
|
|
59
|
+
const chain = mcpgate.verifyAuditChain(frames);
|
|
60
|
+
out(chain.ok ? ` ✓ chain VERIFIED — ${chain.frames} frames intact (offline, tamper-evident)` : ` ✗ chain BROKEN at #${chain.brokenAt}: ${chain.reason}`);
|
|
61
|
+
const headPath = join(dir, "audit.head.json");
|
|
62
|
+
if (existsSync(headPath)) {
|
|
63
|
+
try {
|
|
64
|
+
const rec = JSON.parse(readFileSync(headPath, "utf8"));
|
|
65
|
+
const v = notary.verifyReceipt(rec);
|
|
66
|
+
const head = rec.payload?.frameId;
|
|
67
|
+
const last = frames[frames.length - 1]?.frameId;
|
|
68
|
+
out(v.valid ? ` ✓ signed head VALID (Ed25519, offline)${head === last ? " · points at the current tip" : " · ⚠ tip moved"}` : ` ✗ signed head INVALID: ${v.reason}`);
|
|
69
|
+
}
|
|
70
|
+
catch { /* */ }
|
|
71
|
+
}
|
|
72
|
+
if (!chain.ok)
|
|
73
|
+
process.exitCode = 2;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=mcpgate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp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gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;YAAC,CAAC;YAC1a,IAAI,CAAC,KAAK,CAAC,EAAE;gBAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8LA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8lNvD"}
|
package/dist/index.js
CHANGED
|
@@ -107,6 +107,7 @@ import { registerPagerCommands } from "./commands/pager.js";
|
|
|
107
107
|
import { registerKeryxCommands } from "./commands/keryx.js";
|
|
108
108
|
import { registerCompileCommands } from "./commands/compile.js";
|
|
109
109
|
import { registerSkillscanCommands } from "./commands/skillscan.js";
|
|
110
|
+
import { registerMcpgateCommands } from "./commands/mcpgate.js";
|
|
110
111
|
import { registerAdamasCommands } from "./commands/adamas.js";
|
|
111
112
|
import { registerPrismCommands } from "./commands/prism.js";
|
|
112
113
|
import { registerGoldilocksCommands } from "./commands/goldilocks.js";
|
|
@@ -4781,6 +4782,7 @@ export async function run(argv) {
|
|
|
4781
4782
|
registerKeryxCommands(program);
|
|
4782
4783
|
registerCompileCommands(program);
|
|
4783
4784
|
registerSkillscanCommands(program);
|
|
4785
|
+
registerMcpgateCommands(program);
|
|
4784
4786
|
registerAdamasCommands(program);
|
|
4785
4787
|
registerPrismCommands(program);
|
|
4786
4788
|
registerGoldilocksCommands(program);
|