@mosadd/mcp 3.0.0-alpha.51 → 3.0.0-alpha.53

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 (60) hide show
  1. package/CHANGELOG.md +334 -309
  2. package/README.md +150 -150
  3. package/dist/bin/mcp.js +1 -1
  4. package/dist/{chunk-BTAIZKYT.js → chunk-AWKITPZQ.js} +407 -106
  5. package/dist/index.d.ts +11 -1
  6. package/dist/index.js +1 -1
  7. package/package.json +9 -9
  8. package/src/__tests__/blob-upload.test.ts +93 -0
  9. package/src/__tests__/golden-path.test.ts +139 -139
  10. package/src/__tests__/integration.test.ts +182 -182
  11. package/src/__tests__/knowledge-ingest.test.ts +114 -114
  12. package/src/__tests__/mdm-e2ee.test.ts +212 -212
  13. package/src/__tests__/mdm-mcp-readable.test.ts +284 -0
  14. package/src/__tests__/mirc-invite.test.ts +112 -112
  15. package/src/__tests__/mtalk.test.ts +122 -122
  16. package/src/__tests__/server.test.ts +71 -71
  17. package/src/__tests__/serverJsonVersion.test.ts +45 -45
  18. package/src/__tests__/tool-count-consistency.test.ts +199 -199
  19. package/src/bin/login.ts +138 -138
  20. package/src/bin/mcp.ts +145 -145
  21. package/src/config.ts +66 -66
  22. package/src/crypto/mdm-session.ts +798 -502
  23. package/src/index.ts +19 -19
  24. package/src/observability/sentry.ts +79 -79
  25. package/src/providers/blob-upload.ts +52 -6
  26. package/src/providers/memory-voice.ts +79 -79
  27. package/src/providers/supabase-dm.ts +174 -122
  28. package/src/providers/supabase-voice.ts +91 -91
  29. package/src/providers/supabase.ts +231 -231
  30. package/src/server.ts +186 -162
  31. package/src/tools/__tests__/ragDeleteFoldsSourceId.test.ts +67 -67
  32. package/src/tools/actions.ts +166 -166
  33. package/src/tools/attachments.ts +276 -276
  34. package/src/tools/capabilities.ts +70 -70
  35. package/src/tools/embed.ts +110 -110
  36. package/src/tools/index.ts +181 -181
  37. package/src/tools/knowledge-graph.ts +186 -186
  38. package/src/tools/knowledge.ts +344 -344
  39. package/src/tools/mail-agentbox.ts +155 -155
  40. package/src/tools/mail-aliases.ts +25 -25
  41. package/src/tools/mail-provenance.ts +137 -137
  42. package/src/tools/mail.ts +403 -403
  43. package/src/tools/mcall.ts +216 -216
  44. package/src/tools/mdm-as-agent.ts +126 -126
  45. package/src/tools/mdm-voice.ts +220 -220
  46. package/src/tools/mdm.ts +119 -17
  47. package/src/tools/mirc-edge.ts +196 -196
  48. package/src/tools/mirc-members.ts +287 -287
  49. package/src/tools/mirc.ts +308 -308
  50. package/src/tools/mroom-messages.ts +142 -142
  51. package/src/tools/mroom.ts +221 -221
  52. package/src/tools/mtalk.ts +131 -131
  53. package/src/tools/murl.ts +314 -314
  54. package/src/tools/presence.ts +442 -442
  55. package/src/tools/ptt-ingest.ts +99 -99
  56. package/src/tools/threat.ts +123 -123
  57. package/src/types.ts +121 -121
  58. package/src/version.ts +8 -8
  59. package/src/voice/floor.ts +132 -132
  60. package/LICENSE +0 -201
