@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.
Files changed (52) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +11 -11
  3. package/dist/bin/mcp.js +1 -1
  4. package/dist/{chunk-KX34DDJB.js → chunk-IWLN5EO5.js} +614 -134
  5. package/dist/index.js +1 -1
  6. package/package.json +15 -15
  7. package/src/__tests__/golden-path.test.ts +137 -137
  8. package/src/__tests__/integration.test.ts +179 -179
  9. package/src/__tests__/knowledge-ingest.test.ts +114 -0
  10. package/src/__tests__/mdm-e2ee.test.ts +212 -212
  11. package/src/__tests__/mtalk.test.ts +122 -122
  12. package/src/__tests__/presence.test.ts +141 -0
  13. package/src/__tests__/server.test.ts +71 -71
  14. package/src/__tests__/tool-count-consistency.test.ts +121 -1
  15. package/src/bin/login.ts +138 -138
  16. package/src/bin/mcp.ts +145 -145
  17. package/src/config.ts +66 -66
  18. package/src/crypto/mdm-session.ts +502 -502
  19. package/src/index.ts +19 -19
  20. package/src/observability/sentry.ts +79 -79
  21. package/src/providers/blob-upload.ts +116 -116
  22. package/src/providers/memory-voice.ts +79 -79
  23. package/src/providers/supabase-dm.ts +122 -122
  24. package/src/providers/supabase-voice.ts +91 -91
  25. package/src/providers/supabase.ts +148 -148
  26. package/src/tools/actions.ts +162 -162
  27. package/src/tools/attachments.ts +268 -268
  28. package/src/tools/capabilities.ts +68 -68
  29. package/src/tools/embed.ts +108 -108
  30. package/src/tools/index.ts +173 -104
  31. package/src/tools/knowledge-graph.ts +178 -0
  32. package/src/tools/knowledge.ts +319 -191
  33. package/src/tools/mail-agentbox.ts +147 -0
  34. package/src/tools/mail-aliases.ts +25 -25
  35. package/src/tools/mail-provenance.ts +135 -135
  36. package/src/tools/mail.ts +381 -381
  37. package/src/tools/mdm.ts +476 -479
  38. package/src/tools/mirc-edge.ts +190 -190
  39. package/src/tools/mirc-members.ts +2 -2
  40. package/src/tools/mirc-messages.ts +155 -155
  41. package/src/tools/mirc.ts +2 -2
  42. package/src/tools/mroom-messages.ts +142 -142
  43. package/src/tools/mroom.ts +221 -221
  44. package/src/tools/mtalk.ts +121 -121
  45. package/src/tools/murl.ts +4 -2
  46. package/src/tools/presence.ts +208 -0
  47. package/src/types.ts +94 -94
  48. package/src/voice/floor.ts +132 -132
  49. package/LICENSE +0 -201
  50. package/dist/bin/login.d.ts +0 -13
  51. package/dist/bin/mcp.d.ts +0 -1
  52. package/dist/index.d.ts +0 -266
