@mosadd/mcp 3.0.0-alpha.3 → 3.0.0-alpha.30
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 +212 -0
- package/README.md +150 -116
- package/dist/bin/mcp.js +42 -3
- package/dist/chunk-6PGDNIKR.js +2556 -0
- package/dist/index.d.ts +99 -7
- package/dist/index.js +7 -3
- package/package.json +10 -7
- package/src/__tests__/golden-path.test.ts +137 -132
- package/src/__tests__/integration.test.ts +179 -175
- package/src/__tests__/mdm-e2ee.test.ts +212 -149
- package/src/__tests__/mtalk.test.ts +122 -0
- package/src/__tests__/server.test.ts +71 -67
- package/src/bin/login.ts +138 -138
- package/src/bin/mcp.ts +145 -97
- package/src/config.ts +66 -66
- package/src/crypto/mdm-session.ts +502 -378
- package/src/index.ts +19 -17
- package/src/observability/sentry.ts +79 -79
- package/src/providers/blob-upload.ts +116 -0
- package/src/providers/memory-voice.ts +79 -0
- package/src/providers/supabase-dm.ts +122 -117
- package/src/providers/supabase-voice.ts +91 -0
- package/src/providers/supabase.ts +148 -96
- package/src/server.ts +123 -103
- package/src/tools/actions.ts +162 -0
- package/src/tools/attachments.ts +268 -0
- package/src/tools/capabilities.ts +68 -68
- package/src/tools/embed.ts +108 -0
- package/src/tools/index.ts +104 -37
- package/src/tools/knowledge.ts +191 -0
- package/src/tools/mail-aliases.ts +25 -0
- package/src/tools/mail-provenance.ts +135 -0
- package/src/tools/mail.ts +381 -89
- package/src/tools/mcall.ts +216 -0
- package/src/tools/mdm-voice.ts +212 -0
- package/src/tools/mdm.ts +479 -379
- package/src/tools/mirc-edge.ts +190 -0
- package/src/tools/mirc-members.ts +198 -177
- package/src/tools/mirc-messages.ts +155 -0
- package/src/tools/mirc.ts +190 -170
- package/src/tools/mroom-messages.ts +142 -142
- package/src/tools/mroom.ts +221 -189
- package/src/tools/mtalk.ts +121 -0
- package/src/tools/murl.ts +298 -0
- package/src/tools/ptt-ingest.ts +97 -0
- package/src/tools/threat.ts +119 -0
- package/src/types.ts +94 -79
- package/src/voice/floor.ts +132 -0
- package/dist/chunk-HD5RLE5K.js +0 -1193
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { DmProvider } from '@mosadd/providers';
|
|
4
|
-
import { RatchetState, SessionRole } from '@mosadd/crypto';
|
|
3
|
+
import { DmProvider, VoiceProvider } from '@mosadd/providers';
|
|
4
|
+
import { RatchetState, DhRatchetState, SessionRole } from '@mosadd/crypto';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* mDM end-to-end encryption — session layer (LINEAR-2357).
|
|
@@ -53,9 +53,14 @@ interface OwnPrekeyMaterial {
|
|
|
53
53
|
pair: X25519Pair;
|
|
54
54
|
}>;
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Persisted per-peer ratchet session. Plain data → trivially serializable.
|
|
58
|
+
* A session is either v1 (`ratchet`, symmetric) or v2 (`ratchet2`, DH ratchet /
|
|
59
|
+
* PCS). New sessions are v2; an existing v1 session keeps running v1.
|
|
60
|
+
*/
|
|
57
61
|
interface MdmSessionRecord {
|
|
58
|
-
ratchet
|
|
62
|
+
ratchet?: RatchetState;
|
|
63
|
+
ratchet2?: DhRatchetState;
|
|
59
64
|
role: SessionRole;
|
|
60
65
|
/** Handshake header still owed to the peer (initiator only, until first send). */
|
|
61
66
|
pendingHandshake?: {
|
|
@@ -75,6 +80,21 @@ interface MdmKeyStore {
|
|
|
75
80
|
takeOneTimePrekey(id: number): Promise<Uint8Array | undefined>;
|
|
76
81
|
getSession(peerId: string): Promise<MdmSessionRecord | undefined>;
|
|
77
82
|
putSession(peerId: string, record: MdmSessionRecord): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* OPTIONAL local "sent items" cache. The Double Ratchet is forward-secret and
|
|
85
|
+
* asymmetric: once we seal a message for a peer we cannot re-derive its
|
|
86
|
+
* plaintext from our own ratchet on read. So mDM_list cannot show the sender
|
|
87
|
+
* their OWN outgoing text unless we keep a local copy. These two methods are
|
|
88
|
+
* that copy — keyed by the provider-assigned message id.
|
|
89
|
+
*
|
|
90
|
+
* Honesty note: this is a LOCAL plaintext cache, not synced across devices.
|
|
91
|
+
* A second device (or a fresh process) won't have it and will fall back to a
|
|
92
|
+
* "<encrypted · sent by you>" marker. Cross-device sent-history sync is a
|
|
93
|
+
* tracked follow-up (would need an encrypt-to-self session). Optional so
|
|
94
|
+
* existing MdmKeyStore implementations keep compiling.
|
|
95
|
+
*/
|
|
96
|
+
putSentMessage?(messageId: string, plaintext: Uint8Array): Promise<void>;
|
|
97
|
+
getSentMessage?(messageId: string): Promise<Uint8Array | undefined>;
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
/**
|
|
@@ -95,6 +115,12 @@ type Mode = "cloud" | "local" | "self-host";
|
|
|
95
115
|
interface ProviderRegistry {
|
|
96
116
|
dm: DmProvider;
|
|
97
117
|
keys: MdmKeyStore;
|
|
118
|
+
/**
|
|
119
|
+
* mTALK push-to-talk transport. Defaults to the network provider (LiveKit
|
|
120
|
+
* media + authoritative floor state). A radio host injects a provider that
|
|
121
|
+
* maps the floor onto a physical RF channel.
|
|
122
|
+
*/
|
|
123
|
+
voice: VoiceProvider;
|
|
98
124
|
}
|
|
99
125
|
interface MosaddServerOptions {
|
|
100
126
|
/** API key for hosted mode. Required if mode === "cloud". */
|
|
@@ -110,6 +136,15 @@ interface MosaddServerOptions {
|
|
|
110
136
|
* network adapter. A carrier-aware host supplies e.g. a radio DmProvider here.
|
|
111
137
|
*/
|
|
112
138
|
providers?: Partial<ProviderRegistry>;
|
|
139
|
+
/**
|
|
140
|
+
* When true, publish this identity's mDM prekey bundle once on startup
|
|
141
|
+
* (best-effort, non-fatal) so peers can open an E2EE session without the user
|
|
142
|
+
* manually running mDM_publish_keys first. Fixes the cold-start where mDM_send
|
|
143
|
+
* fails for every recipient because nobody has published keys. Used by the
|
|
144
|
+
* stdio binary; the hosted per-request transport leaves this off (it publishes
|
|
145
|
+
* per authenticated session instead).
|
|
146
|
+
*/
|
|
147
|
+
autoPublishKeys?: boolean;
|
|
113
148
|
}
|
|
114
149
|
interface MosaddToolContext {
|
|
115
150
|
options: Required<Pick<MosaddServerOptions, "mode" | "hubUrl">> & MosaddServerOptions;
|
|
@@ -165,10 +200,67 @@ declare function createMosaddServer(options?: MosaddServerOptions): McpServer;
|
|
|
165
200
|
/**
|
|
166
201
|
* Tool registry. Each m* module contributes a set of tools.
|
|
167
202
|
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
203
|
+
* User-facing modules (4): mDM, mIRC, mURL, mAYL — the re-arch (LINEAR-3938)
|
|
204
|
+
* mAYL replaces the old mp0st name (mp0st_* still registered as back-compat
|
|
205
|
+
* aliases via mail-aliases.ts; will be removed in a later alpha).
|
|
206
|
+
*
|
|
207
|
+
* Capabilities (not modules — cross-cutting agent tooling): mRAG, comms_.
|
|
208
|
+
* mTALK = voice tier inside mIRC, still its own tools for now; folding into
|
|
209
|
+
* mIRC_voice_* in a follow-up release. threat_* (threat_catalog + threat_classify)
|
|
210
|
+
* are REGISTERED (2026-07-15, founder directive + LINEAR-3498): pure/offline
|
|
211
|
+
* defensive classification over the threat taxonomy — the surveillance-era
|
|
212
|
+
* *marketing* was killed, the classification engine is real and wanted.
|
|
213
|
+
*
|
|
214
|
+
* 69 callable tools registered — the exact live count is exported as TOOL_COUNT
|
|
215
|
+
* (= allTools.length) below; ALWAYS reference that, never re-hard-code a number that drifts.
|
|
216
|
+
* Breakdown (2026-07-17): mDM 14 · mIRC 22 · mAYL 11 · mURL 7 · mTALK 5 · mRAG 4 ·
|
|
217
|
+
* comms 3 (action_create/frame_get/embed_create) · Irondome/threat 2 + comms_capabilities
|
|
218
|
+
* discovery 1 = 69. (mDM/mIRC each include their 2 attachment tools from attachments.ts.)
|
|
219
|
+
* Modules (4): mDM, mIRC, mURL, mAYL. Capabilities: mTALK (voice/PTT), mRAG, comms_, Irondome (threat_*).
|
|
220
|
+
* mp0st_* stay as DEPRECATED back-compat aliases for mAYL_* (removed in a later alpha).
|
|
221
|
+
* UNREGISTERED 2026-07-14 (broken scaffolds whose EFs 404/400 every call — re-register when
|
|
222
|
+
* live): mAYL_send_as_agent (mail-provenance), mTALK_ingest_ptt (ptt-ingest).
|
|
223
|
+
* comms_embed_create RE-REGISTERED 2026-07-17 (embed.mosadd.com/v1.js live — P3 of mURL→mIRC).
|
|
224
|
+
* mROOM was KILLED (LINEAR-3414, channel re-cut → ephemeral private mIRC): its tools
|
|
225
|
+
* live in tools/mroom.ts + mroom-messages.ts but are NOT registered here.
|
|
226
|
+
* Plus action links: comms_action_create (agent → user one-link browser action,
|
|
227
|
+
* incl. screen_share) + comms_action_frame_get (see the recipient's shared screen).
|
|
228
|
+
* mURL is a FULL registered dev module (revived, founder 2026-06-27) — IRC-for-URLs,
|
|
229
|
+
* agent-native; backends live (mosadd-edge + murl-channels EF). tools/murl.ts.
|
|
230
|
+
* mURL now has full lifecycle: read/post/presence/list_channels (hub-key) PLUS owner-side
|
|
231
|
+
* create/claim + update(branding/status) + delete (mURL_create/update/delete → murl-manage
|
|
232
|
+
* EF, owner-scoped via user JWT — same auth as mURL_list_channels action='mine').
|
|
233
|
+
* mCALL is carrier-pending (no telephony carrier live yet): its tools live in
|
|
234
|
+
* tools/mcall.ts but are NOT registered here, so an agent only ever discovers
|
|
235
|
+
* tools that actually work. Re-register the one line below when a carrier ships.
|
|
170
236
|
*/
|
|
171
237
|
|
|
172
238
|
declare const allTools: MosaddTool[];
|
|
239
|
+
/**
|
|
240
|
+
* The exact, live number of callable tools this server registers. Reference THIS
|
|
241
|
+
* (import { TOOL_COUNT }) in any code/doc surface that shows a tool count, instead
|
|
242
|
+
* of hard-coding a number that silently drifts (the "70+/65/68" inconsistency that
|
|
243
|
+
* bit us). Mirrors @mosadd/threat-engine's THREAT_EVENT_COUNT pattern.
|
|
244
|
+
*/
|
|
245
|
+
declare const TOOL_COUNT: number;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Supabase provider for the alpha MCP server.
|
|
249
|
+
*
|
|
250
|
+
* Local BYOK mode: user supplies their own Supabase URL + anon key + user JWT
|
|
251
|
+
* via env vars. The MCP server creates a per-request Supabase client and
|
|
252
|
+
* invokes the mosadd Edge Functions on the user's behalf.
|
|
253
|
+
*
|
|
254
|
+
* In Phase 2 this is replaced by the hosted gateway (mcp.mosadd.com) which
|
|
255
|
+
* holds keys server-side via the BYOK broker.
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
interface SupabaseEnv {
|
|
259
|
+
url: string;
|
|
260
|
+
anonKey: string;
|
|
261
|
+
userJwt?: string;
|
|
262
|
+
}
|
|
263
|
+
/** Run `fn` (and every tool call it triggers) with a per-request Supabase session. */
|
|
264
|
+
declare function runWithSupabaseEnv<T>(env: SupabaseEnv, fn: () => T): T;
|
|
173
265
|
|
|
174
|
-
export { type MosaddServerOptions, type MosaddTool, type MosaddToolContext, type ProviderRegistry, allTools, createMosaddServer, defaultProviders };
|
|
266
|
+
export { type MosaddServerOptions, type MosaddTool, type MosaddToolContext, type ProviderRegistry, type SupabaseEnv, TOOL_COUNT, allTools, createMosaddServer, defaultProviders, runWithSupabaseEnv };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
TOOL_COUNT,
|
|
2
3
|
allTools,
|
|
3
4
|
createMosaddServer,
|
|
4
|
-
defaultProviders
|
|
5
|
-
|
|
5
|
+
defaultProviders,
|
|
6
|
+
runWithSupabaseEnv
|
|
7
|
+
} from "./chunk-6PGDNIKR.js";
|
|
6
8
|
import "./chunk-Z7WR52GE.js";
|
|
7
9
|
export {
|
|
10
|
+
TOOL_COUNT,
|
|
8
11
|
allTools,
|
|
9
12
|
createMosaddServer,
|
|
10
|
-
defaultProviders
|
|
13
|
+
defaultProviders,
|
|
14
|
+
runWithSupabaseEnv
|
|
11
15
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosadd/mcp",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "3.0.0-alpha.30",
|
|
4
|
+
"mcpName": "io.github.hei33enberg/mosadd-mcp",
|
|
5
|
+
"description": "Model Context Protocol server for mosadd. Exposes 4 modules (mDM, mIRC, mURL, mAYL) and capabilities (mTALK, mRAG) plus comms agent-actions — 69 tools — to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
|
|
6
|
+
"homepage": "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/Hei33enberg/
|
|
9
|
+
"url": "https://github.com/Hei33enberg/mosADD-OS.git",
|
|
9
10
|
"directory": "packages/mcp"
|
|
10
11
|
},
|
|
11
12
|
"license": "Apache-2.0",
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"dist",
|
|
28
29
|
"src",
|
|
29
30
|
"README.md",
|
|
31
|
+
"CHANGELOG.md",
|
|
30
32
|
"LICENSE"
|
|
31
33
|
],
|
|
32
34
|
"publishConfig": {
|
|
@@ -36,9 +38,10 @@
|
|
|
36
38
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
37
39
|
"@supabase/supabase-js": "^2.48.0",
|
|
38
40
|
"zod": "^4.3.6",
|
|
39
|
-
"@mosadd/crypto": "3.0.0-alpha.
|
|
40
|
-
"@mosadd/providers": "3.0.0-alpha.
|
|
41
|
-
"@mosadd/protocol": "3.0.0-alpha.
|
|
41
|
+
"@mosadd/crypto": "3.0.0-alpha.26",
|
|
42
|
+
"@mosadd/providers": "3.0.0-alpha.26",
|
|
43
|
+
"@mosadd/protocol": "3.0.0-alpha.26",
|
|
44
|
+
"@mosadd/threat-engine": "3.0.0-alpha.26"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
47
|
"tsup": "^8.3.5",
|
|
@@ -1,132 +1,137 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Golden-path E2E: the day-1 "done" bar for the provider-abstraction seam.
|
|
3
|
-
*
|
|
4
|
-
* Proves a carrier-aware HOST (e.g. cymru-os) can inject its own transport
|
|
5
|
-
* under mDM without mosadd-os knowing anything about that transport:
|
|
6
|
-
* 1. host learns capabilities (comms_capabilities) and sees mDM_send = "any"
|
|
7
|
-
* (usable off-grid over radio),
|
|
8
|
-
* 2. host injects a fake RadioProvider,
|
|
9
|
-
* 3. agent calls mDM_send,
|
|
10
|
-
* 4. the opaque payload bytes actually arrive at the injected provider,
|
|
11
|
-
* 5. they round-trip back out via mDM_list.
|
|
12
|
-
*
|
|
13
|
-
* This is the "is it sp, not just written" check the whole 2144 task hinges on.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { describe, expect, it } from "vitest";
|
|
17
|
-
import type {
|
|
18
|
-
DmProvider,
|
|
19
|
-
DmSendArgs,
|
|
20
|
-
DmListArgs,
|
|
21
|
-
DmSendResult,
|
|
22
|
-
DmListResult,
|
|
23
|
-
} from "@mosadd/providers";
|
|
24
|
-
import { mdmTools } from "../tools/mdm.js";
|
|
25
|
-
import { makeCapabilitiesTool } from "../tools/capabilities.js";
|
|
26
|
-
import { allTools } from "../tools/index.js";
|
|
27
|
-
import { createMosaddServer } from "../server.js";
|
|
28
|
-
import { InMemoryMdmKeyStore } from "../crypto/mdm-session.js";
|
|
29
|
-
import
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
expect(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Golden-path E2E: the day-1 "done" bar for the provider-abstraction seam.
|
|
3
|
+
*
|
|
4
|
+
* Proves a carrier-aware HOST (e.g. cymru-os) can inject its own transport
|
|
5
|
+
* under mDM without mosadd-os knowing anything about that transport:
|
|
6
|
+
* 1. host learns capabilities (comms_capabilities) and sees mDM_send = "any"
|
|
7
|
+
* (usable off-grid over radio),
|
|
8
|
+
* 2. host injects a fake RadioProvider,
|
|
9
|
+
* 3. agent calls mDM_send,
|
|
10
|
+
* 4. the opaque payload bytes actually arrive at the injected provider,
|
|
11
|
+
* 5. they round-trip back out via mDM_list.
|
|
12
|
+
*
|
|
13
|
+
* This is the "is it sp, not just written" check the whole 2144 task hinges on.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, expect, it } from "vitest";
|
|
17
|
+
import type {
|
|
18
|
+
DmProvider,
|
|
19
|
+
DmSendArgs,
|
|
20
|
+
DmListArgs,
|
|
21
|
+
DmSendResult,
|
|
22
|
+
DmListResult,
|
|
23
|
+
} from "@mosadd/providers";
|
|
24
|
+
import { mdmTools } from "../tools/mdm.js";
|
|
25
|
+
import { makeCapabilitiesTool } from "../tools/capabilities.js";
|
|
26
|
+
import { allTools } from "../tools/index.js";
|
|
27
|
+
import { createMosaddServer } from "../server.js";
|
|
28
|
+
import { InMemoryMdmKeyStore } from "../crypto/mdm-session.js";
|
|
29
|
+
import { InMemoryVoiceProvider } from "../providers/memory-voice.js";
|
|
30
|
+
import type { MosaddToolContext, ProviderRegistry } from "../types.js";
|
|
31
|
+
|
|
32
|
+
/** Stand-in for a host-supplied radio transport: captures the bytes it's asked
|
|
33
|
+
* to send, and replays them on list — i.e. "the message reached the link". */
|
|
34
|
+
class FakeRadioDmProvider implements DmProvider {
|
|
35
|
+
public readonly sent: DmSendArgs[] = [];
|
|
36
|
+
private bundle: Uint8Array | null = null;
|
|
37
|
+
async selfId(): Promise<string> {
|
|
38
|
+
return "radio:self-callsign";
|
|
39
|
+
}
|
|
40
|
+
async send(args: DmSendArgs): Promise<DmSendResult> {
|
|
41
|
+
this.sent.push(args);
|
|
42
|
+
return { id: `radio-${this.sent.length}`, deliveredAt: new Date(0).toISOString() };
|
|
43
|
+
}
|
|
44
|
+
async list(args: DmListArgs): Promise<DmListResult> {
|
|
45
|
+
return {
|
|
46
|
+
messages: this.sent
|
|
47
|
+
.filter((s) => s.threadId === args.threadId)
|
|
48
|
+
.map((s, i) => ({
|
|
49
|
+
id: `radio-${i + 1}`,
|
|
50
|
+
senderId: "radio:self-callsign",
|
|
51
|
+
payload: s.payload,
|
|
52
|
+
timestamp: new Date(0).toISOString(),
|
|
53
|
+
threadId: s.threadId,
|
|
54
|
+
})),
|
|
55
|
+
nextCursor: null,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async publishPrekeyBundle(bundle: Uint8Array): Promise<void> {
|
|
59
|
+
this.bundle = bundle;
|
|
60
|
+
}
|
|
61
|
+
async fetchPrekeyBundle(): Promise<Uint8Array | null> {
|
|
62
|
+
return this.bundle;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function makeCtx(providers: { dm: DmProvider; keys?: ProviderRegistry["keys"] }): MosaddToolContext {
|
|
67
|
+
return {
|
|
68
|
+
options: { mode: "local", hubUrl: "https://mcp.mosadd.com" },
|
|
69
|
+
providers: {
|
|
70
|
+
dm: providers.dm,
|
|
71
|
+
keys: providers.keys ?? new InMemoryMdmKeyStore(),
|
|
72
|
+
voice: new InMemoryVoiceProvider("radio:self-callsign"),
|
|
73
|
+
},
|
|
74
|
+
log: () => {},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const getTool = (name: string) => {
|
|
79
|
+
const t = mdmTools.find((x) => x.name === name);
|
|
80
|
+
if (!t) throw new Error(`tool ${name} not found`);
|
|
81
|
+
return t;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
describe("golden path — host injects transport under mDM", () => {
|
|
85
|
+
it("step 1: comms_capabilities reports mDM_send usable over any carrier", async () => {
|
|
86
|
+
const capTool = makeCapabilitiesTool(allTools);
|
|
87
|
+
const manifest = (await capTool.handler({}, makeCtx({ dm: new FakeRadioDmProvider() }))) as {
|
|
88
|
+
by_requirement: Record<string, string[]>;
|
|
89
|
+
};
|
|
90
|
+
expect(manifest.by_requirement.any).toContain("mDM_send");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("steps 2-4: the deprecated plaintext path delivers opaque bytes to the injected provider", async () => {
|
|
94
|
+
// This proves the TRANSPORT seam (2144): mDM_send_unencrypted packs a
|
|
95
|
+
// plaintext envelope and the bytes reach the injected provider verbatim.
|
|
96
|
+
// (mDM_send is now E2EE — its own round-trip is covered in mdm-e2ee.test.ts.)
|
|
97
|
+
const radio = new FakeRadioDmProvider();
|
|
98
|
+
const ctx = makeCtx({ dm: radio });
|
|
99
|
+
|
|
100
|
+
const send = getTool("mDM_send_unencrypted");
|
|
101
|
+
const result = (await send.handler(
|
|
102
|
+
{ to: "bob-callsign", text: "rendezvous at grid 4471, 0600" },
|
|
103
|
+
ctx,
|
|
104
|
+
)) as { message_id: string; thread_id: string };
|
|
105
|
+
|
|
106
|
+
// The bytes actually reached the transport.
|
|
107
|
+
expect(radio.sent).toHaveLength(1);
|
|
108
|
+
expect(radio.sent[0]!.to).toBe("bob-callsign");
|
|
109
|
+
expect(radio.sent[0]!.payload).toBeInstanceOf(Uint8Array);
|
|
110
|
+
expect(radio.sent[0]!.payload.byteLength).toBeGreaterThan(0);
|
|
111
|
+
expect(result.message_id).toBe("radio-1");
|
|
112
|
+
|
|
113
|
+
// The payload is opaque to the provider but carries our text under the hood.
|
|
114
|
+
const decoded = JSON.parse(Buffer.from(radio.sent[0]!.payload).toString("utf8"));
|
|
115
|
+
expect(decoded.text).toBe("rendezvous at grid 4471, 0600");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("step 5: mDM_list round-trips the message back through the same provider", async () => {
|
|
119
|
+
const radio = new FakeRadioDmProvider();
|
|
120
|
+
const ctx = makeCtx({ dm: radio });
|
|
121
|
+
|
|
122
|
+
await getTool("mDM_send_unencrypted").handler({ to: "bob-callsign", text: "ack" }, ctx);
|
|
123
|
+
const listed = (await getTool("mDM_list").handler({ contact_id: "bob-callsign" }, ctx)) as {
|
|
124
|
+
messages: Array<{ text: string }>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
expect(listed.messages).toHaveLength(1);
|
|
128
|
+
expect(listed.messages[0]!.text).toBe("ack");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("default server wires a DmProvider without a host override (no throw)", () => {
|
|
132
|
+
// Network default path: constructing the server must not require a host to
|
|
133
|
+
// inject anything (it falls back to the Supabase adapter).
|
|
134
|
+
expect(() => createMosaddServer()).not.toThrow();
|
|
135
|
+
expect(() => createMosaddServer({ providers: { dm: new FakeRadioDmProvider() } })).not.toThrow();
|
|
136
|
+
});
|
|
137
|
+
});
|