@mosadd/mcp 3.0.0-alpha.0 → 3.0.0-alpha.10
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 +127 -116
- package/dist/bin/login.d.ts +13 -0
- package/dist/bin/login.js +110 -0
- package/dist/bin/mcp.js +36 -1
- package/dist/chunk-6EPYADVR.js +2095 -0
- package/dist/chunk-Z7WR52GE.js +45 -0
- package/dist/index.d.ts +46 -4
- package/dist/index.js +6 -3
- package/package.json +11 -7
- package/src/__tests__/golden-path.test.ts +137 -132
- package/src/__tests__/integration.test.ts +178 -175
- package/src/__tests__/mdm-e2ee.test.ts +178 -149
- package/src/__tests__/mtalk.test.ts +122 -0
- package/src/__tests__/server.test.ts +67 -67
- package/src/bin/login.ts +138 -0
- package/src/bin/mcp.ts +97 -47
- package/src/config.ts +66 -0
- package/src/crypto/mdm-session.ts +403 -378
- package/src/index.ts +19 -17
- package/src/observability/sentry.ts +79 -79
- package/src/providers/memory-voice.ts +79 -0
- package/src/providers/supabase-dm.ts +117 -117
- package/src/providers/supabase-voice.ts +91 -0
- package/src/providers/supabase.ts +49 -9
- package/src/server.ts +105 -103
- package/src/tools/capabilities.ts +68 -68
- package/src/tools/index.ts +53 -37
- package/src/tools/knowledge.ts +191 -0
- package/src/tools/mail.ts +371 -89
- package/src/tools/mcall.ts +216 -0
- package/src/tools/mdm-voice.ts +206 -0
- package/src/tools/mdm.ts +448 -379
- package/src/tools/mirc-edge.ts +190 -0
- package/src/tools/mirc-members.ts +177 -177
- package/src/tools/mirc-messages.ts +156 -0
- package/src/tools/mirc.ts +170 -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 +141 -0
- package/src/types.ts +85 -79
- package/src/voice/floor.ts +132 -0
- package/dist/chunk-25L536JZ.js +0 -1182
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { mkdirSync, readFileSync, writeFileSync, rmSync, existsSync, chmodSync } from "fs";
|
|
5
|
+
function configDir() {
|
|
6
|
+
return join(homedir(), ".mosadd");
|
|
7
|
+
}
|
|
8
|
+
function sessionPath() {
|
|
9
|
+
return join(configDir(), "session.json");
|
|
10
|
+
}
|
|
11
|
+
function loadSession() {
|
|
12
|
+
try {
|
|
13
|
+
const raw = readFileSync(sessionPath(), "utf8");
|
|
14
|
+
const s = JSON.parse(raw);
|
|
15
|
+
if (s && typeof s.url === "string" && typeof s.anonKey === "string") return s;
|
|
16
|
+
return null;
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function saveSession(session) {
|
|
22
|
+
mkdirSync(configDir(), { recursive: true });
|
|
23
|
+
writeFileSync(sessionPath(), JSON.stringify(session, null, 2), "utf8");
|
|
24
|
+
try {
|
|
25
|
+
chmodSync(sessionPath(), 384);
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function clearSession() {
|
|
30
|
+
if (!existsSync(sessionPath())) return false;
|
|
31
|
+
rmSync(sessionPath());
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
function isSessionExpired(session) {
|
|
35
|
+
if (!session.expiresAt) return false;
|
|
36
|
+
return Date.now() / 1e3 >= session.expiresAt - 30;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
sessionPath,
|
|
41
|
+
loadSession,
|
|
42
|
+
saveSession,
|
|
43
|
+
clearSession,
|
|
44
|
+
isSessionExpired
|
|
45
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { DmProvider } from '@mosadd/providers';
|
|
3
|
+
import { DmProvider, VoiceProvider } from '@mosadd/providers';
|
|
4
4
|
import { RatchetState, SessionRole } from '@mosadd/crypto';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -75,6 +75,21 @@ interface MdmKeyStore {
|
|
|
75
75
|
takeOneTimePrekey(id: number): Promise<Uint8Array | undefined>;
|
|
76
76
|
getSession(peerId: string): Promise<MdmSessionRecord | undefined>;
|
|
77
77
|
putSession(peerId: string, record: MdmSessionRecord): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* OPTIONAL local "sent items" cache. The Double Ratchet is forward-secret and
|
|
80
|
+
* asymmetric: once we seal a message for a peer we cannot re-derive its
|
|
81
|
+
* plaintext from our own ratchet on read. So mDM_list cannot show the sender
|
|
82
|
+
* their OWN outgoing text unless we keep a local copy. These two methods are
|
|
83
|
+
* that copy — keyed by the provider-assigned message id.
|
|
84
|
+
*
|
|
85
|
+
* Honesty note: this is a LOCAL plaintext cache, not synced across devices.
|
|
86
|
+
* A second device (or a fresh process) won't have it and will fall back to a
|
|
87
|
+
* "<encrypted · sent by you>" marker. Cross-device sent-history sync is a
|
|
88
|
+
* tracked follow-up (would need an encrypt-to-self session). Optional so
|
|
89
|
+
* existing MdmKeyStore implementations keep compiling.
|
|
90
|
+
*/
|
|
91
|
+
putSentMessage?(messageId: string, plaintext: Uint8Array): Promise<void>;
|
|
92
|
+
getSentMessage?(messageId: string): Promise<Uint8Array | undefined>;
|
|
78
93
|
}
|
|
79
94
|
|
|
80
95
|
/**
|
|
@@ -95,6 +110,12 @@ type Mode = "cloud" | "local" | "self-host";
|
|
|
95
110
|
interface ProviderRegistry {
|
|
96
111
|
dm: DmProvider;
|
|
97
112
|
keys: MdmKeyStore;
|
|
113
|
+
/**
|
|
114
|
+
* mTALK push-to-talk transport. Defaults to the network provider (LiveKit
|
|
115
|
+
* media + authoritative floor state). A radio host injects a provider that
|
|
116
|
+
* maps the floor onto a physical RF channel.
|
|
117
|
+
*/
|
|
118
|
+
voice: VoiceProvider;
|
|
98
119
|
}
|
|
99
120
|
interface MosaddServerOptions {
|
|
100
121
|
/** API key for hosted mode. Required if mode === "cloud". */
|
|
@@ -165,10 +186,31 @@ declare function createMosaddServer(options?: MosaddServerOptions): McpServer;
|
|
|
165
186
|
/**
|
|
166
187
|
* Tool registry. Each m* module contributes a set of tools.
|
|
167
188
|
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
189
|
+
* Live modules (7): mDM, mIRC, mROOM, mTALK, mAIL, mRAG, mURL — 64 tools + comms_capabilities.
|
|
190
|
+
* mCALL is carrier-pending (no telephony carrier live yet): its tools live in
|
|
191
|
+
* tools/mcall.ts but are NOT registered here, so an agent only ever discovers
|
|
192
|
+
* tools that actually work. Re-register the one line below when a carrier ships.
|
|
170
193
|
*/
|
|
171
194
|
|
|
172
195
|
declare const allTools: MosaddTool[];
|
|
173
196
|
|
|
174
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Supabase provider for the alpha MCP server.
|
|
199
|
+
*
|
|
200
|
+
* Local BYOK mode: user supplies their own Supabase URL + anon key + user JWT
|
|
201
|
+
* via env vars. The MCP server creates a per-request Supabase client and
|
|
202
|
+
* invokes the mosadd Edge Functions on the user's behalf.
|
|
203
|
+
*
|
|
204
|
+
* In Phase 2 this is replaced by the hosted gateway (mcp.mosadd.com) which
|
|
205
|
+
* holds keys server-side via the BYOK broker.
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
interface SupabaseEnv {
|
|
209
|
+
url: string;
|
|
210
|
+
anonKey: string;
|
|
211
|
+
userJwt?: string;
|
|
212
|
+
}
|
|
213
|
+
/** Run `fn` (and every tool call it triggers) with a per-request Supabase session. */
|
|
214
|
+
declare function runWithSupabaseEnv<T>(env: SupabaseEnv, fn: () => T): T;
|
|
215
|
+
|
|
216
|
+
export { type MosaddServerOptions, type MosaddTool, type MosaddToolContext, type ProviderRegistry, type SupabaseEnv, allTools, createMosaddServer, defaultProviders, runWithSupabaseEnv };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
allTools,
|
|
3
3
|
createMosaddServer,
|
|
4
|
-
defaultProviders
|
|
5
|
-
|
|
4
|
+
defaultProviders,
|
|
5
|
+
runWithSupabaseEnv
|
|
6
|
+
} from "./chunk-6EPYADVR.js";
|
|
7
|
+
import "./chunk-Z7WR52GE.js";
|
|
6
8
|
export {
|
|
7
9
|
allTools,
|
|
8
10
|
createMosaddServer,
|
|
9
|
-
defaultProviders
|
|
11
|
+
defaultProviders,
|
|
12
|
+
runWithSupabaseEnv
|
|
10
13
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosadd/mcp",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
4
|
-
"description": "Model Context Protocol server for mosadd. Exposes m*
|
|
3
|
+
"version": "3.0.0-alpha.10",
|
|
4
|
+
"description": "Model Context Protocol server for mosadd. Exposes the 7 live m* modules (mDM, mIRC, mROOM, mTALK, mAIL, mRAG, mURL) — 64 tools — to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
|
|
5
5
|
"homepage": "https://github.com/Hei33enberg/mosadd-os/tree/main/packages/mcp",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"bin": {
|
|
23
|
-
"mosadd-mcp": "./dist/bin/mcp.js"
|
|
23
|
+
"mosadd-mcp": "./dist/bin/mcp.js",
|
|
24
|
+
"mosadd": "./dist/bin/mcp.js"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
26
27
|
"dist",
|
|
@@ -35,9 +36,9 @@
|
|
|
35
36
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
36
37
|
"@supabase/supabase-js": "^2.48.0",
|
|
37
38
|
"zod": "^4.3.6",
|
|
38
|
-
"@mosadd/crypto": "3.0.0-alpha.
|
|
39
|
-
"@mosadd/
|
|
40
|
-
"@mosadd/
|
|
39
|
+
"@mosadd/crypto": "3.0.0-alpha.4",
|
|
40
|
+
"@mosadd/protocol": "3.0.0-alpha.4",
|
|
41
|
+
"@mosadd/providers": "3.0.0-alpha.4"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"tsup": "^8.3.5",
|
|
@@ -56,8 +57,11 @@
|
|
|
56
57
|
"communication",
|
|
57
58
|
"messaging"
|
|
58
59
|
],
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18"
|
|
62
|
+
},
|
|
59
63
|
"scripts": {
|
|
60
|
-
"build": "tsup src/index.ts src/bin/mcp.ts --format esm --dts --clean --shims",
|
|
64
|
+
"build": "tsup src/index.ts src/bin/mcp.ts src/bin/login.ts --format esm --dts --clean --shims",
|
|
61
65
|
"dev": "tsx src/bin/mcp.ts",
|
|
62
66
|
"test": "vitest run",
|
|
63
67
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
@@ -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
|
+
});
|