@mosadd/mcp 3.0.0-alpha.7 → 3.0.1
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/CHANGELOG.md +415 -0
- package/LICENSE +21 -201
- package/README.md +79 -40
- package/dist/bin/mcp.js +132 -8
- package/dist/chunk-J2S44U5R.js +4258 -0
- package/dist/index.d.ts +112 -8
- package/dist/index.js +3 -1
- package/package.json +19 -16
- package/src/__tests__/blob-upload.test.ts +93 -0
- package/src/__tests__/channel-e2ee.test.ts +62 -0
- package/src/__tests__/cli.test.ts +47 -0
- package/src/__tests__/fleet-plaintext.test.ts +243 -0
- package/src/__tests__/golden-path.test.ts +4 -2
- package/src/__tests__/integration.test.ts +50 -11
- package/src/__tests__/knowledge-ingest.test.ts +114 -0
- package/src/__tests__/label-room-owner.test.ts +22 -0
- package/src/__tests__/mdm-e2ee.test.ts +36 -2
- package/src/__tests__/mdm-mcp-readable.test.ts +390 -0
- package/src/__tests__/mirc-invite.test.ts +112 -0
- package/src/__tests__/mirc-voice.test.ts +82 -0
- package/src/__tests__/mrag-search-answer.test.ts +42 -0
- package/src/__tests__/mrag-search-diagnostics.test.ts +78 -0
- package/src/__tests__/no-dead-host.test.ts +37 -0
- package/src/__tests__/presence.test.ts +199 -0
- package/src/__tests__/server.test.ts +11 -7
- package/src/__tests__/serverJsonVersion.test.ts +45 -0
- package/src/__tests__/tool-count-consistency.test.ts +259 -0
- package/src/__tests__/voice-fields.test.ts +24 -0
- package/src/bin/mcp.ts +71 -6
- package/src/cli.ts +100 -0
- package/src/crypto/channel-e2ee.ts +288 -0
- package/src/crypto/mdm-session.ts +479 -40
- package/src/index.ts +2 -2
- package/src/providers/blob-upload.ts +162 -0
- package/src/providers/supabase-dm.ts +102 -7
- package/src/providers/supabase-voice.ts +13 -1
- package/src/providers/supabase.ts +121 -10
- package/src/server.ts +102 -12
- package/src/tools/__tests__/ragDeleteFoldsSourceId.test.ts +67 -0
- package/src/tools/actions.ts +166 -0
- package/src/tools/attachments.ts +276 -0
- package/src/tools/capabilities.ts +2 -0
- package/src/tools/channel-payload.ts +69 -0
- package/src/tools/embed.ts +110 -0
- package/src/tools/index.ts +136 -6
- package/src/tools/knowledge-graph.ts +186 -0
- package/src/tools/knowledge.ts +205 -12
- package/src/tools/mail-agentbox.ts +155 -0
- package/src/tools/mail-aliases.ts +25 -0
- package/src/tools/mail-provenance.ts +137 -0
- package/src/tools/mail.ts +214 -60
- package/src/tools/mdm-as-agent.ts +137 -0
- package/src/tools/mdm-voice.ts +17 -3
- package/src/tools/mdm.ts +306 -58
- package/src/tools/mirc-edge.ts +12 -6
- package/src/tools/mirc-members.ts +130 -20
- package/src/tools/mirc-messages.ts +109 -40
- package/src/tools/mirc.ts +149 -11
- package/src/tools/mroom-messages.ts +5 -13
- package/src/tools/mtalk.ts +11 -1
- package/src/tools/murl.ts +314 -0
- package/src/tools/presence.ts +442 -0
- package/src/tools/ptt-ingest.ts +99 -0
- package/src/tools/threat.ts +123 -0
- package/src/tools/voice-format.ts +66 -0
- package/src/types.ts +36 -0
- package/src/version.ts +8 -0
- package/dist/chunk-EFTB743G.js +0 -1924
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mRAG_search diagnostics — what rag-query reports about HOW it found the sources (partial / keyword fallback / per-stage timing)
|
|
3
|
+
* must reach the agent. Before this the handler kept only answer/sources/chunks_found, so a keyword-only fallback after a vector
|
|
4
|
+
* timeout (2026-11-22 incident: 0 sources, "przekroczyło limit czasu") looked identical to an empty memory and no stage time was visible.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
7
|
+
|
|
8
|
+
let backend: Record<string, unknown> = {};
|
|
9
|
+
|
|
10
|
+
vi.mock("../providers/supabase.js", () => ({
|
|
11
|
+
readSupabaseEnv: () => ({ url: "https://example.supabase.co", anonKey: "anon", userJwt: "jwt" }),
|
|
12
|
+
invokeFunction: () => Promise.resolve(backend),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
const { knowledgeTools } = await import("../tools/knowledge.js");
|
|
16
|
+
const search = knowledgeTools.find((t) => t.name === "mRAG_search")!;
|
|
17
|
+
const ctx = { log: () => {} } as never;
|
|
18
|
+
|
|
19
|
+
const source = { source_type: "file", source_id: "u", thread_id: null, similarity: 0, snippet: "punkt startu", created_at: "2026-11-21T00:00:00Z" };
|
|
20
|
+
|
|
21
|
+
describe("mRAG_search diagnostics", () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
backend = {};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("keyword fallback after a vector timeout: partial, reason, mode and per-stage timing reach the agent", async () => {
|
|
27
|
+
backend = {
|
|
28
|
+
answer: "[mRAG · wynik częściowy] Etap wektorowy nie zdążył w limicie (3500 ms) — pokazuję wyszukiwanie po słowach: 1 źr.",
|
|
29
|
+
sources: [source],
|
|
30
|
+
chunks_found: 1,
|
|
31
|
+
partial: true,
|
|
32
|
+
partial_reason: "search_timeout",
|
|
33
|
+
search_mode: "keyword",
|
|
34
|
+
timing: { embed_ms: 21, wektor_ms: 3495, slowa_ms: 40, total_ms: 3517 },
|
|
35
|
+
stages: { embed_ms: 21, wektor_ms: 3495, slowa_ms: 40, rerank_ms: null, synteza_ms: null, total_ms: 3517, status: { embed: "ok", wektor: "limit", slowa: "ok" } },
|
|
36
|
+
etapy_tekst: "must not leak into the tool result",
|
|
37
|
+
fresh_chunks: 0,
|
|
38
|
+
};
|
|
39
|
+
const r = (await search.handler({ query: "marocain-punkt-startu" }, ctx)) as Record<string, unknown>;
|
|
40
|
+
expect(r.partial).toBe(true);
|
|
41
|
+
expect(r.partial_reason).toBe("search_timeout");
|
|
42
|
+
expect(r.search_mode).toBe("keyword");
|
|
43
|
+
expect((r.timing as Record<string, number>).wektor_ms).toBe(3495);
|
|
44
|
+
expect(((r.stages as { status: Record<string, string> }).status).wektor).toBe("limit");
|
|
45
|
+
expect(r.chunks_found).toBe(1);
|
|
46
|
+
expect(r.answer).toMatch(/^\[mRAG/);
|
|
47
|
+
// only the documented fields are forwarded, not whatever else the backend happens to send
|
|
48
|
+
expect(Object.keys(r).sort()).toEqual(["answer", "chunks_found", "partial", "partial_reason", "search_mode", "sources", "stages", "timing"]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("a named empty synthesis (degraded) is forwarded together with the sources", async () => {
|
|
52
|
+
backend = { answer: "[mRAG · bez syntezy] Model nie zwrócił odpowiedzi.", sources: [source], chunks_found: 1, degraded: "ai_unavailable", search_mode: "hybrid" };
|
|
53
|
+
const r = (await search.handler({ query: "x", answer: true }, ctx)) as Record<string, unknown>;
|
|
54
|
+
expect(r.degraded).toBe("ai_unavailable");
|
|
55
|
+
expect(r.sources).toHaveLength(1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("an older backend (no diagnostics) yields exactly the old three-field result", async () => {
|
|
59
|
+
backend = { answer: "", sources: [source], chunks_found: 1 };
|
|
60
|
+
const r = (await search.handler({ query: "x" }, ctx)) as Record<string, unknown>;
|
|
61
|
+
expect(Object.keys(r).sort()).toEqual(["answer", "chunks_found", "sources"]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("null diagnostics are dropped, partial:false is kept (it is information)", async () => {
|
|
65
|
+
backend = { answer: "", sources: [], chunks_found: 0, partial: false, degraded: null, timing: null };
|
|
66
|
+
const r = (await search.handler({ query: "x" }, ctx)) as Record<string, unknown>;
|
|
67
|
+
expect(r.partial).toBe(false);
|
|
68
|
+
expect("degraded" in r).toBe(false);
|
|
69
|
+
expect("timing" in r).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("the tool description promises exactly what the handler now delivers", () => {
|
|
73
|
+
expect(search.description).toMatch(/partial:true/);
|
|
74
|
+
expect(search.description).toMatch(/partial_reason/);
|
|
75
|
+
expect(search.description).toMatch(/keyword fallback/);
|
|
76
|
+
expect(search.description).toMatch(/timing/);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The old cloud (`rooffhgbxafyjcwmwpsy.supabase.co`) is dead; the live backend is `https://api.mosadd.com`.
|
|
3
|
+
* A published package that defaults to the dead host breaks `MOSADD_API_KEY` login (hub-key-exchange never answers),
|
|
4
|
+
* so no source file may carry the old host as a URL. Comments that merely name the project id are fine.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect } from "vitest";
|
|
7
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
8
|
+
import { dirname, join, resolve } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
|
|
11
|
+
const SRC = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
12
|
+
const DEAD = /https?:\/\/rooffhgbxafyjcwmwpsy\.supabase\.co/i;
|
|
13
|
+
|
|
14
|
+
function walk(dir: string): string[] {
|
|
15
|
+
return readdirSync(dir).flatMap((n) => {
|
|
16
|
+
const p = join(dir, n);
|
|
17
|
+
if (n === "__tests__" || n === "node_modules") return [];
|
|
18
|
+
return statSync(p).isDirectory() ? walk(p) : /\.(ts|tsx|mjs|js)$/.test(n) ? [p] : [];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
describe("no dead backend host in the package source", () => {
|
|
23
|
+
it("no source file carries the old supabase host as a URL", () => {
|
|
24
|
+
const hits = walk(SRC).filter((f) => DEAD.test(readFileSync(f, "utf8")));
|
|
25
|
+
expect(hits, `dead host found in: ${hits.join(", ")}`).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("the default hub-key-exchange endpoint is api.mosadd.com", () => {
|
|
29
|
+
const src = readFileSync(join(SRC, "bin", "mcp.ts"), "utf8");
|
|
30
|
+
expect(src).toMatch(/DEFAULT_EXCHANGE\s*=\s*"https:\/\/api\.mosadd\.com\/functions\/v1\/hub-key-exchange"/);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("the gate fires: the dead host would be caught", () => {
|
|
34
|
+
expect(DEAD.test('const X = "https://rooffhgbxafyjcwmwpsy.supabase.co/functions/v1/hub-key-exchange";')).toBe(true);
|
|
35
|
+
expect(DEAD.test("// project rooffhgbxafyjcwmwpsy, 16.09")).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* comms_session_attach — the liveness contract.
|
|
3
|
+
*
|
|
4
|
+
* This tool decides WHO answers the owner: a live agent session, or the 24/7 cloud stand-in.
|
|
5
|
+
* Both answering, or the stand-in answering in a live session's name, is the exact failure that
|
|
6
|
+
* cost the founder his trust in the agent (see the file header in tools/presence.ts). So the
|
|
7
|
+
* things pinned here are the ones that would silently re-open it:
|
|
8
|
+
*
|
|
9
|
+
* 1. attaching writes the liveness row the stand-in reads, under the CALLER'S identity;
|
|
10
|
+
* 2. the hold renews itself on a timer — the model is not asked to remember a clock;
|
|
11
|
+
* 3. the timer is unref()ed, so a held line can never keep a dead session's process alive;
|
|
12
|
+
* 4. re-attaching replaces the beat instead of stacking a second one;
|
|
13
|
+
* 5. release DELETES the row (no backdated timestamp lying in a table other code reads).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
17
|
+
|
|
18
|
+
const IDENTITY_ID = "b228b6ae-dda6-4823-9882-40ea91ed1530";
|
|
19
|
+
const USER_ID = "b1b6c60a-f5c5-47bd-8772-9e4e387994ad";
|
|
20
|
+
const TEST_SESSION = "test-host:11111111-2222-3333-4444-555555555555";
|
|
21
|
+
const AGENT_ID = "0489d4c6-8727-442f-bf83-68747a469492";
|
|
22
|
+
|
|
23
|
+
/** Calls recorded by the fake Supabase client, so assertions read like the wire traffic. */
|
|
24
|
+
const calls = {
|
|
25
|
+
upserts: [] as Record<string, unknown>[],
|
|
26
|
+
deletes: [] as string[],
|
|
27
|
+
rpcs: [] as { name: string; args: Record<string, unknown> }[],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Minimal query-builder stand-in: every method returns the builder, `maybeSingle()` resolves the
|
|
32
|
+
* identity row, and the builder is thenable so `await delete().eq()` works like PostgREST's.
|
|
33
|
+
*/
|
|
34
|
+
function makeBuilder(table: string) {
|
|
35
|
+
const builder: Record<string, unknown> = {};
|
|
36
|
+
let pendingDelete = false;
|
|
37
|
+
const self = () => builder;
|
|
38
|
+
Object.assign(builder, {
|
|
39
|
+
select: self,
|
|
40
|
+
is: self,
|
|
41
|
+
or: self,
|
|
42
|
+
upsert: (row: Record<string, unknown>) => {
|
|
43
|
+
calls.upserts.push({ table, ...row });
|
|
44
|
+
return Promise.resolve({ error: null });
|
|
45
|
+
},
|
|
46
|
+
delete: () => {
|
|
47
|
+
pendingDelete = true;
|
|
48
|
+
return builder;
|
|
49
|
+
},
|
|
50
|
+
// ⛔ KASOWANIE MA TERAZ DWA WARUNKI: (konto, sesja). Atrapa musi dać się złożyć w łańcuch
|
|
51
|
+
// `.delete().eq(user).eq(session)`, więc zwracany obiekt jest JEDNOCZEŚNIE budowniczym i
|
|
52
|
+
// obietnicą — inaczej test przechodziłby tylko dlatego, że atrapa nie umie tego, co produkcja.
|
|
53
|
+
eq: (_col: string, val: string) => {
|
|
54
|
+
if (pendingDelete) {
|
|
55
|
+
calls.deletes.push(val);
|
|
56
|
+
return Object.assign(
|
|
57
|
+
{ eq: (_c2: string, v2: string) => { calls.deletes.push(v2); return Promise.resolve({ error: null }); } },
|
|
58
|
+
{ then: (res: (v: { error: null }) => unknown) => Promise.resolve({ error: null }).then(res) },
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return builder;
|
|
62
|
+
},
|
|
63
|
+
// resolveOwnedAgentLine path: .or(...).limit(2) → the caller's ONE owned agent.
|
|
64
|
+
limit: () =>
|
|
65
|
+
Promise.resolve({
|
|
66
|
+
data: [{ id: AGENT_ID, m0ssad_email: "agent-one@mosadd.com", display_name: "AGENT ONE" }],
|
|
67
|
+
error: null,
|
|
68
|
+
}),
|
|
69
|
+
maybeSingle: () => Promise.resolve({ data: { id: IDENTITY_ID, display_name: "mosADD CTO" }, error: null }),
|
|
70
|
+
});
|
|
71
|
+
return builder;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
vi.mock("../providers/supabase.js", () => ({
|
|
75
|
+
readSupabaseEnv: () => ({ url: "https://example.supabase.co", anonKey: "anon", userJwt: "jwt" }),
|
|
76
|
+
// Stała tożsamość sesji — deklaracja linii jest odtąd kluczowana po (konto, sesja), żeby
|
|
77
|
+
// generałowie wpięci tym samym kluczem nie odbierali sobie linii nawzajem.
|
|
78
|
+
sessionId: () => TEST_SESSION,
|
|
79
|
+
getSupabase: () => ({
|
|
80
|
+
auth: { getUser: () => Promise.resolve({ data: { user: { id: USER_ID } }, error: null }) },
|
|
81
|
+
from: (table: string) => makeBuilder(table),
|
|
82
|
+
// release/as_agent path: presence.ts woła mosadd_gateway_binding_release/claim przez rpc —
|
|
83
|
+
// atrapa nagrywa wywołania, żeby asercje czytały się jak prawdziwy wire.
|
|
84
|
+
rpc: (name: string, args: Record<string, unknown>) => {
|
|
85
|
+
calls.rpcs.push({ name, args });
|
|
86
|
+
return Promise.resolve({ error: null, data: { took_over: false, previous_session_id: null } });
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
const ctx = { log: () => {} } as never;
|
|
92
|
+
|
|
93
|
+
/** Import after the mock is registered, so the module under test picks it up. */
|
|
94
|
+
const { presenceTools, __clearAttachmentsForTest } = await import("../tools/presence.js");
|
|
95
|
+
const attach = presenceTools[0];
|
|
96
|
+
|
|
97
|
+
async function call(input: Record<string, unknown>) {
|
|
98
|
+
return (await attach.handler(input, ctx)) as Record<string, unknown>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
describe("comms_session_attach", () => {
|
|
102
|
+
beforeEach(() => {
|
|
103
|
+
calls.upserts = [];
|
|
104
|
+
calls.deletes = [];
|
|
105
|
+
vi.useFakeTimers();
|
|
106
|
+
});
|
|
107
|
+
afterEach(() => {
|
|
108
|
+
__clearAttachmentsForTest();
|
|
109
|
+
vi.useRealTimers();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("is registered as a network tool under the comms_ capability group", () => {
|
|
113
|
+
expect(attach.name).toBe("comms_session_attach");
|
|
114
|
+
expect(attach.requires).toBe("network");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("claims the line for the CALLER'S identity, with a label the owner can read", async () => {
|
|
118
|
+
const out = await call({ label: "CTO — Claude Code" });
|
|
119
|
+
expect(out.attached).toBe(true);
|
|
120
|
+
expect(out.identity_id).toBe(IDENTITY_ID);
|
|
121
|
+
expect(calls.upserts).toHaveLength(1);
|
|
122
|
+
expect(calls.upserts[0]).toMatchObject({
|
|
123
|
+
table: "agent_bridge_heartbeat",
|
|
124
|
+
identity_id: IDENTITY_ID,
|
|
125
|
+
host: "CTO — Claude Code",
|
|
126
|
+
mode: "mcp-session",
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("renews the hold on its own — the model is never asked to keep time", async () => {
|
|
131
|
+
await call({});
|
|
132
|
+
expect(calls.upserts).toHaveLength(1);
|
|
133
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
134
|
+
expect(calls.upserts).toHaveLength(2);
|
|
135
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
136
|
+
expect(calls.upserts).toHaveLength(3);
|
|
137
|
+
// Every beat is a fresh timestamp, not a replay of the first one.
|
|
138
|
+
expect(calls.upserts[2].last_seen_at).not.toBe(calls.upserts[0].last_seen_at);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("never keeps a finished session's process alive (timer is unref'ed)", async () => {
|
|
142
|
+
const unref = vi.fn();
|
|
143
|
+
const spy = vi.spyOn(globalThis, "setInterval").mockReturnValue({ unref } as never);
|
|
144
|
+
await call({});
|
|
145
|
+
expect(unref).toHaveBeenCalledOnce();
|
|
146
|
+
spy.mockRestore();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("re-attaching replaces the beat instead of stacking a second one", async () => {
|
|
150
|
+
await call({ label: "first" });
|
|
151
|
+
await call({ label: "second" });
|
|
152
|
+
calls.upserts = [];
|
|
153
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
154
|
+
expect(calls.upserts).toHaveLength(1);
|
|
155
|
+
expect(calls.upserts[0].host).toBe("second");
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("release DELETES the row and stops beating — the stand-in resumes at once", async () => {
|
|
159
|
+
await call({});
|
|
160
|
+
const out = await call({ release: true });
|
|
161
|
+
expect(out.attached).toBe(false);
|
|
162
|
+
// Zwolnienie kasuje puls linii (po identity) i puszcza deklarację TEJ sesji RPC-em
|
|
163
|
+
// (konto ORAZ sesja po stronie SQL — nie kasujemy po samym koncie, bo to zabierało
|
|
164
|
+
// linię wszystkim innym generałom na tym samym kluczu).
|
|
165
|
+
expect(calls.deletes).toEqual([IDENTITY_ID]);
|
|
166
|
+
expect(calls.rpcs).toEqual([{ name: "mosadd_gateway_binding_release", args: { p_session_id: TEST_SESSION } }]);
|
|
167
|
+
calls.upserts = [];
|
|
168
|
+
await vi.advanceTimersByTimeAsync(180_000);
|
|
169
|
+
expect(calls.upserts).toHaveLength(0);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("as_agent declares the line: binding upsert + beat on the AGENT's identity, not the key's", async () => {
|
|
173
|
+
const out = await call({ as_agent: "agent-one@mosadd.com", label: "agent one — Cowork" });
|
|
174
|
+
expect(out.attached).toBe(true);
|
|
175
|
+
expect(out.identity_id).toBe(AGENT_ID);
|
|
176
|
+
expect((out.speaking_as as { address: string }).address).toBe("agent-one@mosadd.com");
|
|
177
|
+
// The signing declaration message-send reads — arbitrated in SQL:
|
|
178
|
+
// claimed through the RPC, not a raw upsert.
|
|
179
|
+
expect(calls.rpcs).toContainEqual({
|
|
180
|
+
name: "mosadd_gateway_binding_claim",
|
|
181
|
+
args: {
|
|
182
|
+
p_session_id: TEST_SESSION,
|
|
183
|
+
p_agent_identity_id: AGENT_ID,
|
|
184
|
+
p_agent_address: "agent-one@mosadd.com",
|
|
185
|
+
p_host: "agent one — Cowork",
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
// …and the AGENT's liveness row, so ITS cloud stand-in defers to this session.
|
|
189
|
+
expect(calls.upserts).toContainEqual(
|
|
190
|
+
expect.objectContaining({
|
|
191
|
+
table: "agent_bridge_heartbeat",
|
|
192
|
+
identity_id: AGENT_ID,
|
|
193
|
+
host: "agent one — Cowork",
|
|
194
|
+
}),
|
|
195
|
+
);
|
|
196
|
+
// The key's own line is NOT claimed — attaching as an agent must not silence the owner's lane.
|
|
197
|
+
expect(calls.upserts.some((u) => u.table === "agent_bridge_heartbeat" && u.identity_id === IDENTITY_ID)).toBe(false);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
@@ -15,19 +15,23 @@ describe("@mosadd/mcp", () => {
|
|
|
15
15
|
// mIRC (5 tools)
|
|
16
16
|
expect(names).toContain("mIRC_create");
|
|
17
17
|
expect(names).toContain("mIRC_delete");
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
expect(names).toContain("
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
expect(names).
|
|
18
|
+
// mURL (revived module) + mAYL (email 3.0, was mp0st) — threat_* re-registered
|
|
19
|
+
// (surveillance-era direction killed 2026-06-27; on-device security pillar, not an MCP tool)
|
|
20
|
+
expect(names).toContain("mURL_post");
|
|
21
|
+
expect(names).toContain("mAYL_send");
|
|
22
|
+
// mp0st_* aliases RETIRED 2026-07-15 — mAYL is the one name (mp0st is backend-internal only)
|
|
23
|
+
expect(names.some((n) => n.startsWith("mp0st_"))).toBe(false);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it("follows RFC 0001 naming — channel tools m<MODULE>_<operation>, meta tools comms_<op>", () => {
|
|
27
27
|
const channelName = /^m[A-Z][A-Z0-9_]*_[a-z][a-z0-9_]*$/;
|
|
28
|
+
const mailName = /^mp0st_[a-z][a-z0-9_]*$/; // mail module codename
|
|
28
29
|
const metaName = /^comms_[a-z][a-z0-9_]*$/; // discovery/meta namespace
|
|
30
|
+
const threatName = /^threat_[a-z][a-z0-9_]*$/; // defensive threat engine
|
|
29
31
|
for (const tool of allTools) {
|
|
30
|
-
expect(tool.name).toMatch(
|
|
32
|
+
expect(tool.name).toMatch(
|
|
33
|
+
new RegExp(`${channelName.source}|${mailName.source}|${metaName.source}|${threatName.source}`),
|
|
34
|
+
);
|
|
31
35
|
}
|
|
32
36
|
});
|
|
33
37
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* server.json MUSI ZGADZAĆ SIĘ Z package.json — inaczej oficjalny rejestr MCP rozdaje starą wersję.
|
|
3
|
+
*
|
|
4
|
+
* ⛔ POWÓD JEST ZMIERZONY, NIE TEORETYCZNY (2026-08-28). `packages/mcp/server.json` stał na
|
|
5
|
+
* `3.0.0-alpha.33`, podczas gdy pakiet był już na `3.0.0-alpha.44` — **jedenaście wersji wstecz**.
|
|
6
|
+
* `server.json` to karta, którą czyta oficjalny rejestr MCP, więc każdy, kto znalazłby mosADD tam,
|
|
7
|
+
* a nie u nas, instalowałby alpha.33: wersję sprzed poprawki modelu-widma, sprzed stabilnej
|
|
8
|
+
* tożsamości sesji i sprzed dwóch wycofanych wydań (alpha.39 zdeprecowana, alpha.42 cofnięta).
|
|
9
|
+
* Pierwsze wrażenie z produktu brałoby się z kodu, o którym my sami wiemy, że jest zepsuty.
|
|
10
|
+
*
|
|
11
|
+
* Rozjechało się dlatego, że NIC tego nie pilnowało: publikacja bumpuje `package.json`, a karta
|
|
12
|
+
* rejestru jest osobnym plikiem, którego nikt nie tyka. Klasyczne „dwie kopie prawdy" — ta sama
|
|
13
|
+
* klasa, która trzy razy przywracała model-widmo na czoło łańcucha. Opis w dokumentacji niczego
|
|
14
|
+
* nie broni; test broni przy każdym przebiegu.
|
|
15
|
+
*
|
|
16
|
+
* Sprawdzamy OBA miejsca w server.json: `version` na wierzchu i `packages[].version`.
|
|
17
|
+
*/
|
|
18
|
+
import { describe, it, expect } from "vitest";
|
|
19
|
+
import { readFileSync } from "node:fs";
|
|
20
|
+
import { dirname, join } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
|
|
23
|
+
// Zakotwiczone w import.meta.url, nigdy w cwd — pułapka build-cwd kosztowała nas już raz.
|
|
24
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
25
|
+
const PKG_DIR = join(HERE, "..", "..");
|
|
26
|
+
|
|
27
|
+
const pkg = JSON.parse(readFileSync(join(PKG_DIR, "package.json"), "utf8")) as { version: string };
|
|
28
|
+
const card = JSON.parse(readFileSync(join(PKG_DIR, "server.json"), "utf8")) as {
|
|
29
|
+
version: string;
|
|
30
|
+
packages?: Array<{ identifier?: string; version?: string }>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
describe("server.json (karta rejestru MCP)", () => {
|
|
34
|
+
it("ma tę samą wersję co package.json", () => {
|
|
35
|
+
expect(card.version, `server.json.version rozjechało się z package.json (${pkg.version}). ` +
|
|
36
|
+
"Karta rejestru rozdawałaby innym ludziom INNĄ wersję niż publikujemy.").toBe(pkg.version);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("ma tę samą wersję w bloku packages[]", () => {
|
|
40
|
+
const npmEntry = (card.packages ?? []).find((p) => p.identifier === "@mosadd/mcp");
|
|
41
|
+
expect(npmEntry, "brak wpisu @mosadd/mcp w server.json → packages[]").toBeTruthy();
|
|
42
|
+
expect(npmEntry?.version, `server.json → packages[].version rozjechało się z package.json ` +
|
|
43
|
+
`(${pkg.version}). To jest wersja, którą rejestr KAŻE ZAINSTALOWAĆ.`).toBe(pkg.version);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { TOOL_COUNT, allTools } from "../tools/index.js";
|
|
6
|
+
|
|
7
|
+
// ── Anti-drift gate ──────────────────────────────────────────────────────────
|
|
8
|
+
// The advertised tool count has drifted across surfaces repeatedly (68/69/65/61/
|
|
9
|
+
// "70+"), which the founder rightly hates. TOOL_COUNT (= allTools.length) is the ONE
|
|
10
|
+
// source of truth; every hardcoded doc surface must equal it. If you add/remove a
|
|
11
|
+
// tool, this test fails until you update the surfaces below (or vice-versa).
|
|
12
|
+
//
|
|
13
|
+
// NOT checked here: the mosADD app's LP `McpToolReference` computes its total
|
|
14
|
+
// dynamically from the rendered list, so it cannot drift; and the mosadd-agent README
|
|
15
|
+
// lives in a separate repo. Both are noted in the migration handoff.
|
|
16
|
+
//
|
|
17
|
+
// ⚠ CROSS-REPO SURFACE THIS TEST CANNOT REACH: the public MCP server card at
|
|
18
|
+
// apps/web/public/.well-known/mcp/server-card.json lives in the m0ssad-3 repo
|
|
19
|
+
// (served at mosadd.com/.well-known/mcp/server-card.json). Found 2026-07-30
|
|
20
|
+
// advertising 69 AND 64 at once while TOOL_COUNT was 73. It is pinned by its own
|
|
21
|
+
// static gate THERE: m0ssad-3 scripts/check-mcp-server-card.mjs (wired into
|
|
22
|
+
// scripts/gates-local.mjs), whose EXPECTED_TOOL_COUNT constant must be bumped in
|
|
23
|
+
// the same change whenever TOOL_COUNT moves.
|
|
24
|
+
|
|
25
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
const repoRoot = resolve(here, "../../../.."); // packages/mcp/src/__tests__ -> repo root
|
|
27
|
+
|
|
28
|
+
const SURFACES: { file: string; re: RegExp; what: string }[] = [
|
|
29
|
+
// README FIRST, because it is the one people actually read. It was NOT in this list until
|
|
30
|
+
// 2026-07-29 — the gate guarded four internal surfaces and left the public face of the project
|
|
31
|
+
// unguarded, which is the wrong way round. The badge is checked because a wrong number in a
|
|
32
|
+
// green badge is the most confident-looking lie a repo can tell.
|
|
33
|
+
// README rewritten 2026-09-29 (m.0S truth pass): the badge, the @alpha quickstart line and the long module
|
|
34
|
+
// table are gone; the two sentences that carry the total are pinned instead.
|
|
35
|
+
{ file: "README.md", re: /^(\d+) tools in `@mosadd\/mcp`/m, what: "README tools section" },
|
|
36
|
+
{ file: "packages/mcp/server.json", re: /(\d+)\s+MCP tools/, what: "MCP registry manifest description" },
|
|
37
|
+
// The npm-visible description — what `npm view @mosadd/mcp description` and the npmjs.com
|
|
38
|
+
// page show. Added 2026-07-30: it already said 73 but nothing enforced it.
|
|
39
|
+
{ file: "packages/mcp/package.json", re: /—\s*(\d+)\s+tools\s+—/, what: "package.json description" },
|
|
40
|
+
// Added 2026-08-01 (content-truth audit): six surfaces the gate did
|
|
41
|
+
// not pin had silently drifted to 69/66/71/22/4 while TOOL_COUNT was 73. Every public
|
|
42
|
+
// file that hand-types a total is now listed here — if you add a surface with a
|
|
43
|
+
// number, add it to this array in the same PR.
|
|
44
|
+
{ file: "packages/ai/README.md", re: /the (\d+) mosADD toolkit tools/, what: "@mosadd/ai README" },
|
|
45
|
+
{ file: "docs/architecture/human-os.md", re: /exposing \*\*(\d+) tools\*\*/, what: "human-os architecture doc" },
|
|
46
|
+
{ file: "examples/README.md", re: /\*\*(\d+) live MCP tools across/, what: "examples README header" },
|
|
47
|
+
{ file: "packages/mcp/README.md", re: /One key, one server, (\d+) tools/, what: "@mosadd/mcp README intro" },
|
|
48
|
+
{ file: "packages/mcp/README.md", re: /\*\*(\d+) callable tools\*\* in total/, what: "@mosadd/mcp README breakdown" },
|
|
49
|
+
// Added 2026-09-04 (docs review): three more public files hand-typed a total
|
|
50
|
+
// and had sat at 77 through two bumps (82, 84) because nothing pinned them. Both realm llms.txt
|
|
51
|
+
// lines are pinned separately — a single /(\d+) tools/ would only ever see the first.
|
|
52
|
+
// The package's own number, 85 on 2026-09-29, pinned where a text describes @mosadd/mcp itself.
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
// ── The HUB's number ────────────────────────────────────────────────────────
|
|
56
|
+
// 2026-09-29 (verifier of the m.0S distribution pass): the public texts said "85 tools" for
|
|
57
|
+
// https://mcp.mosadd.dev/mcp while the hub listed 88 — it serves every @mosadd/mcp tool plus tools of its
|
|
58
|
+
// own. 2026-09-30: the hub lists 86, because the phone-call tools (call_start, call_status) are held back until
|
|
59
|
+
// calls open (the price list marks them "soon"); the count moved 85 → 88 → 86 in two days. So texts about the
|
|
60
|
+
// ENDPOINT carry no number at all: they point at distribution/hub-tools.json (a snapshot of the live tools/list;
|
|
61
|
+
// `node scripts/check-hub-tools.mjs` compares it with the live hub, `--write` refreshes it), and this gate fails
|
|
62
|
+
// when one of them states "<N> tools" for the endpoint again. A number that describes @mosadd/mcp itself (a line
|
|
63
|
+
// that names `@mosadd/mcp`) stays and is pinned to TOOL_COUNT by SURFACES above.
|
|
64
|
+
const hubSnapshot = JSON.parse(readFileSync(resolve(repoRoot, "distribution/hub-tools.json"), "utf8")) as {
|
|
65
|
+
count: number;
|
|
66
|
+
names: string[];
|
|
67
|
+
server_version: string;
|
|
68
|
+
};
|
|
69
|
+
const packageNames = allTools.map((t) => t.name);
|
|
70
|
+
const HUB_ONLY = hubSnapshot.names.filter((n) => !packageNames.includes(n)).sort();
|
|
71
|
+
const HUB_COUNT = hubSnapshot.count;
|
|
72
|
+
const HELD_BACK = ["call_start", "call_status"]; // phone calls through the user's own Telnyx/Twilio account: "soon"
|
|
73
|
+
|
|
74
|
+
// Every public text that talks about the endpoint (not about the package).
|
|
75
|
+
// 2026-11-14 (README rewrite for the mosADD OS name): the hub paragraph left README.md for docs/tools.md, so the
|
|
76
|
+
// snapshot test below reads HUB_PARAGRAPH_FILE; README.md stays here, so it still may not state a hub count.
|
|
77
|
+
const HUB_PARAGRAPH_FILE = "docs/tools.md";
|
|
78
|
+
const HUB_TEXTS = [
|
|
79
|
+
"README.md",
|
|
80
|
+
HUB_PARAGRAPH_FILE,
|
|
81
|
+
"docs/hosts.md",
|
|
82
|
+
"docs/roadmap.md",
|
|
83
|
+
"skills/m0s-quickstart/SKILL.md",
|
|
84
|
+
"distribution/clawhub/m0s/SKILL.md",
|
|
85
|
+
"distribution/pulsemcp.md",
|
|
86
|
+
"distribution/mcp-so.md",
|
|
87
|
+
"distribution/awesome-mcp-servers.md",
|
|
88
|
+
];
|
|
89
|
+
/** "88 tools", "88 MCP tools", "88 live tools" — a fixed count, in a line that is not about @mosadd/mcp. */
|
|
90
|
+
const FIXED_COUNT = /\b\d+\s+(?:MCP\s+|live\s+|callable\s+)?tools\b/i;
|
|
91
|
+
function fixedHubCounts(text: string): string[] {
|
|
92
|
+
return text.split(/\r?\n/).filter((l) => FIXED_COUNT.test(l) && !l.includes("@mosadd/mcp"));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
describe("tool-count consistency (anti-drift gate)", () => {
|
|
96
|
+
it("TOOL_COUNT is a positive integer", () => {
|
|
97
|
+
expect(Number.isInteger(TOOL_COUNT)).toBe(true);
|
|
98
|
+
expect(TOOL_COUNT).toBeGreaterThan(0);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
for (const s of SURFACES) {
|
|
102
|
+
it(`${s.what} (${s.file}) advertises exactly TOOL_COUNT (${TOOL_COUNT})`, () => {
|
|
103
|
+
const txt = readFileSync(resolve(repoRoot, s.file), "utf8");
|
|
104
|
+
const m = txt.match(s.re);
|
|
105
|
+
expect(m, `no tool-count number found in ${s.file} — did the surface change shape?`).toBeTruthy();
|
|
106
|
+
expect(
|
|
107
|
+
Number(m![1]),
|
|
108
|
+
`${s.file} says ${m![1]} tools but TOOL_COUNT is ${TOOL_COUNT} — sync the surface or the registry`,
|
|
109
|
+
).toBe(TOOL_COUNT);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe("hub tool count (texts about https://mcp.mosadd.dev/mcp)", () => {
|
|
115
|
+
it("the snapshot is the package plus the hub's own tools, nothing missing", () => {
|
|
116
|
+
expect(hubSnapshot.names).toHaveLength(hubSnapshot.count);
|
|
117
|
+
expect(packageNames.filter((n) => !hubSnapshot.names.includes(n)), "package tools the hub does not list").toEqual([]);
|
|
118
|
+
expect(HUB_COUNT).toBe(TOOL_COUNT + HUB_ONLY.length);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it(`the hub paragraph (${HUB_PARAGRAPH_FILE}) points at the snapshot, names every hub-only tool and says which are held back`, () => {
|
|
122
|
+
const doc = readFileSync(resolve(repoRoot, HUB_PARAGRAPH_FILE), "utf8");
|
|
123
|
+
const para = doc.match(/[^\n]*distribution\/hub-tools\.json[^\n]*(?:\n(?!\n)[^\n]*)*/)?.[0] ?? "";
|
|
124
|
+
expect(para, `${HUB_PARAGRAPH_FILE} has no paragraph pointing at distribution/hub-tools.json`).not.toBe("");
|
|
125
|
+
for (const n of HUB_ONLY) expect(para, `${HUB_PARAGRAPH_FILE} hub paragraph does not name ${n}`).toContain(`\`${n}\``);
|
|
126
|
+
const listed = HELD_BACK.filter((n) => hubSnapshot.names.includes(n));
|
|
127
|
+
if (listed.length === 0) {
|
|
128
|
+
// calls are not open: the hub paragraph must say so, and name the tools it holds back
|
|
129
|
+
expect(para).toMatch(/coming soon/);
|
|
130
|
+
expect(para).toMatch(/held back/);
|
|
131
|
+
for (const n of HELD_BACK) expect(para, `${HUB_PARAGRAPH_FILE} does not name the held-back ${n}`).toContain(`\`${n}\``);
|
|
132
|
+
} else {
|
|
133
|
+
expect(para, `the hub lists ${listed.join(", ")} now — ${HUB_PARAGRAPH_FILE} still says they are held back`).not.toMatch(/held back/);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
for (const file of HUB_TEXTS) {
|
|
138
|
+
it(`${file} states no fixed number of hub tools (it points at distribution/hub-tools.json)`, () => {
|
|
139
|
+
const lines = fixedHubCounts(readFileSync(resolve(repoRoot, file), "utf8"));
|
|
140
|
+
expect(
|
|
141
|
+
lines,
|
|
142
|
+
`${file} states a fixed tool count for the endpoint (the hub lists ${HUB_COUNT} today, and it changes): drop the number or point at distribution/hub-tools.json`,
|
|
143
|
+
).toEqual([]);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
it("the gate fires: a text that says '88 tools' for the endpoint is caught, one about @mosadd/mcp is not", () => {
|
|
148
|
+
expect(fixedHubCounts("m.0S is a hosted MCP endpoint with 88 tools.")).toHaveLength(1);
|
|
149
|
+
expect(fixedHubCounts("The hub lists **88 MCP tools** today.")).toHaveLength(1);
|
|
150
|
+
expect(fixedHubCounts("85 tools in `@mosadd/mcp` (`3.0.0-alpha.55`)")).toEqual([]);
|
|
151
|
+
expect(fixedHubCounts("The hub's tool list is whatever `tools/list` returns.")).toEqual([]);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// ── Per-MODULE anti-drift gate ───────────────────────────────────────────────
|
|
156
|
+
// WHY this exists (added 2026-08-11): the total-only gate above was GREEN while the
|
|
157
|
+
// prose around every pinned line was wrong. Each SURFACES entry pins ONE regex per
|
|
158
|
+
// file, so somebody could correct the single matched number and leave its own sentence
|
|
159
|
+
// contradicting it. Measured that day, with TOOL_COUNT = 77:
|
|
160
|
+
// - packages/mcp/README.md ended a sentence "**77 callable tools** in total" (pinned,
|
|
161
|
+
// green) whose own terms — mDM 14 + mIRC 24 + mURL 7 + mAYL 12 = 57, +16 — summed
|
|
162
|
+
// to 73, because mAYL had grown by the four mAYL_agentbox_* tools and nobody
|
|
163
|
+
// re-added the addends.
|
|
164
|
+
// - src/tools/index.ts said the same thing in its header comment.
|
|
165
|
+
// A breakdown that contradicts its own total is worse than no breakdown: it looks
|
|
166
|
+
// audited. So the addends are now derived from allTools and pinned too.
|
|
167
|
+
const liveByModule: Record<string, number> = (() => {
|
|
168
|
+
const by: Record<string, number> = {};
|
|
169
|
+
for (const t of allTools) {
|
|
170
|
+
// Prefix = everything before the first "_", except comms_*/threat_* which are
|
|
171
|
+
// capability groups rather than m* modules and are labelled as such in the docs.
|
|
172
|
+
const prefix = t.name.startsWith("comms_")
|
|
173
|
+
? "comms"
|
|
174
|
+
: t.name.startsWith("threat_")
|
|
175
|
+
? "threat"
|
|
176
|
+
: t.name.split("_")[0];
|
|
177
|
+
by[prefix] = (by[prefix] ?? 0) + 1;
|
|
178
|
+
}
|
|
179
|
+
return by;
|
|
180
|
+
})();
|
|
181
|
+
|
|
182
|
+
/** Doc label → the registry prefix it describes. "Irondome" is the brand name for threat_*. */
|
|
183
|
+
const MODULE_LABELS: { label: string; prefix: string }[] = [
|
|
184
|
+
{ label: "mDM", prefix: "mDM" },
|
|
185
|
+
{ label: "mIRC", prefix: "mIRC" },
|
|
186
|
+
{ label: "mURL", prefix: "mURL" },
|
|
187
|
+
{ label: "mAYL", prefix: "mAYL" },
|
|
188
|
+
{ label: "mTALK", prefix: "mTALK" },
|
|
189
|
+
{ label: "mRAG", prefix: "mRAG" },
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
const MODULE_SURFACES: { file: string; what: string; re: (label: string) => RegExp }[] = [
|
|
193
|
+
{
|
|
194
|
+
file: "packages/mcp/src/tools/index.ts",
|
|
195
|
+
what: "registry header breakdown",
|
|
196
|
+
// "modules mDM 14 · mIRC 24 · mURL 7 · mAYL 16 = 61; capabilities mTALK 6 · mRAG 4 …"
|
|
197
|
+
re: (label) => new RegExp(`\\b${label}\\s+(\\d+)\\s*[·=]`),
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
file: "packages/mcp/README.md",
|
|
201
|
+
what: "README module table row",
|
|
202
|
+
// "| **mDM** (14) | `mDM_list_contacts`, …"
|
|
203
|
+
re: (label) => new RegExp(`\\|\\s*\\*\\*${label}\\*\\*\\s*\\((\\d+)\\)`),
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
file: "packages/mcp/README.md",
|
|
207
|
+
what: "README breakdown addends",
|
|
208
|
+
// "mDM (14) + mIRC (24) + … ; capabilities: mTALK (6) + mRAG (4) + …"
|
|
209
|
+
re: (label) => new RegExp(`\\b${label}_?\\s*\\((\\d+)\\)\\s*[+=;]`),
|
|
210
|
+
},
|
|
211
|
+
// Added 2026-09-04 (docs review). Measured that day: examples/README.md had
|
|
212
|
+
// its header bumped to 85 while its own addends still read mDM (14) / mRAG (4) / comms (4) — a
|
|
213
|
+
// breakdown summing to 78 under a headline of 85, the exact shape this gate exists for. The
|
|
214
|
+
// realm llms.txt and the Smithery copy carried mDM 14 / mIRC 24 / mRAG 4 from alpha.33.
|
|
215
|
+
{
|
|
216
|
+
file: "examples/README.md",
|
|
217
|
+
what: "examples README per-module list",
|
|
218
|
+
// "- **mDM** (16): list_contacts, …"
|
|
219
|
+
re: (label) => new RegExp(`\\*\\*${label}\\*\\*\\s*\\((\\d+)\\)`),
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
file: "README.md",
|
|
223
|
+
what: "README tools line",
|
|
224
|
+
// "mDM 16 · mIRC 25 · mURL 7 · mAYL 16 · mTALK 6 · mRAG 8 · comms 5 · threat 2"
|
|
225
|
+
re: (label) => new RegExp(`\\b${label} (\\d+) ·`),
|
|
226
|
+
},
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
describe("per-module tool-count consistency", () => {
|
|
230
|
+
it("every registered tool falls into a known module/capability prefix", () => {
|
|
231
|
+
const known = new Set([...MODULE_LABELS.map((m) => m.prefix), "comms", "threat"]);
|
|
232
|
+
const strays = Object.keys(liveByModule).filter((p) => !known.has(p));
|
|
233
|
+
expect(
|
|
234
|
+
strays,
|
|
235
|
+
`unknown tool prefix(es) ${strays.join(", ")} — a new module shipped without a doc breakdown; ` +
|
|
236
|
+
`add it to MODULE_LABELS and to every surface listed in MODULE_SURFACES`,
|
|
237
|
+
).toEqual([]);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("the per-module numbers add up to TOOL_COUNT", () => {
|
|
241
|
+
const sum = Object.values(liveByModule).reduce((a, b) => a + b, 0);
|
|
242
|
+
expect(sum).toBe(TOOL_COUNT);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
for (const s of MODULE_SURFACES) {
|
|
246
|
+
for (const { label, prefix } of MODULE_LABELS) {
|
|
247
|
+
it(`${s.what} (${s.file}) says ${label} = ${liveByModule[prefix]}`, () => {
|
|
248
|
+
const txt = readFileSync(resolve(repoRoot, s.file), "utf8");
|
|
249
|
+
const m = txt.match(s.re(label));
|
|
250
|
+
expect(m, `no "${label} <n>" breakdown found in ${s.file} — did the surface change shape?`).toBeTruthy();
|
|
251
|
+
expect(
|
|
252
|
+
Number(m![1]),
|
|
253
|
+
`${s.file} says ${label} has ${m![1]} tools but the registry has ${liveByModule[prefix]} — ` +
|
|
254
|
+
`sync the surface or the registry`,
|
|
255
|
+
).toBe(liveByModule[prefix]);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|