@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.
Files changed (68) hide show
  1. package/CHANGELOG.md +415 -0
  2. package/LICENSE +21 -201
  3. package/README.md +79 -40
  4. package/dist/bin/mcp.js +132 -8
  5. package/dist/chunk-J2S44U5R.js +4258 -0
  6. package/dist/index.d.ts +112 -8
  7. package/dist/index.js +3 -1
  8. package/package.json +19 -16
  9. package/src/__tests__/blob-upload.test.ts +93 -0
  10. package/src/__tests__/channel-e2ee.test.ts +62 -0
  11. package/src/__tests__/cli.test.ts +47 -0
  12. package/src/__tests__/fleet-plaintext.test.ts +243 -0
  13. package/src/__tests__/golden-path.test.ts +4 -2
  14. package/src/__tests__/integration.test.ts +50 -11
  15. package/src/__tests__/knowledge-ingest.test.ts +114 -0
  16. package/src/__tests__/label-room-owner.test.ts +22 -0
  17. package/src/__tests__/mdm-e2ee.test.ts +36 -2
  18. package/src/__tests__/mdm-mcp-readable.test.ts +390 -0
  19. package/src/__tests__/mirc-invite.test.ts +112 -0
  20. package/src/__tests__/mirc-voice.test.ts +82 -0
  21. package/src/__tests__/mrag-search-answer.test.ts +42 -0
  22. package/src/__tests__/mrag-search-diagnostics.test.ts +78 -0
  23. package/src/__tests__/no-dead-host.test.ts +37 -0
  24. package/src/__tests__/presence.test.ts +199 -0
  25. package/src/__tests__/server.test.ts +11 -7
  26. package/src/__tests__/serverJsonVersion.test.ts +45 -0
  27. package/src/__tests__/tool-count-consistency.test.ts +259 -0
  28. package/src/__tests__/voice-fields.test.ts +24 -0
  29. package/src/bin/mcp.ts +71 -6
  30. package/src/cli.ts +100 -0
  31. package/src/crypto/channel-e2ee.ts +288 -0
  32. package/src/crypto/mdm-session.ts +479 -40
  33. package/src/index.ts +2 -2
  34. package/src/providers/blob-upload.ts +162 -0
  35. package/src/providers/supabase-dm.ts +102 -7
  36. package/src/providers/supabase-voice.ts +13 -1
  37. package/src/providers/supabase.ts +121 -10
  38. package/src/server.ts +102 -12
  39. package/src/tools/__tests__/ragDeleteFoldsSourceId.test.ts +67 -0
  40. package/src/tools/actions.ts +166 -0
  41. package/src/tools/attachments.ts +276 -0
  42. package/src/tools/capabilities.ts +2 -0
  43. package/src/tools/channel-payload.ts +69 -0
  44. package/src/tools/embed.ts +110 -0
  45. package/src/tools/index.ts +136 -6
  46. package/src/tools/knowledge-graph.ts +186 -0
  47. package/src/tools/knowledge.ts +205 -12
  48. package/src/tools/mail-agentbox.ts +155 -0
  49. package/src/tools/mail-aliases.ts +25 -0
  50. package/src/tools/mail-provenance.ts +137 -0
  51. package/src/tools/mail.ts +214 -60
  52. package/src/tools/mdm-as-agent.ts +137 -0
  53. package/src/tools/mdm-voice.ts +17 -3
  54. package/src/tools/mdm.ts +306 -58
  55. package/src/tools/mirc-edge.ts +12 -6
  56. package/src/tools/mirc-members.ts +130 -20
  57. package/src/tools/mirc-messages.ts +109 -40
  58. package/src/tools/mirc.ts +149 -11
  59. package/src/tools/mroom-messages.ts +5 -13
  60. package/src/tools/mtalk.ts +11 -1
  61. package/src/tools/murl.ts +314 -0
  62. package/src/tools/presence.ts +442 -0
  63. package/src/tools/ptt-ingest.ts +99 -0
  64. package/src/tools/threat.ts +123 -0
  65. package/src/tools/voice-format.ts +66 -0
  66. package/src/types.ts +36 -0
  67. package/src/version.ts +8 -0
  68. package/dist/chunk-EFTB743G.js +0 -1924
