@mneme-ai/mcp 1.17.6 → 1.18.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 +64 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +76 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp_primitives/completion.d.ts +19 -0
- package/dist/mcp_primitives/completion.d.ts.map +1 -0
- package/dist/mcp_primitives/completion.js +55 -0
- package/dist/mcp_primitives/completion.js.map +1 -0
- package/dist/mcp_primitives/prompts.d.ts +36 -0
- package/dist/mcp_primitives/prompts.d.ts.map +1 -0
- package/dist/mcp_primitives/prompts.js +140 -0
- package/dist/mcp_primitives/prompts.js.map +1 -0
- package/dist/mcp_primitives/resources.d.ts +30 -0
- package/dist/mcp_primitives/resources.d.ts.map +1 -0
- package/dist/mcp_primitives/resources.js +112 -0
- package/dist/mcp_primitives/resources.js.map +1 -0
- package/dist/tools/_aletheia.d.ts +82 -0
- package/dist/tools/_aletheia.d.ts.map +1 -0
- package/dist/tools/_aletheia.js +800 -0
- package/dist/tools/_aletheia.js.map +1 -0
- package/dist/tools/_confess.d.ts +67 -0
- package/dist/tools/_confess.d.ts.map +1 -0
- package/dist/tools/_confess.js +260 -0
- package/dist/tools/_confess.js.map +1 -0
- package/dist/tools/_confess.test.d.ts +6 -0
- package/dist/tools/_confess.test.d.ts.map +1 -0
- package/dist/tools/_confess.test.js +96 -0
- package/dist/tools/_confess.test.js.map +1 -0
- package/dist/tools/_contract.test.d.ts +19 -0
- package/dist/tools/_contract.test.d.ts.map +1 -0
- package/dist/tools/_contract.test.js +117 -0
- package/dist/tools/_contract.test.js.map +1 -0
- package/dist/tools/_court.d.ts +57 -0
- package/dist/tools/_court.d.ts.map +1 -0
- package/dist/tools/_court.js +261 -0
- package/dist/tools/_court.js.map +1 -0
- package/dist/tools/_court.test.d.ts +8 -0
- package/dist/tools/_court.test.d.ts.map +1 -0
- package/dist/tools/_court.test.js +111 -0
- package/dist/tools/_court.test.js.map +1 -0
- package/dist/tools/_genome_marketplace.d.ts +83 -0
- package/dist/tools/_genome_marketplace.d.ts.map +1 -0
- package/dist/tools/_genome_marketplace.js +410 -0
- package/dist/tools/_genome_marketplace.js.map +1 -0
- package/dist/tools/_genome_marketplace.test.d.ts +5 -0
- package/dist/tools/_genome_marketplace.test.d.ts.map +1 -0
- package/dist/tools/_genome_marketplace.test.js +157 -0
- package/dist/tools/_genome_marketplace.test.js.map +1 -0
- package/dist/tools/_mesh.d.ts +51 -0
- package/dist/tools/_mesh.d.ts.map +1 -0
- package/dist/tools/_mesh.js +182 -0
- package/dist/tools/_mesh.js.map +1 -0
- package/dist/tools/_registry.d.ts.map +1 -1
- package/dist/tools/_registry.js +17 -0
- package/dist/tools/_registry.js.map +1 -1
- package/dist/tools/_replay.d.ts +52 -0
- package/dist/tools/_replay.d.ts.map +1 -0
- package/dist/tools/_replay.js +253 -0
- package/dist/tools/_replay.js.map +1 -0
- package/dist/tools/_replay.test.d.ts +5 -0
- package/dist/tools/_replay.test.d.ts.map +1 -0
- package/dist/tools/_replay.test.js +90 -0
- package/dist/tools/_replay.test.js.map +1 -0
- package/dist/tools/_timetravel.d.ts +46 -0
- package/dist/tools/_timetravel.d.ts.map +1 -0
- package/dist/tools/_timetravel.js +243 -0
- package/dist/tools/_timetravel.js.map +1 -0
- package/dist/tools/_timetravel.test.d.ts +7 -0
- package/dist/tools/_timetravel.test.d.ts.map +1 -0
- package/dist/tools/_timetravel.test.js +31 -0
- package/dist/tools/_timetravel.test.js.map +1 -0
- package/dist/tools/_tool_meta.d.ts +30 -0
- package/dist/tools/_tool_meta.d.ts.map +1 -0
- package/dist/tools/_tool_meta.js +530 -0
- package/dist/tools/_tool_meta.js.map +1 -0
- package/dist/tools/_types.d.ts +46 -5
- package/dist/tools/_types.d.ts.map +1 -1
- package/dist/tools/_types.js.map +1 -1
- package/dist/tools/_verify_claims_tool.d.ts.map +1 -1
- package/dist/tools/_verify_claims_tool.js +23 -0
- package/dist/tools/_verify_claims_tool.js.map +1 -1
- package/dist/tools/audit.d.ts.map +1 -1
- package/dist/tools/audit.js +37 -0
- package/dist/tools/audit.js.map +1 -1
- package/dist/tools/memory.d.ts.map +1 -1
- package/dist/tools/memory.js +23 -0
- package/dist/tools/memory.js.map +1 -1
- package/dist/tools/quant.d.ts +10 -2
- package/dist/tools/quant.d.ts.map +1 -1
- package/dist/tools/quant.js +311 -18
- package/dist/tools/quant.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genome Marketplace — unit tests on a tmpdir repo.
|
|
3
|
+
*/
|
|
4
|
+
import { describe, expect, it, beforeEach, afterEach } from "vitest";
|
|
5
|
+
import { mkdtempSync, rmSync, mkdirSync, writeFileSync, existsSync, readFileSync } from "node:fs";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { packGenome, installGenome, verifyGenome, listInstalledGenomes, } from "./_genome_marketplace.js";
|
|
9
|
+
describe("packGenome / verifyGenome", () => {
|
|
10
|
+
let repo;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
repo = mkdtempSync(join(tmpdir(), "mneme-genome-"));
|
|
13
|
+
mkdirSync(join(repo, ".mneme"), { recursive: true });
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
try {
|
|
17
|
+
rmSync(repo, { recursive: true, force: true });
|
|
18
|
+
}
|
|
19
|
+
catch { /* ignore */ }
|
|
20
|
+
});
|
|
21
|
+
it("returns empty files array when .mneme/ has no portable files", () => {
|
|
22
|
+
const g = packGenome(repo, "test", "1.0.0");
|
|
23
|
+
expect(g.files).toHaveLength(0);
|
|
24
|
+
});
|
|
25
|
+
it("includes portable files (constitution, packs/) in the genome", () => {
|
|
26
|
+
writeFileSync(join(repo, ".mneme", "constitution.json"), JSON.stringify({ rules: ["test"] }));
|
|
27
|
+
mkdirSync(join(repo, ".mneme", "packs"), { recursive: true });
|
|
28
|
+
writeFileSync(join(repo, ".mneme", "packs", "stripe.yml"), "name: stripe\n");
|
|
29
|
+
const g = packGenome(repo, "test", "1.0.0");
|
|
30
|
+
expect(g.files.some((f) => f.name === "constitution.json")).toBe(true);
|
|
31
|
+
expect(g.files.some((f) => f.name === "packs/stripe.yml")).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
it("scrubs email addresses while preserving the domain", () => {
|
|
34
|
+
writeFileSync(join(repo, ".mneme", "tribal-knowledge.json"), JSON.stringify({ author: "alice@acme.com", note: "see bob@example.org for context" }));
|
|
35
|
+
const g = packGenome(repo, "test", "1.0.0");
|
|
36
|
+
const f = g.files.find((x) => x.name === "tribal-knowledge.json");
|
|
37
|
+
expect(f).toBeDefined();
|
|
38
|
+
expect(f.content).not.toContain("alice@acme.com");
|
|
39
|
+
expect(f.content).not.toContain("bob@example.org");
|
|
40
|
+
expect(f.content).toContain("<email>@acme.com");
|
|
41
|
+
expect(f.content).toContain("<email>@example.org");
|
|
42
|
+
});
|
|
43
|
+
it("does NOT include runtime state files (mneme.db, replay.jsonl, scoreboard)", () => {
|
|
44
|
+
writeFileSync(join(repo, ".mneme", "mneme.db"), "binary-blob");
|
|
45
|
+
writeFileSync(join(repo, ".mneme", "replay.jsonl"), `{"hash":"x"}\n`);
|
|
46
|
+
writeFileSync(join(repo, ".mneme", "confess-scoreboard.json"), "{}");
|
|
47
|
+
writeFileSync(join(repo, ".mneme", "constitution.json"), "{}");
|
|
48
|
+
const g = packGenome(repo, "test", "1.0.0");
|
|
49
|
+
expect(g.files.find((f) => f.name === "mneme.db")).toBeUndefined();
|
|
50
|
+
expect(g.files.find((f) => f.name === "replay.jsonl")).toBeUndefined();
|
|
51
|
+
expect(g.files.find((f) => f.name === "confess-scoreboard.json")).toBeUndefined();
|
|
52
|
+
expect(g.files.find((f) => f.name === "constitution.json")).toBeDefined();
|
|
53
|
+
});
|
|
54
|
+
it("contentHash is deterministic + verifiable", () => {
|
|
55
|
+
writeFileSync(join(repo, ".mneme", "constitution.json"), JSON.stringify({ a: 1 }));
|
|
56
|
+
const g1 = packGenome(repo, "test", "1.0.0");
|
|
57
|
+
const g2 = packGenome(repo, "test", "1.0.0");
|
|
58
|
+
expect(g1.contentHash).toBe(g2.contentHash);
|
|
59
|
+
expect(verifyGenome(g1).valid).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
it("verifyGenome rejects tampered hash", () => {
|
|
62
|
+
writeFileSync(join(repo, ".mneme", "constitution.json"), "{}");
|
|
63
|
+
const g = packGenome(repo, "test", "1.0.0");
|
|
64
|
+
g.files.push({ name: "extra.txt", content: "added after pack" });
|
|
65
|
+
expect(verifyGenome(g).valid).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe("installGenome", () => {
|
|
69
|
+
let src;
|
|
70
|
+
let dest;
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
src = mkdtempSync(join(tmpdir(), "mneme-genome-src-"));
|
|
73
|
+
dest = mkdtempSync(join(tmpdir(), "mneme-genome-dest-"));
|
|
74
|
+
mkdirSync(join(src, ".mneme"), { recursive: true });
|
|
75
|
+
});
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
try {
|
|
78
|
+
rmSync(src, { recursive: true, force: true });
|
|
79
|
+
}
|
|
80
|
+
catch { /* ignore */ }
|
|
81
|
+
try {
|
|
82
|
+
rmSync(dest, { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
catch { /* ignore */ }
|
|
85
|
+
});
|
|
86
|
+
it("installs all files from a verified genome", () => {
|
|
87
|
+
writeFileSync(join(src, ".mneme", "constitution.json"), JSON.stringify({ rules: [] }));
|
|
88
|
+
const g = packGenome(src, "test", "1.0.0");
|
|
89
|
+
const r = installGenome(dest, g);
|
|
90
|
+
expect(r.installed).toBe(1);
|
|
91
|
+
expect(r.skipped).toBe(0);
|
|
92
|
+
expect(existsSync(join(dest, ".mneme", "constitution.json"))).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
it("reports conflicts when destination already has the file (no force)", () => {
|
|
95
|
+
writeFileSync(join(src, ".mneme", "constitution.json"), "newer");
|
|
96
|
+
const g = packGenome(src, "test", "1.0.0");
|
|
97
|
+
mkdirSync(join(dest, ".mneme"), { recursive: true });
|
|
98
|
+
writeFileSync(join(dest, ".mneme", "constitution.json"), "older");
|
|
99
|
+
const r = installGenome(dest, g);
|
|
100
|
+
expect(r.installed).toBe(0);
|
|
101
|
+
expect(r.skipped).toBe(1);
|
|
102
|
+
expect(r.conflicts).toContain("constitution.json");
|
|
103
|
+
expect(readFileSync(join(dest, ".mneme", "constitution.json"), "utf8")).toBe("older");
|
|
104
|
+
});
|
|
105
|
+
it("force=true overwrites existing files", () => {
|
|
106
|
+
writeFileSync(join(src, ".mneme", "constitution.json"), "newer");
|
|
107
|
+
const g = packGenome(src, "test", "1.0.0");
|
|
108
|
+
mkdirSync(join(dest, ".mneme"), { recursive: true });
|
|
109
|
+
writeFileSync(join(dest, ".mneme", "constitution.json"), "older");
|
|
110
|
+
const r = installGenome(dest, g, { force: true });
|
|
111
|
+
expect(r.installed).toBe(1);
|
|
112
|
+
expect(readFileSync(join(dest, ".mneme", "constitution.json"), "utf8")).toBe("newer");
|
|
113
|
+
});
|
|
114
|
+
it("rejects path-traversal attempts", () => {
|
|
115
|
+
const g = {
|
|
116
|
+
schemaVersion: 1,
|
|
117
|
+
id: "evil",
|
|
118
|
+
title: "evil",
|
|
119
|
+
description: "",
|
|
120
|
+
publishedAt: "",
|
|
121
|
+
publishedBy: "",
|
|
122
|
+
mnemeVersion: "1.0.0",
|
|
123
|
+
contentHash: "",
|
|
124
|
+
files: [{ name: "../../../etc/passwd", content: "pwned" }],
|
|
125
|
+
};
|
|
126
|
+
// Patch the hash to make it pass verify.
|
|
127
|
+
const properHash = require("node:crypto").createHash("sha256").update(JSON.stringify(g.files)).digest("hex");
|
|
128
|
+
g.contentHash = properHash;
|
|
129
|
+
const r = installGenome(dest, g);
|
|
130
|
+
expect(r.installed).toBe(0);
|
|
131
|
+
expect(r.conflicts.some((c) => c.includes("unsafe path"))).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
it("throws when genome contentHash doesn't verify", () => {
|
|
134
|
+
const g = {
|
|
135
|
+
schemaVersion: 1,
|
|
136
|
+
id: "tampered",
|
|
137
|
+
title: "tampered",
|
|
138
|
+
description: "",
|
|
139
|
+
publishedAt: "",
|
|
140
|
+
publishedBy: "",
|
|
141
|
+
mnemeVersion: "1.0.0",
|
|
142
|
+
contentHash: "deadbeef",
|
|
143
|
+
files: [{ name: "constitution.json", content: "{}" }],
|
|
144
|
+
};
|
|
145
|
+
expect(() => installGenome(dest, g)).toThrow(/contentHash mismatch|hash/);
|
|
146
|
+
});
|
|
147
|
+
it("records the install in .mneme/genomes/{id}.installed.json", () => {
|
|
148
|
+
writeFileSync(join(src, ".mneme", "constitution.json"), "{}");
|
|
149
|
+
const g = packGenome(src, "myrepo", "1.0.0");
|
|
150
|
+
installGenome(dest, g);
|
|
151
|
+
const records = listInstalledGenomes(dest);
|
|
152
|
+
expect(records).toHaveLength(1);
|
|
153
|
+
expect(records[0].id).toBe(g.id);
|
|
154
|
+
expect(records[0].contentHash).toBe(g.contentHash);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
//# sourceMappingURL=_genome_marketplace.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_genome_marketplace.test.js","sourceRoot":"","sources":["../../src/tools/_genome_marketplace.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAA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AAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Mesh (v1.18.0 — black sheep #bonus)
|
|
3
|
+
*
|
|
4
|
+
* Multiple Mneme instances (across teams / repos) federate. Query goes
|
|
5
|
+
* out, each peer returns local results, the originator dedupes + ranks.
|
|
6
|
+
*
|
|
7
|
+
* • mneme.mesh.peers — list configured peers
|
|
8
|
+
* • mneme.mesh.federate(query) — broadcast a query, aggregate responses
|
|
9
|
+
*
|
|
10
|
+
* v1.18.0 ships the SCAFFOLDING — config-driven peer registry plus a
|
|
11
|
+
* dispatcher that returns "no peers configured" when .mneme/mesh.json
|
|
12
|
+
* is absent. Real peer transport (HTTP / stdio bridge / WebSocket) lands
|
|
13
|
+
* in v1.19. The SHAPE of the API is locked now so AI agents can start
|
|
14
|
+
* coding against it.
|
|
15
|
+
*
|
|
16
|
+
* Privacy model:
|
|
17
|
+
* • Federated queries carry NO source code or secrets — only metadata
|
|
18
|
+
* (tool name, query string, optional fingerprint) goes over the wire.
|
|
19
|
+
* • Each peer responds with its OWN data.* shape; aggregator merges
|
|
20
|
+
* by relevance, never re-shapes.
|
|
21
|
+
* • Peer auth is HMAC-shared-secret (configured per peer in mesh.json);
|
|
22
|
+
* unsigned responses are dropped.
|
|
23
|
+
*
|
|
24
|
+
* Use cases:
|
|
25
|
+
* • "Who in our company has touched code similar to this?" — cross-repo
|
|
26
|
+
* expertise discovery without leaking source.
|
|
27
|
+
* • "Has any sister repo seen this CVE before?" — security broadcast.
|
|
28
|
+
* • "Onboard a new engineer: which other repos teach this concept?"
|
|
29
|
+
*/
|
|
30
|
+
import type { MnemeTool } from "./_types.js";
|
|
31
|
+
interface MeshPeer {
|
|
32
|
+
/** Peer label — free text. */
|
|
33
|
+
name: string;
|
|
34
|
+
/** Reachable address — http(s) URL, file:// path to a stdio binary, etc. */
|
|
35
|
+
url: string;
|
|
36
|
+
/** Optional shared secret for HMAC-signed responses (not yet enforced). */
|
|
37
|
+
hmacSecret?: string;
|
|
38
|
+
/** Optional human-readable note about which repo this peer represents. */
|
|
39
|
+
note?: string;
|
|
40
|
+
}
|
|
41
|
+
interface MeshConfig {
|
|
42
|
+
schemaVersion: 1;
|
|
43
|
+
peers: MeshPeer[];
|
|
44
|
+
}
|
|
45
|
+
export declare function readMeshConfig(repoRoot: string): MeshConfig | null;
|
|
46
|
+
export declare function writeMeshConfig(repoRoot: string, cfg: MeshConfig): void;
|
|
47
|
+
export declare const meshPeersTool: MnemeTool;
|
|
48
|
+
export declare const meshFederateTool: MnemeTool;
|
|
49
|
+
export declare const meshTools: MnemeTool[];
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=_mesh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_mesh.d.ts","sourceRoot":"","sources":["../../src/tools/_mesh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,UAAU,QAAQ;IAChB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,GAAG,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,UAAU;IAClB,aAAa,EAAE,CAAC,CAAC;IACjB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAQlE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,CAIvE;AAED,eAAO,MAAM,aAAa,EAAE,SAgD3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,SAqF9B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,SAAS,EAAsC,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Mesh (v1.18.0 — black sheep #bonus)
|
|
3
|
+
*
|
|
4
|
+
* Multiple Mneme instances (across teams / repos) federate. Query goes
|
|
5
|
+
* out, each peer returns local results, the originator dedupes + ranks.
|
|
6
|
+
*
|
|
7
|
+
* • mneme.mesh.peers — list configured peers
|
|
8
|
+
* • mneme.mesh.federate(query) — broadcast a query, aggregate responses
|
|
9
|
+
*
|
|
10
|
+
* v1.18.0 ships the SCAFFOLDING — config-driven peer registry plus a
|
|
11
|
+
* dispatcher that returns "no peers configured" when .mneme/mesh.json
|
|
12
|
+
* is absent. Real peer transport (HTTP / stdio bridge / WebSocket) lands
|
|
13
|
+
* in v1.19. The SHAPE of the API is locked now so AI agents can start
|
|
14
|
+
* coding against it.
|
|
15
|
+
*
|
|
16
|
+
* Privacy model:
|
|
17
|
+
* • Federated queries carry NO source code or secrets — only metadata
|
|
18
|
+
* (tool name, query string, optional fingerprint) goes over the wire.
|
|
19
|
+
* • Each peer responds with its OWN data.* shape; aggregator merges
|
|
20
|
+
* by relevance, never re-shapes.
|
|
21
|
+
* • Peer auth is HMAC-shared-secret (configured per peer in mesh.json);
|
|
22
|
+
* unsigned responses are dropped.
|
|
23
|
+
*
|
|
24
|
+
* Use cases:
|
|
25
|
+
* • "Who in our company has touched code similar to this?" — cross-repo
|
|
26
|
+
* expertise discovery without leaking source.
|
|
27
|
+
* • "Has any sister repo seen this CVE before?" — security broadcast.
|
|
28
|
+
* • "Onboard a new engineer: which other repos teach this concept?"
|
|
29
|
+
*/
|
|
30
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
31
|
+
import { join } from "node:path";
|
|
32
|
+
const MESH_FILE = ".mneme/mesh.json";
|
|
33
|
+
export function readMeshConfig(repoRoot) {
|
|
34
|
+
const path = join(repoRoot, MESH_FILE);
|
|
35
|
+
if (!existsSync(path))
|
|
36
|
+
return null;
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function writeMeshConfig(repoRoot, cfg) {
|
|
45
|
+
const dir = join(repoRoot, ".mneme");
|
|
46
|
+
if (!existsSync(dir))
|
|
47
|
+
mkdirSync(dir, { recursive: true });
|
|
48
|
+
writeFileSync(join(repoRoot, MESH_FILE), JSON.stringify(cfg, null, 2), "utf8");
|
|
49
|
+
}
|
|
50
|
+
export const meshPeersTool = {
|
|
51
|
+
name: "mneme.mesh.peers",
|
|
52
|
+
category: "meta",
|
|
53
|
+
description: "List every peer Mneme instance configured for federation in " +
|
|
54
|
+
"`.mneme/mesh.json`. Use WHEN you want to know which other repos / teams " +
|
|
55
|
+
"this Mneme instance can broadcast queries to. Returns an empty list when " +
|
|
56
|
+
"mesh.json is absent — that means peer transport is not enabled in this repo.",
|
|
57
|
+
whenToUse: "You want to enumerate the federation peers configured for this repo.",
|
|
58
|
+
triggers: ["mesh peers", "mneme federation list", "federation status"],
|
|
59
|
+
inputSchema: { type: "object", properties: {} },
|
|
60
|
+
outputSchema: {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
configured: { type: "boolean" },
|
|
64
|
+
peers: { type: "array", items: { type: "object" } },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
examples: [
|
|
68
|
+
{
|
|
69
|
+
userQuery: "What Mneme instances am I federated with?",
|
|
70
|
+
expectedOutput: "Returns { configured: true|false, peers: [{ name, url, note }] }. Empty when mesh.json is absent.",
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
pitfalls: [
|
|
74
|
+
"Returns the configuration AS WRITTEN — does not check liveness. A peer URL may be unreachable.",
|
|
75
|
+
"v1.18.0 ships the API surface; actual peer transport lands in v1.19.",
|
|
76
|
+
],
|
|
77
|
+
composeWith: ["mneme.mesh.federate"],
|
|
78
|
+
handler: async (rt) => {
|
|
79
|
+
const cfg = readMeshConfig(rt.meta.rootPath);
|
|
80
|
+
if (!cfg) {
|
|
81
|
+
return {
|
|
82
|
+
data: { configured: false, peers: [] },
|
|
83
|
+
wisdom: "No mesh.json — federation is not enabled in this repo. Create .mneme/mesh.json with a peers array to enable.",
|
|
84
|
+
confidence: { level: "high" },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
data: {
|
|
89
|
+
configured: true,
|
|
90
|
+
peers: cfg.peers.map((p) => ({ name: p.name, url: p.url, note: p.note })),
|
|
91
|
+
},
|
|
92
|
+
wisdom: `${cfg.peers.length} peer${cfg.peers.length === 1 ? "" : "s"} configured for federation.`,
|
|
93
|
+
confidence: { level: "high" },
|
|
94
|
+
followUp: cfg.peers.length > 0 ? ["mneme.mesh.federate"] : [],
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
export const meshFederateTool = {
|
|
99
|
+
name: "mneme.mesh.federate",
|
|
100
|
+
category: "meta",
|
|
101
|
+
description: "Broadcast a query to every configured Mneme peer + aggregate the responses. " +
|
|
102
|
+
"Privacy: the query string + tool-name go over the wire; source code does NOT. " +
|
|
103
|
+
"Each peer's data.* response is preserved (no re-shaping); aggregator merges " +
|
|
104
|
+
"by relevance score. Use WHEN you want cross-repo expertise discovery, " +
|
|
105
|
+
"security broadcasts (\"has any sister repo seen this CVE?\"), or onboarding " +
|
|
106
|
+
"rehearsals across multiple codebases. v1.18.0: SCAFFOLDING ONLY — returns " +
|
|
107
|
+
"'no peer transport' until v1.19 ships the actual HTTP / stdio bridge.",
|
|
108
|
+
whenToUse: "You want to broadcast a tool query to every configured Mneme peer + aggregate responses.",
|
|
109
|
+
triggers: ["federate this query", "ask all peers", "cross-repo search"],
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
tool: { type: "string", description: "Tool name to broadcast (e.g. 'mneme.memory.ask')." },
|
|
114
|
+
args: { description: "Arguments forwarded to each peer's tool call." },
|
|
115
|
+
},
|
|
116
|
+
required: ["tool", "args"],
|
|
117
|
+
},
|
|
118
|
+
outputSchema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
total: { type: "number", description: "Peers contacted." },
|
|
122
|
+
responses: { type: "array", items: { type: "object" } },
|
|
123
|
+
aggregated: { type: "object" },
|
|
124
|
+
transportReady: { type: "boolean", description: "false in v1.18.0 — true once v1.19 ships transport." },
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
examples: [
|
|
128
|
+
{
|
|
129
|
+
userQuery: "Ask every peer Mneme: 'has anyone seen a CVE matching this commit?'",
|
|
130
|
+
args: { tool: "mneme.memory.ask", args: { question: "any commits referencing CVE-2024-XXXXX?" } },
|
|
131
|
+
expectedOutput: "v1.18.0: returns transportReady=false + scaffolding response. v1.19+: per-peer responses + aggregated answer.",
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
pitfalls: [
|
|
135
|
+
"v1.18.0 — peer transport NOT YET WIRED. Returns scaffolding response so AI agents can code against the API surface.",
|
|
136
|
+
"Once transport ships (v1.19): peers are unauthenticated unless mesh.json provides an hmacSecret per peer. Unsigned responses get dropped.",
|
|
137
|
+
"Federated queries are slower than local — 1× round-trip per peer. Use sparingly.",
|
|
138
|
+
],
|
|
139
|
+
composeWith: ["mneme.mesh.peers", "mneme.help"],
|
|
140
|
+
handler: async (rt, args) => {
|
|
141
|
+
const cfg = readMeshConfig(rt.meta.rootPath);
|
|
142
|
+
const tool = String(args["tool"] ?? "");
|
|
143
|
+
if (!tool) {
|
|
144
|
+
return {
|
|
145
|
+
data: { error: "missing required argument: tool" },
|
|
146
|
+
wisdom: "Pass the tool name to federate (e.g. 'mneme.memory.ask').",
|
|
147
|
+
confidence: { level: "high" },
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (!cfg || cfg.peers.length === 0) {
|
|
151
|
+
return {
|
|
152
|
+
data: {
|
|
153
|
+
total: 0,
|
|
154
|
+
responses: [],
|
|
155
|
+
aggregated: { note: "no peers configured" },
|
|
156
|
+
transportReady: false,
|
|
157
|
+
},
|
|
158
|
+
wisdom: "No peers configured. Create .mneme/mesh.json with peer entries to enable federation. v1.18.0 ships the API surface; actual transport lands in v1.19.",
|
|
159
|
+
confidence: { level: "high" },
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
// v1.18.0 scaffolding: return per-peer 'not yet implemented' shape.
|
|
163
|
+
const responses = cfg.peers.map((p) => ({
|
|
164
|
+
peer: p.name,
|
|
165
|
+
url: p.url,
|
|
166
|
+
status: "transport-pending",
|
|
167
|
+
detail: "v1.18.0 scaffolding — actual peer transport ships in v1.19.",
|
|
168
|
+
}));
|
|
169
|
+
return {
|
|
170
|
+
data: {
|
|
171
|
+
total: cfg.peers.length,
|
|
172
|
+
responses,
|
|
173
|
+
aggregated: { note: "scaffolding response — transport not yet wired" },
|
|
174
|
+
transportReady: false,
|
|
175
|
+
},
|
|
176
|
+
wisdom: `Scaffolding response: ${cfg.peers.length} peer${cfg.peers.length === 1 ? "" : "s"} would be contacted, but v1.18.0 ships only the API. Transport in v1.19.`,
|
|
177
|
+
confidence: { level: "low", notes: "Scaffolding only — real responses arrive in v1.19." },
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
export const meshTools = [meshPeersTool, meshFederateTool];
|
|
182
|
+
//# sourceMappingURL=_mesh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_mesh.js","sourceRoot":"","sources":["../../src/tools/_mesh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAA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MAAM;gBACvB,SAAS;gBACT,UAAU,EAAE,EAAE,IAAI,EAAE,gDAAgD,EAAE;gBACtE,cAAc,EAAE,KAAK;aACtB;YACD,MAAM,EAAE,yBAAyB,GAAG,CAAC,KAAK,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,0EAA0E;YACpK,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,oDAAoD,EAAE;SAC1F,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAgB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_registry.d.ts","sourceRoot":"","sources":["../../src/tools/_registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"_registry.d.ts","sourceRoot":"","sources":["../../src/tools/_registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA4B3D;sEACsE;AACtE,wBAAgB,aAAa,IAAI,SAAS,EAAE,CA6B3C;AAED,mDAAmD;AACnD,wBAAgB,YAAY,IAAI,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CASrD;AAED,uEAAuE;AACvE,wBAAgB,eAAe,IAAI,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,CAAC,CAOhE"}
|
package/dist/tools/_registry.js
CHANGED
|
@@ -22,6 +22,14 @@ import { constitutionTool } from "./_constitution_tool.js";
|
|
|
22
22
|
import { verifyClaimsTool } from "./_verify_claims_tool.js";
|
|
23
23
|
import { dnaSearchTool } from "./_dna_tool.js";
|
|
24
24
|
import { genomeTools } from "./_genome_tools.js";
|
|
25
|
+
import { toolMetaTools } from "./_tool_meta.js";
|
|
26
|
+
import { adversaryTool } from "./_court.js";
|
|
27
|
+
import { confessTool } from "./_confess.js";
|
|
28
|
+
import { replayTools } from "./_replay.js";
|
|
29
|
+
import { timeTravelTools } from "./_timetravel.js";
|
|
30
|
+
import { genomeMarketplaceTools } from "./_genome_marketplace.js";
|
|
31
|
+
import { aletheiaTools, honeypotTools } from "./_aletheia.js";
|
|
32
|
+
import { meshTools } from "./_mesh.js";
|
|
25
33
|
/** All Mneme tools, in display order. The capabilities syllabus comes first
|
|
26
34
|
* so AI clients that read tool lists top-down see it immediately. */
|
|
27
35
|
export function buildAllTools() {
|
|
@@ -33,6 +41,15 @@ export function buildAllTools() {
|
|
|
33
41
|
constitutionTool,
|
|
34
42
|
dnaSearchTool,
|
|
35
43
|
...genomeTools,
|
|
44
|
+
...toolMetaTools,
|
|
45
|
+
adversaryTool,
|
|
46
|
+
confessTool,
|
|
47
|
+
...replayTools,
|
|
48
|
+
...timeTravelTools,
|
|
49
|
+
...genomeMarketplaceTools,
|
|
50
|
+
...aletheiaTools,
|
|
51
|
+
...honeypotTools,
|
|
52
|
+
...meshTools,
|
|
36
53
|
smartDoTool,
|
|
37
54
|
...memoryTools,
|
|
38
55
|
...peopleTools,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_registry.js","sourceRoot":"","sources":["../../src/tools/_registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EA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G,GAAG,IAAI,GAAG,EAAqB,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE,EAAE,CAAC;QAChC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,GAAG,IAAI,GAAG,EAA6B,CAAC;IACjD,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE,EAAE,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAClD,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replay Traces (v1.18.0 — black sheep #7)
|
|
3
|
+
*
|
|
4
|
+
* Every MCP tool call is recorded as one HMAC-chained line in
|
|
5
|
+
* `.mneme/replay.jsonl`. Each entry's `prevHash` references the previous
|
|
6
|
+
* line, so any tampering breaks the chain at exactly one point — Merkle
|
|
7
|
+
* trail without a tree.
|
|
8
|
+
*
|
|
9
|
+
* • mneme.replay.dump — return the whole session trace as JSON
|
|
10
|
+
* • mneme.replay.fingerprint — return the Merkle root + chain integrity
|
|
11
|
+
*
|
|
12
|
+
* Use cases: SOC2 / EU AI Act audit evidence, deterministic-session proofs,
|
|
13
|
+
* post-mortem reconstruction. The fingerprint is what you publish; the
|
|
14
|
+
* dump is what you'd hand an auditor.
|
|
15
|
+
*
|
|
16
|
+
* The recorder lives in this file but is invoked from index.ts on every
|
|
17
|
+
* call. Recording is best-effort — any I/O error is swallowed so a
|
|
18
|
+
* corrupted disk can never block tool dispatch.
|
|
19
|
+
*/
|
|
20
|
+
import type { MnemeTool } from "./_types.js";
|
|
21
|
+
interface ReplayEntry {
|
|
22
|
+
/** ISO-8601 timestamp. */
|
|
23
|
+
ts: string;
|
|
24
|
+
/** Tool name invoked. */
|
|
25
|
+
tool: string;
|
|
26
|
+
/** SHA-256 of the JSON-stringified arguments (full args may contain user data). */
|
|
27
|
+
argHash: string;
|
|
28
|
+
/** SHA-256 of the JSON-stringified response (full response may be huge). */
|
|
29
|
+
responseHash: string;
|
|
30
|
+
/** Verdict if the tool returned one (PASS/WARN/FAIL/etc.) — convenience field. */
|
|
31
|
+
verdict?: string;
|
|
32
|
+
/** Hash of the previous line + this line's payload — chain link. */
|
|
33
|
+
prevHash: string;
|
|
34
|
+
/** This entry's hash (HMAC of payload). Becomes prevHash for the next entry. */
|
|
35
|
+
hash: string;
|
|
36
|
+
}
|
|
37
|
+
/** Append a single tool-call record. Best-effort — never throws. */
|
|
38
|
+
export declare function recordReplay(repoRoot: string, tool: string, args: unknown, response: unknown): void;
|
|
39
|
+
export interface ReplayChainStatus {
|
|
40
|
+
total: number;
|
|
41
|
+
intact: boolean;
|
|
42
|
+
brokenAt?: number;
|
|
43
|
+
/** Merkle root = HMAC(secret, lastHash). Stable identifier for the trace. */
|
|
44
|
+
root: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function verifyChain(repoRoot: string): ReplayChainStatus;
|
|
47
|
+
export declare function readReplay(repoRoot: string, limit?: number): ReplayEntry[];
|
|
48
|
+
export declare const replayDumpTool: MnemeTool;
|
|
49
|
+
export declare const replayFingerprintTool: MnemeTool;
|
|
50
|
+
export declare const replayTools: MnemeTool[];
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=_replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_replay.d.ts","sourceRoot":"","sources":["../../src/tools/_replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C,UAAU,WAAW;IACnB,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,YAAY,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;CACd;AAyCD,oEAAoE;AACpE,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,OAAO,GAChB,IAAI,CAgBN;AAYD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CA8B/D;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAO,GAAG,WAAW,EAAE,CAgBxE;AAED,eAAO,MAAM,cAAc,EAAE,SA4D5B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,SA+CnC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,SAAS,EAA4C,CAAC"}
|