@mosadd/mcp 3.0.0-alpha.32 → 3.0.0-alpha.33
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 +74 -0
- package/README.md +11 -11
- package/dist/bin/mcp.js +1 -1
- package/dist/{chunk-KX34DDJB.js → chunk-IWLN5EO5.js} +614 -134
- package/dist/index.js +1 -1
- package/package.json +15 -15
- package/src/__tests__/golden-path.test.ts +137 -137
- package/src/__tests__/integration.test.ts +179 -179
- package/src/__tests__/knowledge-ingest.test.ts +114 -0
- package/src/__tests__/mdm-e2ee.test.ts +212 -212
- package/src/__tests__/mtalk.test.ts +122 -122
- package/src/__tests__/presence.test.ts +141 -0
- package/src/__tests__/server.test.ts +71 -71
- package/src/__tests__/tool-count-consistency.test.ts +121 -1
- package/src/bin/login.ts +138 -138
- package/src/bin/mcp.ts +145 -145
- package/src/config.ts +66 -66
- package/src/crypto/mdm-session.ts +502 -502
- package/src/index.ts +19 -19
- package/src/observability/sentry.ts +79 -79
- package/src/providers/blob-upload.ts +116 -116
- package/src/providers/memory-voice.ts +79 -79
- package/src/providers/supabase-dm.ts +122 -122
- package/src/providers/supabase-voice.ts +91 -91
- package/src/providers/supabase.ts +148 -148
- package/src/tools/actions.ts +162 -162
- package/src/tools/attachments.ts +268 -268
- package/src/tools/capabilities.ts +68 -68
- package/src/tools/embed.ts +108 -108
- package/src/tools/index.ts +173 -104
- package/src/tools/knowledge-graph.ts +178 -0
- package/src/tools/knowledge.ts +319 -191
- package/src/tools/mail-agentbox.ts +147 -0
- package/src/tools/mail-aliases.ts +25 -25
- package/src/tools/mail-provenance.ts +135 -135
- package/src/tools/mail.ts +381 -381
- package/src/tools/mdm.ts +476 -479
- package/src/tools/mirc-edge.ts +190 -190
- package/src/tools/mirc-members.ts +2 -2
- package/src/tools/mirc-messages.ts +155 -155
- package/src/tools/mirc.ts +2 -2
- package/src/tools/mroom-messages.ts +142 -142
- package/src/tools/mroom.ts +221 -221
- package/src/tools/mtalk.ts +121 -121
- package/src/tools/murl.ts +4 -2
- package/src/tools/presence.ts +208 -0
- package/src/types.ts +94 -94
- package/src/voice/floor.ts +132 -132
- package/LICENSE +0 -201
- package/dist/bin/login.d.ts +0 -13
- package/dist/bin/mcp.d.ts +0 -1
- package/dist/index.d.ts +0 -266
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* mTALK PTT golden path — the half-duplex floor discipline (the kill feature).
|
|
3
|
-
*
|
|
4
|
-
* Two participants (alice, bob) share ONE room (one floor). Proves through the
|
|
5
|
-
* actual mTALK tools:
|
|
6
|
-
* 1. first to press PTT is GRANTED the floor,
|
|
7
|
-
* 2. a second presser is DENIED and QUEUED (half-duplex — one talker),
|
|
8
|
-
* 3. releasing the floor PROMOTES the next in the queue automatically,
|
|
9
|
-
* 4. the anti-hog timeout auto-bumps a holder who never releases,
|
|
10
|
-
* 5. join credentials are issued for the media transport.
|
|
11
|
-
*
|
|
12
|
-
* Deterministic: the in-memory voice provider takes an injected clock, so the
|
|
13
|
-
* anti-hog timeout is tested without real time passing.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { describe, expect, it } from "vitest";
|
|
17
|
-
import { mtalkTools } from "../tools/mtalk.js";
|
|
18
|
-
import { InMemoryVoiceProvider } from "../providers/memory-voice.js";
|
|
19
|
-
import { InMemoryMdmKeyStore } from "../crypto/mdm-session.js";
|
|
20
|
-
import type { DmProvider } from "@mosadd/providers";
|
|
21
|
-
import type { MosaddToolContext } from "../types.js";
|
|
22
|
-
|
|
23
|
-
const tool = (name: string) => {
|
|
24
|
-
const t = mtalkTools.find((x) => x.name === name);
|
|
25
|
-
if (!t) throw new Error(`tool ${name} not found`);
|
|
26
|
-
return t.handler;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// mTALK tools never touch dm/keys; a minimal stub satisfies the type.
|
|
30
|
-
const dmStub = {} as unknown as DmProvider;
|
|
31
|
-
|
|
32
|
-
function ctxFor(voice: InMemoryVoiceProvider): MosaddToolContext {
|
|
33
|
-
return {
|
|
34
|
-
options: { mode: "local", hubUrl: "https://mcp.mosadd.com" },
|
|
35
|
-
providers: { dm: dmStub, keys: new InMemoryMdmKeyStore(), voice },
|
|
36
|
-
log: () => {},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
describe("mTALK PTT floor discipline — half-duplex, queue, promotion, anti-hog", () => {
|
|
41
|
-
it("grants one speaker, queues the next, promotes on release", async () => {
|
|
42
|
-
let now = 1_000;
|
|
43
|
-
const clock = () => now;
|
|
44
|
-
const aliceVoice = new InMemoryVoiceProvider("alice", clock);
|
|
45
|
-
const bobVoice = new InMemoryVoiceProvider("bob", clock);
|
|
46
|
-
aliceVoice.shareRoomsWith(bobVoice); // one shared room/floor
|
|
47
|
-
const alice = ctxFor(aliceVoice);
|
|
48
|
-
const bob = ctxFor(bobVoice);
|
|
49
|
-
|
|
50
|
-
// Open a shared room.
|
|
51
|
-
const { room_id } = (await tool("mTALK_open")({ label: "ops" }, alice)) as { room_id: string };
|
|
52
|
-
expect(room_id).toContain("ops");
|
|
53
|
-
|
|
54
|
-
// 1. Alice presses PTT first → granted.
|
|
55
|
-
const aPress = (await tool("mTALK_press")({ room_id }, alice)) as {
|
|
56
|
-
granted: boolean;
|
|
57
|
-
position: number;
|
|
58
|
-
holder: string | null;
|
|
59
|
-
};
|
|
60
|
-
expect(aPress.granted).toBe(true);
|
|
61
|
-
expect(aPress.holder).toBe("alice");
|
|
62
|
-
|
|
63
|
-
// 2. Bob presses while Alice holds → denied + queued at position 1.
|
|
64
|
-
const bPress = (await tool("mTALK_press")({ room_id }, bob)) as {
|
|
65
|
-
granted: boolean;
|
|
66
|
-
position: number;
|
|
67
|
-
holder: string | null;
|
|
68
|
-
queue: string[];
|
|
69
|
-
};
|
|
70
|
-
expect(bPress.granted).toBe(false);
|
|
71
|
-
expect(bPress.position).toBe(1);
|
|
72
|
-
expect(bPress.holder).toBe("alice");
|
|
73
|
-
expect(bPress.queue).toEqual(["bob"]);
|
|
74
|
-
|
|
75
|
-
// 3. Alice releases → Bob is promoted to holder automatically.
|
|
76
|
-
const released = (await tool("mTALK_release")({ room_id }, alice)) as {
|
|
77
|
-
holder: string | null;
|
|
78
|
-
queue: string[];
|
|
79
|
-
};
|
|
80
|
-
expect(released.holder).toBe("bob");
|
|
81
|
-
expect(released.queue).toEqual([]);
|
|
82
|
-
|
|
83
|
-
// State reads consistently from Bob's side too.
|
|
84
|
-
const state = (await tool("mTALK_state")({ room_id }, bob)) as { holder: string | null };
|
|
85
|
-
expect(state.holder).toBe("bob");
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("auto-bumps a holder who exceeds the anti-hog timeout", async () => {
|
|
89
|
-
let now = 0;
|
|
90
|
-
const clock = () => now;
|
|
91
|
-
const aliceVoice = new InMemoryVoiceProvider("alice", clock);
|
|
92
|
-
const bobVoice = new InMemoryVoiceProvider("bob", clock);
|
|
93
|
-
aliceVoice.shareRoomsWith(bobVoice);
|
|
94
|
-
const alice = ctxFor(aliceVoice);
|
|
95
|
-
const bob = ctxFor(bobVoice);
|
|
96
|
-
|
|
97
|
-
const { room_id } = (await tool("mTALK_open")({ label: "ops" }, alice)) as { room_id: string };
|
|
98
|
-
|
|
99
|
-
await tool("mTALK_press")({ room_id }, alice); // alice holds at t=0
|
|
100
|
-
const bPress = (await tool("mTALK_press")({ room_id }, bob)) as { granted: boolean };
|
|
101
|
-
expect(bPress.granted).toBe(false); // queued behind alice
|
|
102
|
-
|
|
103
|
-
// Advance past the 30s anti-hog ceiling; next floor read auto-promotes bob.
|
|
104
|
-
now = 31_000;
|
|
105
|
-
const state = (await tool("mTALK_state")({ room_id }, bob)) as { holder: string | null };
|
|
106
|
-
expect(state.holder).toBe("bob"); // alice was bumped, bob promoted
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("issues join credentials for the media transport", async () => {
|
|
110
|
-
const voice = new InMemoryVoiceProvider("alice");
|
|
111
|
-
const alice = ctxFor(voice);
|
|
112
|
-
const { room_id } = (await tool("mTALK_open")({}, alice)) as { room_id: string };
|
|
113
|
-
const join = (await tool("mTALK_join")({ room_id }, alice)) as {
|
|
114
|
-
token: string;
|
|
115
|
-
url: string;
|
|
116
|
-
identity: string;
|
|
117
|
-
};
|
|
118
|
-
expect(join.identity).toBe("alice");
|
|
119
|
-
expect(join.token).toBeTruthy();
|
|
120
|
-
expect(join.url).toBeTruthy();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* mTALK PTT golden path — the half-duplex floor discipline (the kill feature).
|
|
3
|
+
*
|
|
4
|
+
* Two participants (alice, bob) share ONE room (one floor). Proves through the
|
|
5
|
+
* actual mTALK tools:
|
|
6
|
+
* 1. first to press PTT is GRANTED the floor,
|
|
7
|
+
* 2. a second presser is DENIED and QUEUED (half-duplex — one talker),
|
|
8
|
+
* 3. releasing the floor PROMOTES the next in the queue automatically,
|
|
9
|
+
* 4. the anti-hog timeout auto-bumps a holder who never releases,
|
|
10
|
+
* 5. join credentials are issued for the media transport.
|
|
11
|
+
*
|
|
12
|
+
* Deterministic: the in-memory voice provider takes an injected clock, so the
|
|
13
|
+
* anti-hog timeout is tested without real time passing.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, expect, it } from "vitest";
|
|
17
|
+
import { mtalkTools } from "../tools/mtalk.js";
|
|
18
|
+
import { InMemoryVoiceProvider } from "../providers/memory-voice.js";
|
|
19
|
+
import { InMemoryMdmKeyStore } from "../crypto/mdm-session.js";
|
|
20
|
+
import type { DmProvider } from "@mosadd/providers";
|
|
21
|
+
import type { MosaddToolContext } from "../types.js";
|
|
22
|
+
|
|
23
|
+
const tool = (name: string) => {
|
|
24
|
+
const t = mtalkTools.find((x) => x.name === name);
|
|
25
|
+
if (!t) throw new Error(`tool ${name} not found`);
|
|
26
|
+
return t.handler;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// mTALK tools never touch dm/keys; a minimal stub satisfies the type.
|
|
30
|
+
const dmStub = {} as unknown as DmProvider;
|
|
31
|
+
|
|
32
|
+
function ctxFor(voice: InMemoryVoiceProvider): MosaddToolContext {
|
|
33
|
+
return {
|
|
34
|
+
options: { mode: "local", hubUrl: "https://mcp.mosadd.com" },
|
|
35
|
+
providers: { dm: dmStub, keys: new InMemoryMdmKeyStore(), voice },
|
|
36
|
+
log: () => {},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe("mTALK PTT floor discipline — half-duplex, queue, promotion, anti-hog", () => {
|
|
41
|
+
it("grants one speaker, queues the next, promotes on release", async () => {
|
|
42
|
+
let now = 1_000;
|
|
43
|
+
const clock = () => now;
|
|
44
|
+
const aliceVoice = new InMemoryVoiceProvider("alice", clock);
|
|
45
|
+
const bobVoice = new InMemoryVoiceProvider("bob", clock);
|
|
46
|
+
aliceVoice.shareRoomsWith(bobVoice); // one shared room/floor
|
|
47
|
+
const alice = ctxFor(aliceVoice);
|
|
48
|
+
const bob = ctxFor(bobVoice);
|
|
49
|
+
|
|
50
|
+
// Open a shared room.
|
|
51
|
+
const { room_id } = (await tool("mTALK_open")({ label: "ops" }, alice)) as { room_id: string };
|
|
52
|
+
expect(room_id).toContain("ops");
|
|
53
|
+
|
|
54
|
+
// 1. Alice presses PTT first → granted.
|
|
55
|
+
const aPress = (await tool("mTALK_press")({ room_id }, alice)) as {
|
|
56
|
+
granted: boolean;
|
|
57
|
+
position: number;
|
|
58
|
+
holder: string | null;
|
|
59
|
+
};
|
|
60
|
+
expect(aPress.granted).toBe(true);
|
|
61
|
+
expect(aPress.holder).toBe("alice");
|
|
62
|
+
|
|
63
|
+
// 2. Bob presses while Alice holds → denied + queued at position 1.
|
|
64
|
+
const bPress = (await tool("mTALK_press")({ room_id }, bob)) as {
|
|
65
|
+
granted: boolean;
|
|
66
|
+
position: number;
|
|
67
|
+
holder: string | null;
|
|
68
|
+
queue: string[];
|
|
69
|
+
};
|
|
70
|
+
expect(bPress.granted).toBe(false);
|
|
71
|
+
expect(bPress.position).toBe(1);
|
|
72
|
+
expect(bPress.holder).toBe("alice");
|
|
73
|
+
expect(bPress.queue).toEqual(["bob"]);
|
|
74
|
+
|
|
75
|
+
// 3. Alice releases → Bob is promoted to holder automatically.
|
|
76
|
+
const released = (await tool("mTALK_release")({ room_id }, alice)) as {
|
|
77
|
+
holder: string | null;
|
|
78
|
+
queue: string[];
|
|
79
|
+
};
|
|
80
|
+
expect(released.holder).toBe("bob");
|
|
81
|
+
expect(released.queue).toEqual([]);
|
|
82
|
+
|
|
83
|
+
// State reads consistently from Bob's side too.
|
|
84
|
+
const state = (await tool("mTALK_state")({ room_id }, bob)) as { holder: string | null };
|
|
85
|
+
expect(state.holder).toBe("bob");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("auto-bumps a holder who exceeds the anti-hog timeout", async () => {
|
|
89
|
+
let now = 0;
|
|
90
|
+
const clock = () => now;
|
|
91
|
+
const aliceVoice = new InMemoryVoiceProvider("alice", clock);
|
|
92
|
+
const bobVoice = new InMemoryVoiceProvider("bob", clock);
|
|
93
|
+
aliceVoice.shareRoomsWith(bobVoice);
|
|
94
|
+
const alice = ctxFor(aliceVoice);
|
|
95
|
+
const bob = ctxFor(bobVoice);
|
|
96
|
+
|
|
97
|
+
const { room_id } = (await tool("mTALK_open")({ label: "ops" }, alice)) as { room_id: string };
|
|
98
|
+
|
|
99
|
+
await tool("mTALK_press")({ room_id }, alice); // alice holds at t=0
|
|
100
|
+
const bPress = (await tool("mTALK_press")({ room_id }, bob)) as { granted: boolean };
|
|
101
|
+
expect(bPress.granted).toBe(false); // queued behind alice
|
|
102
|
+
|
|
103
|
+
// Advance past the 30s anti-hog ceiling; next floor read auto-promotes bob.
|
|
104
|
+
now = 31_000;
|
|
105
|
+
const state = (await tool("mTALK_state")({ room_id }, bob)) as { holder: string | null };
|
|
106
|
+
expect(state.holder).toBe("bob"); // alice was bumped, bob promoted
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("issues join credentials for the media transport", async () => {
|
|
110
|
+
const voice = new InMemoryVoiceProvider("alice");
|
|
111
|
+
const alice = ctxFor(voice);
|
|
112
|
+
const { room_id } = (await tool("mTALK_open")({}, alice)) as { room_id: string };
|
|
113
|
+
const join = (await tool("mTALK_join")({ room_id }, alice)) as {
|
|
114
|
+
token: string;
|
|
115
|
+
url: string;
|
|
116
|
+
identity: string;
|
|
117
|
+
};
|
|
118
|
+
expect(join.identity).toBe("alice");
|
|
119
|
+
expect(join.token).toBeTruthy();
|
|
120
|
+
expect(join.url).toBeTruthy();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
|
|
21
|
+
/** Calls recorded by the fake Supabase client, so assertions read like the wire traffic. */
|
|
22
|
+
const calls = {
|
|
23
|
+
upserts: [] as Record<string, unknown>[],
|
|
24
|
+
deletes: [] as string[],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Minimal query-builder stand-in: every method returns the builder, `maybeSingle()` resolves the
|
|
29
|
+
* identity row, and the builder is thenable so `await delete().eq()` works like PostgREST's.
|
|
30
|
+
*/
|
|
31
|
+
function makeBuilder(table: string) {
|
|
32
|
+
const builder: Record<string, unknown> = {};
|
|
33
|
+
let pendingDelete = false;
|
|
34
|
+
const self = () => builder;
|
|
35
|
+
Object.assign(builder, {
|
|
36
|
+
select: self,
|
|
37
|
+
upsert: (row: Record<string, unknown>) => {
|
|
38
|
+
calls.upserts.push({ table, ...row });
|
|
39
|
+
return Promise.resolve({ error: null });
|
|
40
|
+
},
|
|
41
|
+
delete: () => {
|
|
42
|
+
pendingDelete = true;
|
|
43
|
+
return builder;
|
|
44
|
+
},
|
|
45
|
+
eq: (_col: string, val: string) => {
|
|
46
|
+
if (pendingDelete) {
|
|
47
|
+
calls.deletes.push(val);
|
|
48
|
+
return Promise.resolve({ error: null });
|
|
49
|
+
}
|
|
50
|
+
return builder;
|
|
51
|
+
},
|
|
52
|
+
maybeSingle: () => Promise.resolve({ data: { id: IDENTITY_ID, display_name: "mosADD CTO" }, error: null }),
|
|
53
|
+
});
|
|
54
|
+
return builder;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
vi.mock("../providers/supabase.js", () => ({
|
|
58
|
+
readSupabaseEnv: () => ({ url: "https://example.supabase.co", anonKey: "anon", userJwt: "jwt" }),
|
|
59
|
+
getSupabase: () => ({
|
|
60
|
+
auth: { getUser: () => Promise.resolve({ data: { user: { id: USER_ID } }, error: null }) },
|
|
61
|
+
from: (table: string) => makeBuilder(table),
|
|
62
|
+
}),
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
const ctx = { log: () => {} } as never;
|
|
66
|
+
|
|
67
|
+
/** Import after the mock is registered, so the module under test picks it up. */
|
|
68
|
+
const { presenceTools, __clearAttachmentsForTest } = await import("../tools/presence.js");
|
|
69
|
+
const attach = presenceTools[0];
|
|
70
|
+
|
|
71
|
+
async function call(input: Record<string, unknown>) {
|
|
72
|
+
return (await attach.handler(input, ctx)) as Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe("comms_session_attach", () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
calls.upserts = [];
|
|
78
|
+
calls.deletes = [];
|
|
79
|
+
vi.useFakeTimers();
|
|
80
|
+
});
|
|
81
|
+
afterEach(() => {
|
|
82
|
+
__clearAttachmentsForTest();
|
|
83
|
+
vi.useRealTimers();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("is registered as a network tool under the comms_ capability group", () => {
|
|
87
|
+
expect(attach.name).toBe("comms_session_attach");
|
|
88
|
+
expect(attach.requires).toBe("network");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("claims the line for the CALLER'S identity, with a label the owner can read", async () => {
|
|
92
|
+
const out = await call({ label: "CTO — Claude Code" });
|
|
93
|
+
expect(out.attached).toBe(true);
|
|
94
|
+
expect(out.identity_id).toBe(IDENTITY_ID);
|
|
95
|
+
expect(calls.upserts).toHaveLength(1);
|
|
96
|
+
expect(calls.upserts[0]).toMatchObject({
|
|
97
|
+
table: "agent_bridge_heartbeat",
|
|
98
|
+
identity_id: IDENTITY_ID,
|
|
99
|
+
host: "CTO — Claude Code",
|
|
100
|
+
mode: "mcp-session",
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("renews the hold on its own — the model is never asked to keep time", async () => {
|
|
105
|
+
await call({});
|
|
106
|
+
expect(calls.upserts).toHaveLength(1);
|
|
107
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
108
|
+
expect(calls.upserts).toHaveLength(2);
|
|
109
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
110
|
+
expect(calls.upserts).toHaveLength(3);
|
|
111
|
+
// Every beat is a fresh timestamp, not a replay of the first one.
|
|
112
|
+
expect(calls.upserts[2].last_seen_at).not.toBe(calls.upserts[0].last_seen_at);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("never keeps a finished session's process alive (timer is unref'ed)", async () => {
|
|
116
|
+
const unref = vi.fn();
|
|
117
|
+
const spy = vi.spyOn(globalThis, "setInterval").mockReturnValue({ unref } as never);
|
|
118
|
+
await call({});
|
|
119
|
+
expect(unref).toHaveBeenCalledOnce();
|
|
120
|
+
spy.mockRestore();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("re-attaching replaces the beat instead of stacking a second one", async () => {
|
|
124
|
+
await call({ label: "first" });
|
|
125
|
+
await call({ label: "second" });
|
|
126
|
+
calls.upserts = [];
|
|
127
|
+
await vi.advanceTimersByTimeAsync(60_000);
|
|
128
|
+
expect(calls.upserts).toHaveLength(1);
|
|
129
|
+
expect(calls.upserts[0].host).toBe("second");
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("release DELETES the row and stops beating — the stand-in resumes at once", async () => {
|
|
133
|
+
await call({});
|
|
134
|
+
const out = await call({ release: true });
|
|
135
|
+
expect(out.attached).toBe(false);
|
|
136
|
+
expect(calls.deletes).toEqual([IDENTITY_ID]);
|
|
137
|
+
calls.upserts = [];
|
|
138
|
+
await vi.advanceTimersByTimeAsync(180_000);
|
|
139
|
+
expect(calls.upserts).toHaveLength(0);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { allTools, createMosaddServer } from "../index.js";
|
|
3
|
-
|
|
4
|
-
describe("@mosadd/mcp", () => {
|
|
5
|
-
describe("allTools registry", () => {
|
|
6
|
-
it("exposes at least the 4 alpha channels", () => {
|
|
7
|
-
const names = allTools.map((t) => t.name);
|
|
8
|
-
// mDM (6 tools)
|
|
9
|
-
expect(names).toContain("mDM_list_contacts");
|
|
10
|
-
expect(names).toContain("mDM_publish_keys");
|
|
11
|
-
expect(names).toContain("mDM_send");
|
|
12
|
-
expect(names).toContain("mDM_send_unencrypted");
|
|
13
|
-
expect(names).toContain("mDM_list");
|
|
14
|
-
expect(names).toContain("mDM_respond_request");
|
|
15
|
-
// mIRC (5 tools)
|
|
16
|
-
expect(names).toContain("mIRC_create");
|
|
17
|
-
expect(names).toContain("mIRC_delete");
|
|
18
|
-
// mURL (revived module) + mAYL (email 3.0, was mp0st) — threat_* re-registered (LINEAR-3498)
|
|
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
|
-
});
|
|
25
|
-
|
|
26
|
-
it("follows RFC 0001 naming — channel tools m<MODULE>_<operation>, meta tools comms_<op>", () => {
|
|
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 (LINEAR-3464)
|
|
29
|
-
const metaName = /^comms_[a-z][a-z0-9_]*$/; // discovery/meta namespace
|
|
30
|
-
const threatName = /^threat_[a-z][a-z0-9_]*$/; // defensive threat engine (LINEAR-3498)
|
|
31
|
-
for (const tool of allTools) {
|
|
32
|
-
expect(tool.name).toMatch(
|
|
33
|
-
new RegExp(`${channelName.source}|${mailName.source}|${metaName.source}|${threatName.source}`),
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("every tool declares a transport requirement (any | radio | network)", () => {
|
|
39
|
-
for (const tool of allTools) {
|
|
40
|
-
expect(["any", "radio", "network"]).toContain(tool.requires);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("every tool ships a description and a Zod schema", () => {
|
|
45
|
-
for (const tool of allTools) {
|
|
46
|
-
expect(typeof tool.description).toBe("string");
|
|
47
|
-
expect(tool.description.length).toBeGreaterThan(20);
|
|
48
|
-
expect(tool.inputSchema).toBeDefined();
|
|
49
|
-
// Zod schemas have _def
|
|
50
|
-
expect((tool.inputSchema as { _def?: unknown })._def).toBeDefined();
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe("createMosaddServer", () => {
|
|
56
|
-
it("constructs without throwing in local mode", () => {
|
|
57
|
-
const server = createMosaddServer({ mode: "local", logLevel: "error" });
|
|
58
|
-
expect(server).toBeDefined();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("defaults to local mode when no apiKey", () => {
|
|
62
|
-
const server = createMosaddServer({ logLevel: "error" });
|
|
63
|
-
expect(server).toBeDefined();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("accepts cloud mode with apiKey", () => {
|
|
67
|
-
const server = createMosaddServer({ apiKey: "test", logLevel: "error" });
|
|
68
|
-
expect(server).toBeDefined();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { allTools, createMosaddServer } from "../index.js";
|
|
3
|
+
|
|
4
|
+
describe("@mosadd/mcp", () => {
|
|
5
|
+
describe("allTools registry", () => {
|
|
6
|
+
it("exposes at least the 4 alpha channels", () => {
|
|
7
|
+
const names = allTools.map((t) => t.name);
|
|
8
|
+
// mDM (6 tools)
|
|
9
|
+
expect(names).toContain("mDM_list_contacts");
|
|
10
|
+
expect(names).toContain("mDM_publish_keys");
|
|
11
|
+
expect(names).toContain("mDM_send");
|
|
12
|
+
expect(names).toContain("mDM_send_unencrypted");
|
|
13
|
+
expect(names).toContain("mDM_list");
|
|
14
|
+
expect(names).toContain("mDM_respond_request");
|
|
15
|
+
// mIRC (5 tools)
|
|
16
|
+
expect(names).toContain("mIRC_create");
|
|
17
|
+
expect(names).toContain("mIRC_delete");
|
|
18
|
+
// mURL (revived module) + mAYL (email 3.0, was mp0st) — threat_* re-registered (LINEAR-3498)
|
|
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
|
+
});
|
|
25
|
+
|
|
26
|
+
it("follows RFC 0001 naming — channel tools m<MODULE>_<operation>, meta tools comms_<op>", () => {
|
|
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 (LINEAR-3464)
|
|
29
|
+
const metaName = /^comms_[a-z][a-z0-9_]*$/; // discovery/meta namespace
|
|
30
|
+
const threatName = /^threat_[a-z][a-z0-9_]*$/; // defensive threat engine (LINEAR-3498)
|
|
31
|
+
for (const tool of allTools) {
|
|
32
|
+
expect(tool.name).toMatch(
|
|
33
|
+
new RegExp(`${channelName.source}|${mailName.source}|${metaName.source}|${threatName.source}`),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("every tool declares a transport requirement (any | radio | network)", () => {
|
|
39
|
+
for (const tool of allTools) {
|
|
40
|
+
expect(["any", "radio", "network"]).toContain(tool.requires);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("every tool ships a description and a Zod schema", () => {
|
|
45
|
+
for (const tool of allTools) {
|
|
46
|
+
expect(typeof tool.description).toBe("string");
|
|
47
|
+
expect(tool.description.length).toBeGreaterThan(20);
|
|
48
|
+
expect(tool.inputSchema).toBeDefined();
|
|
49
|
+
// Zod schemas have _def
|
|
50
|
+
expect((tool.inputSchema as { _def?: unknown })._def).toBeDefined();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("createMosaddServer", () => {
|
|
56
|
+
it("constructs without throwing in local mode", () => {
|
|
57
|
+
const server = createMosaddServer({ mode: "local", logLevel: "error" });
|
|
58
|
+
expect(server).toBeDefined();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("defaults to local mode when no apiKey", () => {
|
|
62
|
+
const server = createMosaddServer({ logLevel: "error" });
|
|
63
|
+
expect(server).toBeDefined();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("accepts cloud mode with apiKey", () => {
|
|
67
|
+
const server = createMosaddServer({ apiKey: "test", logLevel: "error" });
|
|
68
|
+
expect(server).toBeDefined();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|