@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.
- package/CHANGELOG.md +415 -0
- package/LICENSE +21 -201
- package/README.md +79 -40
- package/dist/bin/mcp.js +132 -8
- package/dist/chunk-J2S44U5R.js +4258 -0
- package/dist/index.d.ts +112 -8
- package/dist/index.js +3 -1
- package/package.json +19 -16
- package/src/__tests__/blob-upload.test.ts +93 -0
- package/src/__tests__/channel-e2ee.test.ts +62 -0
- package/src/__tests__/cli.test.ts +47 -0
- package/src/__tests__/fleet-plaintext.test.ts +243 -0
- package/src/__tests__/golden-path.test.ts +4 -2
- package/src/__tests__/integration.test.ts +50 -11
- package/src/__tests__/knowledge-ingest.test.ts +114 -0
- package/src/__tests__/label-room-owner.test.ts +22 -0
- package/src/__tests__/mdm-e2ee.test.ts +36 -2
- package/src/__tests__/mdm-mcp-readable.test.ts +390 -0
- package/src/__tests__/mirc-invite.test.ts +112 -0
- package/src/__tests__/mirc-voice.test.ts +82 -0
- package/src/__tests__/mrag-search-answer.test.ts +42 -0
- package/src/__tests__/mrag-search-diagnostics.test.ts +78 -0
- package/src/__tests__/no-dead-host.test.ts +37 -0
- package/src/__tests__/presence.test.ts +199 -0
- package/src/__tests__/server.test.ts +11 -7
- package/src/__tests__/serverJsonVersion.test.ts +45 -0
- package/src/__tests__/tool-count-consistency.test.ts +259 -0
- package/src/__tests__/voice-fields.test.ts +24 -0
- package/src/bin/mcp.ts +71 -6
- package/src/cli.ts +100 -0
- package/src/crypto/channel-e2ee.ts +288 -0
- package/src/crypto/mdm-session.ts +479 -40
- package/src/index.ts +2 -2
- package/src/providers/blob-upload.ts +162 -0
- package/src/providers/supabase-dm.ts +102 -7
- package/src/providers/supabase-voice.ts +13 -1
- package/src/providers/supabase.ts +121 -10
- package/src/server.ts +102 -12
- package/src/tools/__tests__/ragDeleteFoldsSourceId.test.ts +67 -0
- package/src/tools/actions.ts +166 -0
- package/src/tools/attachments.ts +276 -0
- package/src/tools/capabilities.ts +2 -0
- package/src/tools/channel-payload.ts +69 -0
- package/src/tools/embed.ts +110 -0
- package/src/tools/index.ts +136 -6
- package/src/tools/knowledge-graph.ts +186 -0
- package/src/tools/knowledge.ts +205 -12
- package/src/tools/mail-agentbox.ts +155 -0
- package/src/tools/mail-aliases.ts +25 -0
- package/src/tools/mail-provenance.ts +137 -0
- package/src/tools/mail.ts +214 -60
- package/src/tools/mdm-as-agent.ts +137 -0
- package/src/tools/mdm-voice.ts +17 -3
- package/src/tools/mdm.ts +306 -58
- package/src/tools/mirc-edge.ts +12 -6
- package/src/tools/mirc-members.ts +130 -20
- package/src/tools/mirc-messages.ts +109 -40
- package/src/tools/mirc.ts +149 -11
- package/src/tools/mroom-messages.ts +5 -13
- package/src/tools/mtalk.ts +11 -1
- package/src/tools/murl.ts +314 -0
- package/src/tools/presence.ts +442 -0
- package/src/tools/ptt-ingest.ts +99 -0
- package/src/tools/threat.ts +123 -0
- package/src/tools/voice-format.ts +66 -0
- package/src/types.ts +36 -0
- package/src/version.ts +8 -0
- package/dist/chunk-EFTB743G.js +0 -1924
package/src/tools/mail.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* mp0st — Email.
|
|
3
3
|
*
|
|
4
4
|
* Every mosadd user gets `<userId>@mosadd.com` for free — incoming mail lands
|
|
5
5
|
* in their app, outgoing mail flows through the mosadd mp0st pipeline.
|
|
@@ -19,9 +19,9 @@ const EmailAddress = z
|
|
|
19
19
|
.max(254)
|
|
20
20
|
.describe("RFC 5321 email address.");
|
|
21
21
|
|
|
22
|
-
const MessageId = z.string().min(1).describe("Message id (UUID) from
|
|
22
|
+
const MessageId = z.string().min(1).describe("Message id (UUID) from mAYL_send or inbox.");
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const mp0st_send_input = z.object({
|
|
25
25
|
to: z.union([EmailAddress, z.array(EmailAddress).min(1).max(50)]).describe(
|
|
26
26
|
"Recipient(s). Single address or array of up to 50.",
|
|
27
27
|
),
|
|
@@ -31,17 +31,37 @@ const mAIL_send_input = z.object({
|
|
|
31
31
|
cc: z.array(EmailAddress).max(50).optional(),
|
|
32
32
|
bcc: z.array(EmailAddress).max(50).optional(),
|
|
33
33
|
reply_to: EmailAddress.optional(),
|
|
34
|
+
tracking: z
|
|
35
|
+
.boolean()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("Open-pixel + link-click tracking. Default true. Set false to send with NO tracking (privacy / GDPR-friendly)."),
|
|
38
|
+
force_reader: z
|
|
39
|
+
.boolean()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Default false. If true, the email body is a stub only and the recipient must open it in mosadd's secure reader — maximizes tracking (print/copy/time-on-read become observable). Best for confidential / legal mail."),
|
|
42
|
+
disclose_tracking: z
|
|
43
|
+
.boolean()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Default false. If true (and tracking on), append a tracking-disclosure footer to the email — recommended for GDPR/ePrivacy compliance."),
|
|
46
|
+
watermark: z
|
|
47
|
+
.union([z.boolean(), z.string().max(120)])
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("Inject a faint recipient watermark into the secure reader (shows in screenshots/prints). Pass true to watermark with the recipient address, or a custom string."),
|
|
50
|
+
auto_destruct: z
|
|
51
|
+
.enum(["1h", "24h", "7d"])
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Self-destruct timer: the secure-reader link expires after this window."),
|
|
34
54
|
});
|
|
35
55
|
|
|
36
|
-
const
|
|
56
|
+
const mp0st_view_input = z.object({
|
|
37
57
|
message_id: MessageId,
|
|
38
58
|
});
|
|
39
59
|
|
|
40
|
-
const
|
|
60
|
+
const mp0st_delete_input = z.object({
|
|
41
61
|
message_id: MessageId,
|
|
42
62
|
});
|
|
43
63
|
|
|
44
|
-
const
|
|
64
|
+
const mp0st_list_input = z.object({
|
|
45
65
|
direction: z
|
|
46
66
|
.enum(["inbound", "outbound"])
|
|
47
67
|
.optional()
|
|
@@ -53,15 +73,42 @@ const mAIL_list_input = z.object({
|
|
|
53
73
|
.describe("Pagination cursor: pass the previous response's next_cursor to get the next (older) page."),
|
|
54
74
|
});
|
|
55
75
|
|
|
56
|
-
const
|
|
76
|
+
const mp0st_stats_input = z.object({
|
|
77
|
+
message_id: MessageId,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const mp0st_events_input = z.object({
|
|
57
81
|
message_id: MessageId,
|
|
58
82
|
});
|
|
59
83
|
|
|
60
|
-
const
|
|
84
|
+
const mp0st_metrics_input = z.object({});
|
|
85
|
+
|
|
86
|
+
const mp0st_revoke_input = z.object({
|
|
61
87
|
message_id: MessageId,
|
|
88
|
+
restore: z
|
|
89
|
+
.boolean()
|
|
90
|
+
.optional()
|
|
91
|
+
.describe("Set true to UN-revoke (restore access). Default false = revoke."),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const mp0st_audit_export_input = z.object({
|
|
95
|
+
message_id: MessageId,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const mp0st_consent_input = z.object({
|
|
99
|
+
action: z
|
|
100
|
+
.enum(["list", "check", "optin"])
|
|
101
|
+
.describe("'list' = recipients who opted out of your tracking; 'check' = is one recipient opted out; 'optin' = re-enable tracking for a recipient."),
|
|
102
|
+
recipient: EmailAddress.optional().describe("Required for 'check' and 'optin'."),
|
|
62
103
|
});
|
|
63
104
|
|
|
64
|
-
const
|
|
105
|
+
const mp0st_notify_input = z.object({
|
|
106
|
+
since: z
|
|
107
|
+
.string()
|
|
108
|
+
.optional()
|
|
109
|
+
.describe("ISO-8601 cursor — return only events newer than this. Pass the previous response's `cursor` to poll for new activity."),
|
|
110
|
+
limit: z.number().int().min(1).max(200).optional().describe("Max events. Default 50."),
|
|
111
|
+
});
|
|
65
112
|
|
|
66
113
|
interface MailListItem {
|
|
67
114
|
message_id: string;
|
|
@@ -77,20 +124,24 @@ interface MailListItem {
|
|
|
77
124
|
|
|
78
125
|
// ---- Handlers ----
|
|
79
126
|
|
|
80
|
-
async function
|
|
81
|
-
input: z.infer<typeof
|
|
127
|
+
async function mp0st_send(
|
|
128
|
+
input: z.infer<typeof mp0st_send_input>,
|
|
82
129
|
ctx: MosaddToolContext,
|
|
83
|
-
): Promise<{ message_id: string;
|
|
130
|
+
): Promise<{ message_id: string; status: string; is_internal: boolean }> {
|
|
84
131
|
readSupabaseEnv();
|
|
85
132
|
if (!input.body_text && !input.body_html) {
|
|
86
|
-
throw new Error("
|
|
133
|
+
throw new Error("mp0st_send requires at least one of body_text or body_html.");
|
|
87
134
|
}
|
|
88
|
-
ctx.log("debug", "
|
|
89
|
-
|
|
135
|
+
ctx.log("debug", "mp0st_send invoking mp0st-send", { to: input.to });
|
|
136
|
+
// mp0st-send returns { ok, email_id, status, is_internal } — remap email_id to the
|
|
137
|
+
// tool's message_id contract (email_id IS the message id). Surface backend errors.
|
|
138
|
+
const res = await invokeFunction<{ ok?: boolean; email_id?: string; status?: string; is_internal?: boolean; error?: string }>("mp0st-send", input);
|
|
139
|
+
if (res.error) throw new Error(res.error);
|
|
140
|
+
return { message_id: res.email_id ?? "", status: res.status ?? "sent", is_internal: res.is_internal ?? false };
|
|
90
141
|
}
|
|
91
142
|
|
|
92
|
-
async function
|
|
93
|
-
input: z.infer<typeof
|
|
143
|
+
async function mp0st_view(
|
|
144
|
+
input: z.infer<typeof mp0st_view_input>,
|
|
94
145
|
ctx: MosaddToolContext,
|
|
95
146
|
): Promise<{
|
|
96
147
|
message_id: string;
|
|
@@ -99,19 +150,22 @@ async function mAIL_view(
|
|
|
99
150
|
subject: string;
|
|
100
151
|
body_text: string | null;
|
|
101
152
|
body_html: string | null;
|
|
102
|
-
|
|
153
|
+
sent_at: string;
|
|
103
154
|
}> {
|
|
104
155
|
readSupabaseEnv();
|
|
105
|
-
|
|
106
|
-
|
|
156
|
+
// mp0st-get (NOT mp0st-view): mp0st-view is the open-tracking pixel endpoint
|
|
157
|
+
// keyed on ?t=<trackingId> and always 400s "Missing tracking ID" on a JSON POST.
|
|
158
|
+
// mp0st-get reads the owner-scoped email by id and returns the full body.
|
|
159
|
+
ctx.log("debug", "mp0st_view invoking mp0st-get", { message_id: input.message_id });
|
|
160
|
+
return await invokeFunction("mp0st-get", { message_id: input.message_id });
|
|
107
161
|
}
|
|
108
162
|
|
|
109
|
-
async function
|
|
110
|
-
input: z.infer<typeof
|
|
163
|
+
async function mp0st_list(
|
|
164
|
+
input: z.infer<typeof mp0st_list_input>,
|
|
111
165
|
ctx: MosaddToolContext,
|
|
112
166
|
): Promise<{ emails: MailListItem[]; next_cursor: string | null }> {
|
|
113
167
|
readSupabaseEnv();
|
|
114
|
-
ctx.log("debug", "
|
|
168
|
+
ctx.log("debug", "mp0st_list invoking mp0st-list", { direction: input.direction });
|
|
115
169
|
return await invokeFunction<{ emails: MailListItem[]; next_cursor: string | null }>("mp0st-list", {
|
|
116
170
|
direction: input.direction ?? null,
|
|
117
171
|
limit: input.limit ?? 50,
|
|
@@ -119,12 +173,12 @@ async function mAIL_list(
|
|
|
119
173
|
});
|
|
120
174
|
}
|
|
121
175
|
|
|
122
|
-
async function
|
|
123
|
-
input: z.infer<typeof
|
|
176
|
+
async function mp0st_delete(
|
|
177
|
+
input: z.infer<typeof mp0st_delete_input>,
|
|
124
178
|
ctx: MosaddToolContext,
|
|
125
179
|
): Promise<{ ok: true; message_id: string; deleted: true }> {
|
|
126
180
|
readSupabaseEnv();
|
|
127
|
-
ctx.log("debug", "
|
|
181
|
+
ctx.log("debug", "mp0st_delete invoking mp0st-delete", { message_id: input.message_id });
|
|
128
182
|
return await invokeFunction<{ ok: true; message_id: string; deleted: true }>("mp0st-delete", {
|
|
129
183
|
message_id: input.message_id,
|
|
130
184
|
});
|
|
@@ -147,31 +201,31 @@ interface MailEngagement {
|
|
|
147
201
|
total_events: number;
|
|
148
202
|
}
|
|
149
203
|
|
|
150
|
-
async function
|
|
151
|
-
input: z.infer<typeof
|
|
204
|
+
async function mp0st_stats(
|
|
205
|
+
input: z.infer<typeof mp0st_stats_input>,
|
|
152
206
|
ctx: MosaddToolContext,
|
|
153
207
|
): Promise<{ summary: MailEngagement }> {
|
|
154
208
|
readSupabaseEnv();
|
|
155
|
-
ctx.log("debug", "
|
|
209
|
+
ctx.log("debug", "mp0st_stats invoking mp0st-stats", { message_id: input.message_id });
|
|
156
210
|
return await invokeFunction<{ summary: MailEngagement }>("mp0st-stats", {
|
|
157
211
|
message_id: input.message_id,
|
|
158
212
|
});
|
|
159
213
|
}
|
|
160
214
|
|
|
161
|
-
async function
|
|
162
|
-
input: z.infer<typeof
|
|
215
|
+
async function mp0st_events(
|
|
216
|
+
input: z.infer<typeof mp0st_events_input>,
|
|
163
217
|
ctx: MosaddToolContext,
|
|
164
218
|
): Promise<{
|
|
165
219
|
summary: MailEngagement;
|
|
166
220
|
events: Array<{ event_type: string; at: string; device: string | null; ip_hash: string | null; link_url: string | null }>;
|
|
167
221
|
}> {
|
|
168
222
|
readSupabaseEnv();
|
|
169
|
-
ctx.log("debug", "
|
|
223
|
+
ctx.log("debug", "mp0st_events invoking mp0st-stats", { message_id: input.message_id });
|
|
170
224
|
return await invokeFunction("mp0st-stats", { message_id: input.message_id, events: true });
|
|
171
225
|
}
|
|
172
226
|
|
|
173
|
-
async function
|
|
174
|
-
_input: z.infer<typeof
|
|
227
|
+
async function mp0st_metrics(
|
|
228
|
+
_input: z.infer<typeof mp0st_metrics_input>,
|
|
175
229
|
ctx: MosaddToolContext,
|
|
176
230
|
): Promise<{
|
|
177
231
|
mailbox: {
|
|
@@ -184,66 +238,166 @@ async function mAIL_metrics(
|
|
|
184
238
|
};
|
|
185
239
|
}> {
|
|
186
240
|
readSupabaseEnv();
|
|
187
|
-
ctx.log("debug", "
|
|
241
|
+
ctx.log("debug", "mp0st_metrics invoking mp0st-stats");
|
|
188
242
|
return await invokeFunction("mp0st-stats", {});
|
|
189
243
|
}
|
|
190
244
|
|
|
245
|
+
async function mp0st_revoke(
|
|
246
|
+
input: z.infer<typeof mp0st_revoke_input>,
|
|
247
|
+
ctx: MosaddToolContext,
|
|
248
|
+
): Promise<{ ok: true; message_id: string; revoked: boolean; expires_at: string | null }> {
|
|
249
|
+
readSupabaseEnv();
|
|
250
|
+
ctx.log("debug", "mp0st_revoke invoking mp0st-revoke", { message_id: input.message_id, restore: !!input.restore });
|
|
251
|
+
return await invokeFunction("mp0st-revoke", {
|
|
252
|
+
message_id: input.message_id,
|
|
253
|
+
restore: input.restore ?? false,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async function mp0st_audit_export(
|
|
258
|
+
input: z.infer<typeof mp0st_audit_export_input>,
|
|
259
|
+
ctx: MosaddToolContext,
|
|
260
|
+
): Promise<{ audit: Record<string, unknown>; signature: string; algo: string; note: string }> {
|
|
261
|
+
readSupabaseEnv();
|
|
262
|
+
ctx.log("debug", "mp0st_audit_export invoking mp0st-audit", { message_id: input.message_id });
|
|
263
|
+
return await invokeFunction("mp0st-audit", { message_id: input.message_id });
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async function mp0st_consent(
|
|
267
|
+
input: z.infer<typeof mp0st_consent_input>,
|
|
268
|
+
ctx: MosaddToolContext,
|
|
269
|
+
): Promise<Record<string, unknown>> {
|
|
270
|
+
readSupabaseEnv();
|
|
271
|
+
if ((input.action === "check" || input.action === "optin") && !input.recipient) {
|
|
272
|
+
throw new Error(`mp0st_consent action '${input.action}' requires a 'recipient' email address.`);
|
|
273
|
+
}
|
|
274
|
+
ctx.log("debug", "mp0st_consent invoking mp0st-consent", { action: input.action });
|
|
275
|
+
return await invokeFunction("mp0st-consent", { action: input.action, recipient: input.recipient ?? null });
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async function mp0st_notify(
|
|
279
|
+
input: z.infer<typeof mp0st_notify_input>,
|
|
280
|
+
ctx: MosaddToolContext,
|
|
281
|
+
): Promise<{
|
|
282
|
+
events: Array<{ message_id: string; subject: string | null; to: string | null; event_type: string; device: string | null; link_url: string | null; at: string }>;
|
|
283
|
+
cursor: string | null;
|
|
284
|
+
count: number;
|
|
285
|
+
}> {
|
|
286
|
+
readSupabaseEnv();
|
|
287
|
+
ctx.log("debug", "mp0st_notify invoking mp0st-notify", { since: input.since });
|
|
288
|
+
return await invokeFunction("mp0st-notify", { action: "feed", since: input.since ?? null, limit: input.limit ?? 50 });
|
|
289
|
+
}
|
|
290
|
+
|
|
191
291
|
// ---- Registration ----
|
|
192
292
|
|
|
193
293
|
export const mailTools: MosaddTool[] = [
|
|
194
294
|
{
|
|
195
|
-
name: "
|
|
295
|
+
name: "mAYL_list",
|
|
296
|
+
title: "List emails",
|
|
297
|
+
annotations: { readOnlyHint: true },
|
|
196
298
|
requires: "network",
|
|
197
299
|
description:
|
|
198
|
-
"List the user's mailbox (their <userId>@mosadd.com inbox/outbox) newest-first, with sender, subject, status and a short snippet. Filter by direction ('inbound' = received, 'outbound' = sent). Use the returned next_cursor with `before` to page through older mail. Call
|
|
199
|
-
inputSchema:
|
|
200
|
-
handler:
|
|
300
|
+
"List the user's mailbox (their <userId>@mosadd.com inbox/outbox) newest-first, with sender, subject, status and a short snippet. Filter by direction ('inbound' = received, 'outbound' = sent). Use the returned next_cursor with `before` to page through older mail. Call mAYL_view to read a full message body.",
|
|
301
|
+
inputSchema: mp0st_list_input,
|
|
302
|
+
handler: mp0st_list as MosaddTool["handler"],
|
|
201
303
|
},
|
|
202
304
|
{
|
|
203
|
-
name: "
|
|
305
|
+
name: "mAYL_send",
|
|
306
|
+
title: "Send email",
|
|
307
|
+
annotations: { readOnlyHint: false },
|
|
204
308
|
requires: "network",
|
|
205
309
|
description:
|
|
206
|
-
"Send an email from the user's mosadd address (<userId>@mosadd.com). Pass body_text or body_html (or both). Supports cc, bcc, reply_to.",
|
|
207
|
-
inputSchema:
|
|
208
|
-
handler:
|
|
310
|
+
"Send an email from the user's mosadd address (<userId>@mosadd.com). Pass body_text or body_html (or both). Supports cc, bcc, reply_to. Monitoring/legal options: tracking (open+click, default on; set false for no tracking), force_reader (stub email → recipient opens in mosadd's secure reader, unlocking print/copy/time-on-read tracking + revoke), watermark (recipient watermark visible in screenshots/prints), disclose_tracking (GDPR footer), auto_destruct ('1h'|'24h'|'7d').",
|
|
311
|
+
inputSchema: mp0st_send_input,
|
|
312
|
+
handler: mp0st_send as MosaddTool["handler"],
|
|
209
313
|
},
|
|
210
314
|
{
|
|
211
|
-
name: "
|
|
315
|
+
name: "mAYL_view",
|
|
316
|
+
title: "Read an email",
|
|
317
|
+
annotations: { readOnlyHint: true },
|
|
212
318
|
requires: "network",
|
|
213
319
|
description: "Read the full body and metadata of an email by message_id.",
|
|
214
|
-
inputSchema:
|
|
215
|
-
handler:
|
|
320
|
+
inputSchema: mp0st_view_input,
|
|
321
|
+
handler: mp0st_view as MosaddTool["handler"],
|
|
216
322
|
},
|
|
217
323
|
{
|
|
218
|
-
name: "
|
|
324
|
+
name: "mAYL_delete",
|
|
325
|
+
title: "Delete email",
|
|
326
|
+
annotations: { destructiveHint: true },
|
|
219
327
|
requires: "network",
|
|
220
328
|
description:
|
|
221
|
-
"Delete one of the user's emails by message_id (from
|
|
222
|
-
inputSchema:
|
|
223
|
-
handler:
|
|
329
|
+
"Delete one of the user's emails by message_id (from mAYL_list). Soft-delete — it stops showing in mAYL_list. Owner-scoped: only your own mail.",
|
|
330
|
+
inputSchema: mp0st_delete_input,
|
|
331
|
+
handler: mp0st_delete as MosaddTool["handler"],
|
|
224
332
|
},
|
|
225
333
|
{
|
|
226
|
-
name: "
|
|
334
|
+
name: "mAYL_stats",
|
|
335
|
+
title: "Email delivery stats",
|
|
336
|
+
annotations: { readOnlyHint: true },
|
|
227
337
|
requires: "network",
|
|
228
338
|
description:
|
|
229
339
|
"Engagement summary for one sent email (by message_id): open_count, unique_opens, click_count, whether it was likely forwarded, first/last opened time, and a breakdown of tracked event types. Opens/clicks are real (tracking pixel + link-wrap); forward detection is best-effort (IP-subnet diversity). Owner-scoped.",
|
|
230
|
-
inputSchema:
|
|
231
|
-
handler:
|
|
340
|
+
inputSchema: mp0st_stats_input,
|
|
341
|
+
handler: mp0st_stats as MosaddTool["handler"],
|
|
232
342
|
},
|
|
233
343
|
{
|
|
234
|
-
name: "
|
|
344
|
+
name: "mAYL_events",
|
|
345
|
+
title: "Email event trail",
|
|
346
|
+
annotations: { readOnlyHint: true },
|
|
235
347
|
requires: "network",
|
|
236
348
|
description:
|
|
237
|
-
"Raw engagement timeline for one email (by message_id): every tracked event (pixel_open, link_click, forwarded, page_view, copy/print/focus signals) with timestamp, device type and link URL. Use
|
|
238
|
-
inputSchema:
|
|
239
|
-
handler:
|
|
349
|
+
"Raw engagement timeline for one email (by message_id): every tracked event (pixel_open, link_click, forwarded, page_view, copy/print/focus signals) with timestamp, device type and link URL. Use mAYL_stats for the rollup; use this for the per-event detail. Owner-scoped.",
|
|
350
|
+
inputSchema: mp0st_events_input,
|
|
351
|
+
handler: mp0st_events as MosaddTool["handler"],
|
|
240
352
|
},
|
|
241
353
|
{
|
|
242
|
-
name: "
|
|
354
|
+
name: "mAYL_metrics",
|
|
355
|
+
title: "Email engagement metrics",
|
|
356
|
+
annotations: { readOnlyHint: true },
|
|
243
357
|
requires: "network",
|
|
244
358
|
description:
|
|
245
359
|
"Mailbox-wide engagement aggregate across the user's sent mail: total_sent, opened_emails, open_rate_pct, total_opens, total_clicks, forwarded_emails. Owner-scoped.",
|
|
246
|
-
inputSchema:
|
|
247
|
-
handler:
|
|
360
|
+
inputSchema: mp0st_metrics_input,
|
|
361
|
+
handler: mp0st_metrics as MosaddTool["handler"],
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "mAYL_revoke",
|
|
365
|
+
title: "Revoke a sent email",
|
|
366
|
+
annotations: { destructiveHint: true },
|
|
367
|
+
requires: "network",
|
|
368
|
+
description:
|
|
369
|
+
"Revoke (recall) a sent email's secure-reader access by message_id — the recipient can no longer open the full message via the mosadd reader link (Virtru-style recall, immediate). Pass restore:true to re-enable. HONEST LIMIT: cannot un-send or claw back content the recipient already read, copied, or screenshotted — only disables future reader access. Owner-scoped.",
|
|
370
|
+
inputSchema: mp0st_revoke_input,
|
|
371
|
+
handler: mp0st_revoke as MosaddTool["handler"],
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: "mAYL_audit_export",
|
|
375
|
+
title: "Export signed audit report",
|
|
376
|
+
annotations: { readOnlyHint: true },
|
|
377
|
+
requires: "network",
|
|
378
|
+
description:
|
|
379
|
+
"Export a tamper-evident engagement audit report for one sent email (RMail-style): full event trail (opens, clicks, reader print/copy/forward signals) + totals, plus an HMAC-SHA256 signature over the canonical JSON so the report can be proven unaltered. For legal/compliance use. HONEST LIMIT: proves what mosadd observed; it is not a qualified delivery receipt (ERDS). Owner-scoped.",
|
|
380
|
+
inputSchema: mp0st_audit_export_input,
|
|
381
|
+
handler: mp0st_audit_export as MosaddTool["handler"],
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "mAYL_consent",
|
|
385
|
+
title: "Manage tracking opt-outs",
|
|
386
|
+
annotations: { readOnlyHint: false },
|
|
387
|
+
requires: "network",
|
|
388
|
+
description:
|
|
389
|
+
"Manage recipient tracking opt-outs (GDPR/ePrivacy). action 'list' = recipients who opted out of your tracking; 'check' {recipient} = whether one opted out; 'optin' {recipient} = re-enable. Recipients self-opt-out via the footer link in your tracked emails; mAYL_send then automatically sends them with NO pixel/link-wrap. Owner-scoped.",
|
|
390
|
+
inputSchema: mp0st_consent_input,
|
|
391
|
+
handler: mp0st_consent as MosaddTool["handler"],
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
name: "mAYL_notify",
|
|
395
|
+
title: "Engagement notifications feed",
|
|
396
|
+
annotations: { readOnlyHint: true },
|
|
397
|
+
requires: "network",
|
|
398
|
+
description:
|
|
399
|
+
"Recent engagement feed across ALL your sent mail — the 'who just opened/clicked my mail' notifications stream (opens, clicks, forwards, reader print/copy signals), newest first, each with the email subject + recipient. Poll: pass the returned `cursor` back as `since` to get only new activity. Owner-scoped.",
|
|
400
|
+
inputSchema: mp0st_notify_input,
|
|
401
|
+
handler: mp0st_notify as MosaddTool["handler"],
|
|
248
402
|
},
|
|
249
403
|
];
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mDM agent-attributed send — a person's session speaks AS one of THEIR agents.
|
|
3
|
+
*
|
|
4
|
+
* ── THE PROBLEM THIS SOLVES ──────────────────────────────────────────────────
|
|
5
|
+
* An MCP key is bound to a USER, and the hosted gateway exchanges it for THAT
|
|
6
|
+
* user's session. So when someone adds the connector while signed in as
|
|
7
|
+
* themselves, their agent runtime comes up holding the OWNER'S identity. The
|
|
8
|
+
* founder hit exactly this on 2026-08-17: his "Dispatch" agent authenticated as
|
|
9
|
+
* him, went looking for him among his own contacts, did not find him, and
|
|
10
|
+
* reported the agent↔agent guard as the cause. The real cost was that his mDM
|
|
11
|
+
* had no living 1:1 thread with his dispatcher.
|
|
12
|
+
*
|
|
13
|
+
* With this tool the same session can post AS one of the owner's agents (`<agent>@mosadd.com`), so the
|
|
14
|
+
* DYSPOZYTOR thread fills with messages FROM the dispatcher.
|
|
15
|
+
*
|
|
16
|
+
* ── AUTHORIZATION ────────────────────────────────────────────────────────────
|
|
17
|
+
* Enforced SERVER-SIDE by the `mdm-send-as-agent` Edge Function, never here:
|
|
18
|
+
* the named identity must be `kind='agent'`, owned by the CALLER
|
|
19
|
+
* (`owner_user_id`), and not retired. A client-side check would be decoration —
|
|
20
|
+
* the tool arguments are attacker-controlled by definition.
|
|
21
|
+
*
|
|
22
|
+
* Shape follows the accepted `mAYL_send_as_agent` precedent (owner's credential
|
|
23
|
+
* in, agent-attributed message out). Its AUTH model was deliberately not copied:
|
|
24
|
+
* measured 2026-08-17, `hub-claim-mint` accepts any `agent_id` string and never
|
|
25
|
+
* compares it to an owner, so the agent name in a mAYL provenance stamp is
|
|
26
|
+
* caller-asserted text. That gap is tracked separately; this tool does not
|
|
27
|
+
* reproduce it.
|
|
28
|
+
*
|
|
29
|
+
* Auth transport also differs on purpose: mAYL_send_as_agent reads
|
|
30
|
+
* `process.env.MOSADD_API_KEY`, which does not exist on the hosted multi-tenant
|
|
31
|
+
* gateway (the key is per-request there, not process-wide). This tool goes
|
|
32
|
+
* through `invokeFunction`, i.e. the caller's own session — so it works
|
|
33
|
+
* identically over stdio and over mcp.mosadd.com.
|
|
34
|
+
*
|
|
35
|
+
* Agent DMs travel as plaintext base64 on the established agent lane (the same
|
|
36
|
+
* path agent-dm-responder uses); this tool does not change that property.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
import { z } from "zod";
|
|
40
|
+
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
41
|
+
import { invokeFunction } from "../providers/supabase.js";
|
|
42
|
+
|
|
43
|
+
const mDM_send_as_agent_input = z.object({
|
|
44
|
+
agent: z
|
|
45
|
+
.string()
|
|
46
|
+
.min(1)
|
|
47
|
+
.max(200)
|
|
48
|
+
.describe(
|
|
49
|
+
"Which of YOUR agents to speak as — its mosADD address (<agent>@mosadd.com), " +
|
|
50
|
+
"its identity id, or its display name. Must be an agent you own.",
|
|
51
|
+
),
|
|
52
|
+
text: z.string().min(1).max(8000).describe("The message body, as the agent would write it."),
|
|
53
|
+
to: z
|
|
54
|
+
.string()
|
|
55
|
+
.max(200)
|
|
56
|
+
.optional()
|
|
57
|
+
.describe(
|
|
58
|
+
"Recipient identity id or mosADD address. Defaults to YOU (the key's owner) — " +
|
|
59
|
+
"the common case is an agent reporting to its owner. Must be a person, not another agent.",
|
|
60
|
+
),
|
|
61
|
+
thread_label: z
|
|
62
|
+
.string()
|
|
63
|
+
.min(1)
|
|
64
|
+
.max(120)
|
|
65
|
+
.regex(/^[a-zA-Z0-9._-]+$/)
|
|
66
|
+
.optional()
|
|
67
|
+
.describe(
|
|
68
|
+
"Optional thread label (same as mDM_send). Omit for the MAIN unlabeled thread — required for " +
|
|
69
|
+
"account-owner traffic. A new label opens a new thread.",
|
|
70
|
+
),
|
|
71
|
+
silent: z
|
|
72
|
+
.boolean()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("Deliver without waking a phone: the message still arrives and shows unread, only the OS push is skipped."),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const mDM_list_my_agents_input = z.object({});
|
|
78
|
+
|
|
79
|
+
type SendResult = {
|
|
80
|
+
ok: boolean;
|
|
81
|
+
sent_as: { identity_id: string; address: string | null; display_name: string | null };
|
|
82
|
+
to: { identity_id: string; display_name: string | null };
|
|
83
|
+
thread_id: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
async function mDM_send_as_agent(
|
|
87
|
+
input: z.infer<typeof mDM_send_as_agent_input>,
|
|
88
|
+
ctx: MosaddToolContext,
|
|
89
|
+
): Promise<SendResult> {
|
|
90
|
+
ctx.log("debug", "mDM_send_as_agent", { agent: input.agent, thread_label: input.thread_label });
|
|
91
|
+
return await invokeFunction<SendResult>("mdm-send-as-agent", {
|
|
92
|
+
agent: input.agent,
|
|
93
|
+
text: input.text,
|
|
94
|
+
...(input.to ? { to: input.to } : {}),
|
|
95
|
+
...(input.thread_label ? { thread_label: input.thread_label } : {}),
|
|
96
|
+
...(input.silent ? { silent: true } : {}),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function mDM_list_my_agents(
|
|
101
|
+
_input: z.infer<typeof mDM_list_my_agents_input>,
|
|
102
|
+
ctx: MosaddToolContext,
|
|
103
|
+
): Promise<{ agents: Array<{ identity_id: string; address: string | null; display_name: string | null }> }> {
|
|
104
|
+
ctx.log("debug", "mDM_list_my_agents");
|
|
105
|
+
return await invokeFunction("mdm-send-as-agent", { action: "list_agents" });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const mdmAsAgentTools: MosaddTool[] = [
|
|
109
|
+
{
|
|
110
|
+
name: "mDM_send_as_agent",
|
|
111
|
+
title: "Send DM as your agent",
|
|
112
|
+
annotations: { readOnlyHint: false },
|
|
113
|
+
requires: "network",
|
|
114
|
+
description:
|
|
115
|
+
"Send a direct message AS ONE OF YOUR OWN AGENTS instead of as yourself. Use this when you are an " +
|
|
116
|
+
"agent runtime (Dispatch, Hermes, a CTO agent) connected with your owner's key: without it every " +
|
|
117
|
+
"message you send appears to come FROM the owner, so the owner has no thread with you. Names the " +
|
|
118
|
+
"agent by mosADD address, identity id or display name; `to` defaults to the key's owner. Optional " +
|
|
119
|
+
"`thread_label` selects a named thread (omit = MAIN unlabeled — required for the account owner until " +
|
|
120
|
+
"rename lands). The server verifies you OWN that agent — speaking as someone else's agent, or as " +
|
|
121
|
+
"another person, is refused. Recipient must be a person: agent-to-agent DM stays blocked.",
|
|
122
|
+
inputSchema: mDM_send_as_agent_input,
|
|
123
|
+
handler: mDM_send_as_agent as MosaddTool["handler"],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "mDM_list_my_agents",
|
|
127
|
+
title: "List your agents",
|
|
128
|
+
annotations: { readOnlyHint: true },
|
|
129
|
+
requires: "network",
|
|
130
|
+
description:
|
|
131
|
+
"List the agents you are allowed to speak as with mDM_send_as_agent — every live agent owned by " +
|
|
132
|
+
"the account behind this key, with its identity id, mosADD address and display name. Call this " +
|
|
133
|
+
"first when you are unsure which agent identity you hold.",
|
|
134
|
+
inputSchema: mDM_list_my_agents_input,
|
|
135
|
+
handler: mDM_list_my_agents as MosaddTool["handler"],
|
|
136
|
+
},
|
|
137
|
+
];
|
package/src/tools/mdm-voice.ts
CHANGED
|
@@ -80,8 +80,10 @@ async function signalDm(
|
|
|
80
80
|
const dm = ctx.providers.dm;
|
|
81
81
|
const selfId = await dm.selfId();
|
|
82
82
|
const threadId = dmThreadId(selfId, to, threadLabel);
|
|
83
|
+
// DmProvider.send returns DmSendResult { id, deliveredAt } — read `id` (the old
|
|
84
|
+
// `message_id` lookup was always undefined, so the echoed id never populated).
|
|
83
85
|
const res = await dm.send({ to, threadId, payload: packEnvelope(envelope) });
|
|
84
|
-
return { message_id: (res as {
|
|
86
|
+
return { message_id: (res as { id?: string })?.id, thread_id: threadId };
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
// ---- Handlers ----
|
|
@@ -102,8 +104,12 @@ async function mDM_call_start(
|
|
|
102
104
|
const selfId = await dm.selfId();
|
|
103
105
|
const mode = input.video ? "video" : "audio";
|
|
104
106
|
|
|
105
|
-
// Stable room label tied to the DM
|
|
106
|
-
|
|
107
|
+
// Stable room label tied to the DM PAIR (no thread_label) so re-dials reuse one
|
|
108
|
+
// room AND the name stays short enough that both participants' full identity ids
|
|
109
|
+
// are always present — the livekit-token gate authorizes by full-id inclusion, so
|
|
110
|
+
// truncating an id would lock a real participant out. (thread_label still routes
|
|
111
|
+
// the call_invite message below, just not the room id.)
|
|
112
|
+
const label = `dmcall-${dmThreadId(selfId, input.to).replace(/[^a-zA-Z0-9._-]/g, "-")}`.slice(0, 120);
|
|
107
113
|
const { roomId } = await ctx.providers.voice.createRoom(label);
|
|
108
114
|
const ticket = await ctx.providers.voice.joinTicket(roomId);
|
|
109
115
|
|
|
@@ -173,6 +179,8 @@ async function mDM_voice_note(
|
|
|
173
179
|
export const mdmVoiceTools: MosaddTool[] = [
|
|
174
180
|
{
|
|
175
181
|
name: "mDM_call_start",
|
|
182
|
+
title: "Start a voice call",
|
|
183
|
+
annotations: { readOnlyHint: false },
|
|
176
184
|
requires: "network",
|
|
177
185
|
description:
|
|
178
186
|
"Start a 1:1 real-time voice (or video) call with a contact — the ordinary full-duplex phone-style call (NOT walkie-talkie mTALK, NOT PSTN mCALL). Creates a room, returns join credentials (token + media url), and drops a `call_invite` control message in the DM thread so the contact can answer. Set video:true for video.",
|
|
@@ -181,6 +189,8 @@ export const mdmVoiceTools: MosaddTool[] = [
|
|
|
181
189
|
},
|
|
182
190
|
{
|
|
183
191
|
name: "mDM_call_answer",
|
|
192
|
+
title: "Answer a voice call",
|
|
193
|
+
annotations: { readOnlyHint: false },
|
|
184
194
|
requires: "network",
|
|
185
195
|
description:
|
|
186
196
|
"Answer an incoming 1:1 call by its room_id (from the call_invite seen via mDM_list). Returns join credentials (token + media url) for the same room.",
|
|
@@ -189,6 +199,8 @@ export const mdmVoiceTools: MosaddTool[] = [
|
|
|
189
199
|
},
|
|
190
200
|
{
|
|
191
201
|
name: "mDM_call_end",
|
|
202
|
+
title: "End a voice call",
|
|
203
|
+
annotations: { readOnlyHint: false },
|
|
192
204
|
requires: "network",
|
|
193
205
|
description:
|
|
194
206
|
"End a 1:1 call. The audio leg ends when clients disconnect; pass `to` to also drop a `call_end` (hangup) control message in the contact's DM thread.",
|
|
@@ -197,6 +209,8 @@ export const mdmVoiceTools: MosaddTool[] = [
|
|
|
197
209
|
},
|
|
198
210
|
{
|
|
199
211
|
name: "mDM_voice_note",
|
|
212
|
+
title: "Leave a voice note",
|
|
213
|
+
annotations: { readOnlyHint: false },
|
|
200
214
|
requires: "network",
|
|
201
215
|
description:
|
|
202
216
|
"Send an asynchronous voice note to a contact: references an already-uploaded audio clip (audio_url) and posts it as a `voice_note` message in the DM thread. Use for fire-and-forget voice instead of a live call.",
|