@@ -1,142 +1,142 @@
1
- /**
2
- * mROOM text mode — send + list messages inside a private room.
3
- *
4
- * mROOM_send_message and mROOM_list_messages route through the same
5
- * the mosadd backend's `message-send` / `message-list` Edge Functions that mDM uses,
6
- * but with `space_id: 'rooms'` and `thread_id: 'privroom:<room_id>'` so the
7
- * RLS policies apply room-membership checks rather than DM contact checks.
8
- *
9
- * Voice in rooms (PTT, audio) lands separately via mTALK_start_session
10
- * over the WebRTC daemon — see LINEAR-2145.
11
- */
12
-
13
- import { z } from "zod";
14
- import type { MosaddTool, MosaddToolContext } from "../types.js";
15
- import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
16
-
17
- const PROTOCOL_VERSION = "mosadd.chat.v1";
18
-
19
- const RoomId = z.string().min(1).describe("Private room id (UUID). From mROOM_create / mROOM_list.");
20
-
21
- const mROOM_send_message_input = z.object({
22
- room_id: RoomId,
23
- text: z.string().min(1).max(64_000).describe("Message body (UTF-8). Max 64 KB."),
24
- reply_to_id: z.string().optional().describe("Optional id of the message being replied to."),
25
- });
26
-
27
- const mROOM_list_messages_input = z.object({
28
- room_id: RoomId,
29
- limit: z.number().int().min(1).max(200).default(50).optional(),
30
- cursor: z.string().optional().describe("Opaque pagination cursor from a prior list response."),
31
- });
32
-
33
- function packPlaintextPayload(text: string, replyToId?: string): string {
34
- const envelope = {
35
- v: PROTOCOL_VERSION,
36
- type: "text",
37
- text,
38
- reply_to: replyToId ?? null,
39
- sent_at: new Date().toISOString(),
40
- };
41
- return Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
42
- }
43
-
44
- function unpackPayload(payload: string): { text: string } {
45
- try {
46
- const json = Buffer.from(payload, "base64").toString("utf8");
47
- const obj = JSON.parse(json);
48
- if (typeof obj?.text === "string") return obj;
49
- } catch {
50
- /* fall through */
51
- }
52
- return { text: "<ciphertext>" };
53
- }
54
-
55
- async function mROOM_send_message(
56
- input: z.infer<typeof mROOM_send_message_input>,
57
- ctx: MosaddToolContext,
58
- ): Promise<{ message_id: string; delivered_at: string; thread_id: string }> {
59
- readSupabaseEnv();
60
- const thread_id = `privroom:${input.room_id}`;
61
- ctx.log("debug", "mROOM_send_message", { thread_id });
62
-
63
- const data = await invokeFunction<{ message?: { id: string; created_at: string } }>(
64
- "message-send",
65
- {
66
- space_id: "rooms",
67
- thread_id,
68
- encrypted_payload: packPlaintextPayload(input.text, input.reply_to_id),
69
- message_type: "text",
70
- protocol_version: PROTOCOL_VERSION,
71
- reply_to_id: input.reply_to_id ?? null,
72
- },
73
- );
74
-
75
- if (!data?.message?.id) {
76
- throw new Error("message-send returned no message id");
77
- }
78
-
79
- return {
80
- message_id: data.message.id,
81
- delivered_at: data.message.created_at ?? new Date().toISOString(),
82
- thread_id,
83
- };
84
- }
85
-
86
- async function mROOM_list_messages(
87
- input: z.infer<typeof mROOM_list_messages_input>,
88
- ctx: MosaddToolContext,
89
- ): Promise<{
90
- messages: Array<{ id: string; sender_identity_id: string; text: string; timestamp: string }>;
91
- next_cursor: string | null;
92
- }> {
93
- readSupabaseEnv();
94
- const thread_id = `privroom:${input.room_id}`;
95
- ctx.log("debug", "mROOM_list_messages", { thread_id });
96
-
97
- type MessageListResponse = {
98
- messages?: Array<{
99
- id: string;
100
- sender_identity_id: string;
101
- encrypted_payload: string;
102
- created_at: string;
103
- }>;
104
- next_cursor?: string | null;
105
- };
106
-
107
- const data = await invokeFunction<MessageListResponse>("message-list", {
108
- space_id: "rooms",
109
- thread_id,
110
- limit: input.limit ?? 50,
111
- cursor: input.cursor,
112
- });
113
-
114
- return {
115
- messages: (data?.messages ?? []).map((m) => ({
116
- id: m.id,
117
- sender_identity_id: m.sender_identity_id,
118
- text: unpackPayload(m.encrypted_payload).text,
119
- timestamp: m.created_at,
120
- })),
121
- next_cursor: data?.next_cursor ?? null,
122
- };
123
- }
124
-
125
- export const mroomMessagesTools: MosaddTool[] = [
126
- {
127
- name: "mROOM_send_message",
128
- requires: "network",
129
- description:
130
- "Send a text message into a private room. Authorisation: must be a member (or guest with a valid token). Alpha payload is plaintext base64; v0.2 wraps with Double Ratchet.",
131
- inputSchema: mROOM_send_message_input,
132
- handler: mROOM_send_message as MosaddTool["handler"],
133
- },
134
- {
135
- name: "mROOM_list_messages",
136
- requires: "network",
137
- description:
138
- "List recent text messages in a private room. Cursor-paginated, newest first.",
139
- inputSchema: mROOM_list_messages_input,
140
- handler: mROOM_list_messages as MosaddTool["handler"],
141
- },
142
- ];
1
+ /**
2
+ * mROOM text mode — send + list messages inside a private room.
3
+ *
4
+ * mROOM_send_message and mROOM_list_messages route through the same
5
+ * the mosadd backend's `message-send` / `message-list` Edge Functions that mDM uses,
6
+ * but with `space_id: 'rooms'` and `thread_id: 'privroom:<room_id>'` so the
7
+ * RLS policies apply room-membership checks rather than DM contact checks.
8
+ *
9
+ * Voice in rooms (PTT, audio) lands separately via mTALK_start_session
10
+ * over the WebRTC daemon — see LINEAR-2145.
11
+ */
12
+
13
+ import { z } from "zod";
14
+ import type { MosaddTool, MosaddToolContext } from "../types.js";
15
+ import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
16
+
17
+ const PROTOCOL_VERSION = "mosadd.chat.v1";
18
+
19
+ const RoomId = z.string().min(1).describe("Private room id (UUID). From mROOM_create / mROOM_list.");
20
+
21
+ const mROOM_send_message_input = z.object({
22
+ room_id: RoomId,
23
+ text: z.string().min(1).max(64_000).describe("Message body (UTF-8). Max 64 KB."),
24
+ reply_to_id: z.string().optional().describe("Optional id of the message being replied to."),
25
+ });
26
+
27
+ const mROOM_list_messages_input = z.object({
28
+ room_id: RoomId,
29
+ limit: z.number().int().min(1).max(200).default(50).optional(),
30
+ cursor: z.string().optional().describe("Opaque pagination cursor from a prior list response."),
31
+ });
32
+
33
+ function packPlaintextPayload(text: string, replyToId?: string): string {
34
+ const envelope = {
35
+ v: PROTOCOL_VERSION,
36
+ type: "text",
37
+ text,
38
+ reply_to: replyToId ?? null,
39
+ sent_at: new Date().toISOString(),
40
+ };
41
+ return Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
42
+ }
43
+
44
+ function unpackPayload(payload: string): { text: string } {
45
+ try {
46
+ const json = Buffer.from(payload, "base64").toString("utf8");
47
+ const obj = JSON.parse(json);
48
+ if (typeof obj?.text === "string") return obj;
49
+ } catch {
50
+ /* fall through */
51
+ }
52
+ return { text: "<ciphertext>" };
53
+ }
54
+
55
+ async function mROOM_send_message(
56
+ input: z.infer<typeof mROOM_send_message_input>,
57
+ ctx: MosaddToolContext,
58
+ ): Promise<{ message_id: string; delivered_at: string; thread_id: string }> {
59
+ readSupabaseEnv();
60
+ const thread_id = `privroom:${input.room_id}`;
61
+ ctx.log("debug", "mROOM_send_message", { thread_id });
62
+
63
+ const data = await invokeFunction<{ message?: { id: string; created_at: string } }>(
64
+ "message-send",
65
+ {
66
+ space_id: "rooms",
67
+ thread_id,
68
+ encrypted_payload: packPlaintextPayload(input.text, input.reply_to_id),
69
+ message_type: "text",
70
+ protocol_version: PROTOCOL_VERSION,
71
+ reply_to_id: input.reply_to_id ?? null,
72
+ },
73
+ );
74
+
75
+ if (!data?.message?.id) {
76
+ throw new Error("message-send returned no message id");
77
+ }
78
+
79
+ return {
80
+ message_id: data.message.id,
81
+ delivered_at: data.message.created_at ?? new Date().toISOString(),
82
+ thread_id,
83
+ };
84
+ }
85
+
86
+ async function mROOM_list_messages(
87
+ input: z.infer<typeof mROOM_list_messages_input>,
88
+ ctx: MosaddToolContext,
89
+ ): Promise<{
90
+ messages: Array<{ id: string; sender_identity_id: string; text: string; timestamp: string }>;
91
+ next_cursor: string | null;
92
+ }> {
93
+ readSupabaseEnv();
94
+ const thread_id = `privroom:${input.room_id}`;
95
+ ctx.log("debug", "mROOM_list_messages", { thread_id });
96
+
97
+ type MessageListResponse = {
98
+ messages?: Array<{
99
+ id: string;
100
+ sender_identity_id: string;
101
+ encrypted_payload: string;
102
+ created_at: string;
103
+ }>;
104
+ next_cursor?: string | null;
105
+ };
106
+
107
+ const data = await invokeFunction<MessageListResponse>("message-list", {
108
+ space_id: "rooms",
109
+ thread_id,
110
+ limit: input.limit ?? 50,
111
+ cursor: input.cursor,
112
+ });
113
+
114
+ return {
115
+ messages: (data?.messages ?? []).map((m) => ({
116
+ id: m.id,
117
+ sender_identity_id: m.sender_identity_id,
118
+ text: unpackPayload(m.encrypted_payload).text,
119
+ timestamp: m.created_at,
120
+ })),
121
+ next_cursor: data?.next_cursor ?? null,
122
+ };
123
+ }
124
+
125
+ export const mroomMessagesTools: MosaddTool[] = [
126
+ {
127
+ name: "mROOM_send_message",
128
+ requires: "network",
129
+ description:
130
+ "Send a text message into a private room. Authorisation: must be a member (or guest with a valid token). Alpha payload is plaintext base64; v0.2 wraps with Double Ratchet.",
131
+ inputSchema: mROOM_send_message_input,
132
+ handler: mROOM_send_message as MosaddTool["handler"],
133
+ },
134
+ {
135
+ name: "mROOM_list_messages",
136
+ requires: "network",
137
+ description:
138
+ "List recent text messages in a private room. Cursor-paginated, newest first.",
139
+ inputSchema: mROOM_list_messages_input,
140
+ handler: mROOM_list_messages as MosaddTool["handler"],
141
+ },
142
+ ];