@@ -1,13 +0,0 @@
1
- /**
2
- * `mosadd login` / `logout` / `whoami` — session helper.
3
- *
4
- * Removes the "copy a JWT from mosadd.com DevTools" hack: signs in with
5
- * Supabase email+password (BYOK project URL + anon key) and stores the session
6
- * at ~/.mosadd/session.json, which the MCP server reads automatically.
7
- *
8
- * Credentials resolution (first found wins): CLI flags → env → interactive
9
- * prompt. URL/anon also fall back to a previously saved session.
10
- */
11
- declare function runAuthCommand(cmd: string, args: string[]): Promise<void>;
12
-
13
- export { runAuthCommand };
package/dist/bin/mcp.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
package/dist/index.d.ts DELETED
@@ -1,266 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
- import { DmProvider, VoiceProvider } from '@mosadd/providers';
4
- import { RatchetState, DhRatchetState, SessionRole } from '@mosadd/crypto';
5
-
6
- /**
7
- * mDM end-to-end encryption — session layer (LINEAR-2357).
8
- *
9
- * Sits ABOVE the DmProvider. The provider moves opaque bytes; THIS module
10
- * decides what those bytes are: an X3DH handshake + Double Ratchet ciphertext
11
- * envelope, produced from `@mosadd/crypto` primitives.
12
- *
13
- * Flow (decision "1a" — prekey distribution rides the DmProvider):
14
- * - Each peer publishes a prekey bundle via `dm.publishPrekeyBundle(bytes)`.
15
- * - First contact: sender `dm.fetchPrekeyBundle(peer)` → X3DH (initiator) →
16
- * Double Ratchet. The first ciphertext carries a handshake header
17
- * (initiator IK + EK + consumed one-time-prekey id) so the recipient can
18
- * run X3DH (responder) and derive the SAME root key.
19
- * - Subsequent messages reuse the stored ratchet session (no header).
20
- *
21
- * SCOPE / known follow-ups (tracked on LINEAR-2357, NOT silently hidden):
22
- * - Ratchet is strict in-order (no skipped-message keys) — fine for a single
23
- * ordered thread; out-of-order/lossy transports need skipped-key handling.
24
- * - Signed-prekey signature is carried but NOT yet verified (auth follow-up).
25
- * - Initiator "glare" (both sides open simultaneously) not resolved.
26
- * - Default keystore is in-memory (per-process); file/OS-keychain backing is
27
- * a follow-up. The MdmKeyStore seam makes that a drop-in.
28
- */
29
-
30
- interface X25519Pair {
31
- publicKey: Uint8Array;
32
- privateKey: Uint8Array;
33
- }
34
- /** The local peer's long-term identity + prekeys (private halves included). */
35
- interface OwnPrekeyMaterial {
36
- /** X25519 DH identity — used in X3DH. */
37
- identity: X25519Pair;
38
- /**
39
- * Ed25519 SIGNING identity — the long-term key a peer pins out-of-band
40
- * (the "safety number"). Signs the bundle so a network/radio MITM can't swap
41
- * the signed prekey or DH identity in transit.
42
- */
43
- signingIdentity: {
44
- publicKey: Uint8Array;
45
- privateKey: Uint8Array;
46
- };
47
- signedPrekey: {
48
- id: number;
49
- pair: X25519Pair;
50
- };
51
- oneTimePrekeys: Array<{
52
- id: number;
53
- pair: X25519Pair;
54
- }>;
55
- }
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
- */
61
- interface MdmSessionRecord {
62
- ratchet?: RatchetState;
63
- ratchet2?: DhRatchetState;
64
- role: SessionRole;
65
- /** Handshake header still owed to the peer (initiator only, until first send). */
66
- pendingHandshake?: {
67
- ik: Uint8Array;
68
- ek: Uint8Array;
69
- opkId?: number;
70
- };
71
- }
72
- /**
73
- * Local custody of private key material + ratchet sessions. The default impl
74
- * is in-memory; a host may inject a file- or keychain-backed implementation.
75
- */
76
- interface MdmKeyStore {
77
- /** Own identity + prekeys. Generated lazily on first access, then stable. */
78
- getOwnMaterial(): Promise<OwnPrekeyMaterial>;
79
- /** Consume (one-time) a prekey private by id. Returns undefined if unknown. */
80
- takeOneTimePrekey(id: number): Promise<Uint8Array | undefined>;
81
- getSession(peerId: string): Promise<MdmSessionRecord | undefined>;
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>;
98
- }
99
-
100
- /**
101
- * Internal types for the mosadd MCP server.
102
- */
103
-
104
- type Mode = "cloud" | "local" | "self-host";
105
- /**
106
- * Transport backends per channel. The server fills any missing entry with its
107
- * default network adapter; a host (e.g. cymru-os) injects alternatives —
108
- * notably a radio DmProvider — via `MosaddServerOptions.providers`. This is
109
- * the DI seam that keeps mosadd-os transport-agnostic.
110
- *
111
- * `keys` is LOCAL crypto custody (identity + prekeys + ratchet sessions) for
112
- * mDM E2EE — distinct from transport. Defaults to an in-process keystore; a
113
- * host may inject a file/keychain-backed one.
114
- */
115
- interface ProviderRegistry {
116
- dm: DmProvider;
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;
124
- }
125
- interface MosaddServerOptions {
126
- /** API key for hosted mode. Required if mode === "cloud". */
127
- apiKey?: string;
128
- /** Override the default hub URL (https://mcp.mosadd.com). */
129
- hubUrl?: string;
130
- /** Operating mode. Defaults to "cloud" if apiKey is present, else "local". */
131
- mode?: Mode;
132
- /** Log level. */
133
- logLevel?: "debug" | "info" | "warn" | "error";
134
- /**
135
- * Host-injected channel providers. Any omitted channel uses the default
136
- * network adapter. A carrier-aware host supplies e.g. a radio DmProvider here.
137
- */
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;
148
- }
149
- interface MosaddToolContext {
150
- options: Required<Pick<MosaddServerOptions, "mode" | "hubUrl">> & MosaddServerOptions;
151
- /** Resolved channel providers (defaults merged with host-injected ones). */
152
- providers: ProviderRegistry;
153
- /** Per-request logger. */
154
- log: (level: "debug" | "info" | "warn" | "error", msg: string, extra?: unknown) => void;
155
- }
156
- /**
157
- * Transport capability a tool requires to function. This is the ONE contract
158
- * string shared with consuming hosts. e.g. cymru-os gates tools by carrier
159
- * availability via this flag (cymru-os RFC 0002 D-Bus "Capability-flag bridge").
160
- * The enum is FINAL and normalized with the cymru-os host; changing these
161
- * values must be coordinated (Linear label `requires:cymru-input`).
162
- *
163
- * - "any" works over any transport, incl. off-grid radio (small,
164
- * packet-friendly payloads). e.g. text DM.
165
- * - "radio" radio-specific path (e.g. Codec2 audio frames). Off-grid OK.
166
- * - "network" needs IP connectivity (server-hosted channels, email, public
167
- * join links, bridges). NOT available off-grid.
168
- */
169
- type CapabilityRequirement = "any" | "radio" | "network";
170
- interface MosaddTool<TInput = unknown, TOutput = unknown> {
171
- /** Tool name. MUST follow the m{MODULE}_{operation} convention. */
172
- name: string;
173
- /** Short human-readable description. Shown to the model. */
174
- description: string;
175
- /**
176
- * Transport this tool requires. Consuming hosts read this to gate tools by
177
- * available carriers. Every tool MUST declare it explicitly.
178
- */
179
- requires: CapabilityRequirement;
180
- /** Zod schema for input. */
181
- inputSchema: z.ZodType<TInput>;
182
- /** Tool handler. */
183
- handler: (input: TInput, ctx: MosaddToolContext) => Promise<TOutput>;
184
- }
185
-
186
- /**
187
- * Build a McpServer instance with all mosadd tools registered.
188
- */
189
-
190
- /**
191
- * Resolve the channel ProviderRegistry: default network adapters merged with
192
- * anything the host injects. A carrier-aware host (cymru-os) passes its own
193
- * radio DmProvider via `injected.dm`. This is the single place the default
194
- * adapters are named — both `createMosaddServer` and the `@mosadd/ai` adapters
195
- * build their context through it so they stay in lockstep.
196
- */
197
- declare function defaultProviders(injected?: Partial<ProviderRegistry>): ProviderRegistry;
198
- declare function createMosaddServer(options?: MosaddServerOptions): McpServer;
199
-
200
- /**
201
- * Tool registry. Each m* module contributes a set of tools.
202
- *
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.
236
- */
237
-
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;
265
-
266
- export { type MosaddServerOptions, type MosaddTool, type MosaddToolContext, type ProviderRegistry, type SupabaseEnv, TOOL_COUNT, allTools, createMosaddServer, defaultProviders, runWithSupabaseEnv };