@@ -0,0 +1,66 @@
1
+ /**
2
+ * voice-format — W4 (owner decision 16.09): a voice message to an agent should read like a note,
3
+ * not like 500 KB of base64 in the text field.
4
+ *
5
+ * Voice/PTT messages (message_type "voice"/"ptt") carry a payload shaped
6
+ * { audio, mime, dur } (base64 webm/mp4). Until then mDM_list/mIRC_list_messages
7
+ * returned that raw JSON as text — the agent saw garbage instead of a recording.
8
+ * Now it gets a short marker with the duration. The audio stays in the payload;
9
+ * whoever wants to listen uses a voice tool (mDM_voice_note / transcription).
10
+ */
11
+ export function formatVoiceIfAny(text: string): string {
12
+ try {
13
+ const obj = JSON.parse(text) as unknown;
14
+ if (
15
+ obj &&
16
+ typeof obj === "object" &&
17
+ typeof (obj as { audio?: unknown }).audio === "string" &&
18
+ (obj as { audio: string }).audio.length > 1000 &&
19
+ typeof (obj as { dur?: unknown }).dur === "number"
20
+ ) {
21
+ const s = Math.max(1, Math.round((obj as { dur: number }).dur / 1000));
22
+ return `[voice note — ${s}s]`;
23
+ }
24
+ } catch {
25
+ // nie JSON — zwykły tekst, zwróć bez zmian
26
+ }
27
+ return text;
28
+ }
29
+
30
+ /**
31
+ * 15.11.2026 — głosówka niesie transkrypt i adres nagrania. message-list (mosADD) dokłada do
32
+ * wiadomości voice/ptt pola transcript / audio_url / duration_ms (RLS czytającego); tu
33
+ * przekazujemy je odbiorcy jako `voice`. Wcześniej agent widział sam podpis.
34
+ */
35
+ export function voiceFields(m: {
36
+ messageType?: string;
37
+ transcript?: string | null;
38
+ audioUrl?: string | null;
39
+ durationMs?: number | null;
40
+ }): { voice?: { transcript: string | null; audio_url: string | null; duration_ms: number | null } } {
41
+ if (m.messageType !== "voice" && m.messageType !== "ptt") return {};
42
+ return { voice: { transcript: m.transcript ?? null, audio_url: m.audioUrl ?? null, duration_ms: m.durationMs ?? null } };
43
+ }
44
+
45
+ const VOICE_MARKER = /^\[voice note — \d+s\]$/;
46
+
47
+ /**
48
+ * 30.11.2026 — agent ma USŁYSZEĆ PTT, nie zobaczyć podpis. Agenci czytają `text` (nasłuch, skille, mosty) —
49
+ * pole `voice` widział tylko ten, kto o nie zapytał. Dla głosówki `text` = znacznik + transkrypt:
50
+ * „[voice note — 25s] <transkrypcja>”. Bez transkryptu (jeszcze się robi / nagranie bez mowy) zostaje sam znacznik.
51
+ * Transkrypt przychodzi z message-list uprawnieniami CZYTAJĄCEGO (RLS ptt_transcripts: uczestnik wątku / członek kanału),
52
+ * więc obcy nie dostaje go ani w `voice`, ani w `text`.
53
+ */
54
+ export function voiceText(
55
+ text: string,
56
+ voice?: { transcript: string | null; duration_ms: number | null } | null,
57
+ ): string {
58
+ if (!voice) return text;
59
+ const marker = VOICE_MARKER.test(text)
60
+ ? text
61
+ : typeof voice.duration_ms === "number" && voice.duration_ms > 0
62
+ ? `[voice note — ${Math.max(1, Math.round(voice.duration_ms / 1000))}s]`
63
+ : "[voice note]";
64
+ const t = typeof voice.transcript === "string" ? voice.transcript.trim() : "";
65
+ return t ? `${marker} ${t}` : marker;
66
+ }
package/src/types.ts CHANGED
@@ -43,6 +43,15 @@ export interface MosaddServerOptions {
43
43
  * network adapter. A carrier-aware host supplies e.g. a radio DmProvider here.
44
44
  */
45
45
  providers?: Partial<ProviderRegistry>;
46
+ /**
47
+ * When true, publish this identity's mDM prekey bundle once on startup
48
+ * (best-effort, non-fatal) so peers can open an E2EE session without the user
49
+ * manually running mDM_publish_keys first. Fixes the cold-start where mDM_send
50
+ * fails for every recipient because nobody has published keys. Used by the
51
+ * stdio binary; the hosted per-request transport leaves this off (it publishes
52
+ * per authenticated session instead).
53
+ */
54
+ autoPublishKeys?: boolean;
46
55
  }
47
56
 
48
57
  export interface MosaddToolContext {
@@ -68,11 +77,38 @@ export interface MosaddToolContext {
68
77
  */
69
78
  export type CapabilityRequirement = "any" | "radio" | "network";
70
79
 
80
+ /**
81
+ * MCP tool annotations (spec `ToolAnnotations`, minus `title` which lives on the
82
+ * tool itself). Connector UIs — Claude's included — group and gate tools by these
83
+ * hints: `readOnlyHint: true` lands the tool in the read-only bucket (bulk-approvable),
84
+ * `destructiveHint: true` marks it as destroying/overwriting user data at approval
85
+ * time, and tools with NO annotations all fall into one flat "Other tools" bucket —
86
+ * which is exactly how the mosADD connector looked until 2026-08-26 (84 tools, one
87
+ * undifferentiated list; founder order: fix it).
88
+ */
89
+ export interface MosaddToolAnnotations {
90
+ /** Tool does not mutate anything. list/get/search/state/metrics class. */
91
+ readOnlyHint?: boolean;
92
+ /** Tool destroys or irreversibly overwrites data (delete/ban/revoke/edit-in-place). */
93
+ destructiveHint?: boolean;
94
+ /** Calling twice with the same args has no additional effect. */
95
+ idempotentHint?: boolean;
96
+ /** Tool reaches outside the mosADD closed world (e.g. sends external email). */
97
+ openWorldHint?: boolean;
98
+ }
99
+
71
100
  export interface MosaddTool<TInput = unknown, TOutput = unknown> {
72
101
  /** Tool name. MUST follow the m{MODULE}_{operation} convention. */
73
102
  name: string;
103
+ /**
104
+ * Human title for connector UIs (e.g. "Send encrypted DM"). The `name` stays the
105
+ * model-facing handle; this is what a PERSON sees in the permissions list.
106
+ */
107
+ title?: string;
74
108
  /** Short human-readable description. Shown to the model. */
75
109
  description: string;
110
+ /** MCP annotations; see MosaddToolAnnotations. Every registered tool SHOULD set them. */
111
+ annotations?: MosaddToolAnnotations;
76
112
  /**
77
113
  * Transport this tool requires. Consuming hosts read this to gate tools by
78
114
  * available carriers. Every tool MUST declare it explicitly.
package/src/version.ts ADDED
@@ -0,0 +1,8 @@
1
+ // Single source of truth for the package version at RUNTIME.
2
+ // ⛔ Never hand-type the version anywhere else (server.ts carried a hardcoded
3
+ // "3.0.0-alpha.32" while package.json said alpha.34 — serverInfo lied to every
4
+ // connected client). tsup bundles this JSON import, so the constant always
5
+ // equals the version that was actually published.
6
+ import pkg from "../package.json" with { type: "json" };
7
+
8
+ export const PKG_VERSION: string = (pkg as { version: string }).version;