@mosadd/mcp 3.0.0-alpha.17 → 3.0.0-alpha.19
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 +37 -0
- package/README.md +12 -12
- package/dist/bin/mcp.js +1 -1
- package/dist/{chunk-5ZMJB5YU.js → chunk-QUJGZUTE.js} +295 -483
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/package.json +4 -3
- package/src/__tests__/integration.test.ts +3 -3
- package/src/__tests__/server.test.ts +11 -7
- package/src/tools/actions.ts +2 -2
- package/src/tools/attachments.ts +1 -61
- package/src/tools/embed.ts +108 -0
- package/src/tools/index.ts +12 -5
- package/src/tools/mail-provenance.ts +15 -15
- package/src/tools/mail.ts +84 -84
- package/src/tools/threat.ts +92 -0
package/dist/index.d.ts
CHANGED
|
@@ -195,7 +195,10 @@ declare function createMosaddServer(options?: MosaddServerOptions): McpServer;
|
|
|
195
195
|
/**
|
|
196
196
|
* Tool registry. Each m* module contributes a set of tools.
|
|
197
197
|
*
|
|
198
|
-
* Live modules (
|
|
198
|
+
* Live modules (5): mDM, mIRC, mTALK, mp0st, mRAG (58 channel tools) + comms (4)
|
|
199
|
+
* + threat_catalog/threat_classify (pure defensive engine, LINEAR-3498) = 64 callable.
|
|
200
|
+
* mROOM was KILLED (LINEAR-3414, channel re-cut → ephemeral private mIRC): its tools
|
|
201
|
+
* live in tools/mroom.ts + mroom-messages.ts but are NOT registered here.
|
|
199
202
|
* Plus action links: comms_action_create (agent → user one-link browser action,
|
|
200
203
|
* incl. screen_share) + comms_action_frame_get (see the recipient's shared screen).
|
|
201
204
|
* mURL is a consumer/brand surface (murl.mosadd.com), NOT a dev product — its tools
|
package/dist/index.js
CHANGED
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 the
|
|
3
|
+
"version": "3.0.0-alpha.19",
|
|
4
|
+
"description": "Model Context Protocol server for mosadd. Exposes the 5 live m* modules (mDM, mIRC, mTALK, mp0st, mRAG) plus comms + threat tools — 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",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"zod": "^4.3.6",
|
|
40
40
|
"@mosadd/crypto": "3.0.0-alpha.4",
|
|
41
41
|
"@mosadd/providers": "3.0.0-alpha.4",
|
|
42
|
-
"@mosadd/protocol": "3.0.0-alpha.4"
|
|
42
|
+
"@mosadd/protocol": "3.0.0-alpha.4",
|
|
43
|
+
"@mosadd/threat-engine": "3.0.0-alpha.5"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"tsup": "^8.3.5",
|
|
@@ -134,11 +134,11 @@ describe("@mosadd/mcp — integration (real stdio)", () => {
|
|
|
134
134
|
const result = resp.result as { tools?: Array<{ name: string }> };
|
|
135
135
|
const names = result.tools?.map((t) => t.name) ?? [];
|
|
136
136
|
|
|
137
|
-
// All
|
|
137
|
+
// All live channels surface their tools
|
|
138
138
|
expect(names).toContain("mDM_send");
|
|
139
139
|
expect(names).toContain("mIRC_create");
|
|
140
|
-
expect(names).toContain("
|
|
141
|
-
expect(names).toContain("
|
|
140
|
+
expect(names).toContain("threat_classify"); // threat engine exposed (LINEAR-3498); mROOM killed (LINEAR-3414)
|
|
141
|
+
expect(names).toContain("mp0st_send");
|
|
142
142
|
expect(names).toContain("mTALK_press"); // mTALK PTT now shipped
|
|
143
143
|
expect(names).toContain("mRAG_search"); // mRAG RAG-for-devs now shipped
|
|
144
144
|
expect(names).toContain("mIRC_post_message"); // channel messaging now shipped
|
|
@@ -15,19 +15,23 @@ describe("@mosadd/mcp", () => {
|
|
|
15
15
|
// mIRC (5 tools)
|
|
16
16
|
expect(names).toContain("mIRC_create");
|
|
17
17
|
expect(names).toContain("mIRC_delete");
|
|
18
|
-
//
|
|
19
|
-
expect(names).toContain("
|
|
20
|
-
expect(names).toContain("
|
|
21
|
-
//
|
|
22
|
-
expect(names).toContain("
|
|
23
|
-
expect(names).toContain("
|
|
18
|
+
// threat engine (LINEAR-3498) — mROOM killed (LINEAR-3414)
|
|
19
|
+
expect(names).toContain("threat_catalog");
|
|
20
|
+
expect(names).toContain("threat_classify");
|
|
21
|
+
// mp0st (2 tools)
|
|
22
|
+
expect(names).toContain("mp0st_send");
|
|
23
|
+
expect(names).toContain("mp0st_view");
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it("follows RFC 0001 naming — channel tools m<MODULE>_<operation>, meta tools comms_<op>", () => {
|
|
27
27
|
const channelName = /^m[A-Z][A-Z0-9_]*_[a-z][a-z0-9_]*$/;
|
|
28
|
+
const mailName = /^mp0st_[a-z][a-z0-9_]*$/; // mail module codename (LINEAR-3464)
|
|
28
29
|
const metaName = /^comms_[a-z][a-z0-9_]*$/; // discovery/meta namespace
|
|
30
|
+
const threatName = /^threat_[a-z][a-z0-9_]*$/; // defensive threat engine (LINEAR-3498)
|
|
29
31
|
for (const tool of allTools) {
|
|
30
|
-
expect(tool.name).toMatch(
|
|
32
|
+
expect(tool.name).toMatch(
|
|
33
|
+
new RegExp(`${channelName.source}|${mailName.source}|${metaName.source}|${threatName.source}`),
|
|
34
|
+
);
|
|
31
35
|
}
|
|
32
36
|
});
|
|
33
37
|
|
package/src/tools/actions.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Mint a single-use, expiring link (`https://mosadd.com/do/<token>`) that asks a
|
|
5
5
|
* human to DO something in their browser — confirm, pick a file, fill a form, or
|
|
6
6
|
* open a vetted URL — with explicit consent. Send the returned `link` to the
|
|
7
|
-
* person via any channel (mDM/mIRC/
|
|
7
|
+
* person via any channel (mDM/mIRC/mp0st). They open it, see what's asked, consent,
|
|
8
8
|
* and the browser performs the action IN ITS SANDBOX, then the result is recorded
|
|
9
9
|
* against the action. No install, no OS access, nothing runs without a user gesture.
|
|
10
10
|
*
|
|
@@ -147,7 +147,7 @@ export const actionTools: MosaddTool[] = [
|
|
|
147
147
|
name: "comms_action_create",
|
|
148
148
|
requires: "network",
|
|
149
149
|
description:
|
|
150
|
-
"Mint a single-use, expiring action link (https://mosadd.com/do/<token>) that asks a human to DO something in their browser, with explicit consent. action_type: 'confirm' (yes/no) | 'file_request' (recipient picks a file from their computer) | 'form' (recipient fills fields you define) | 'open_url' (recipient opens a vetted https URL). Returns { action_id, token, link, expires_at }. Send the `link` to the person via mDM/mIRC/
|
|
150
|
+
"Mint a single-use, expiring action link (https://mosadd.com/do/<token>) that asks a human to DO something in their browser, with explicit consent. action_type: 'confirm' (yes/no) | 'file_request' (recipient picks a file from their computer) | 'form' (recipient fills fields you define) | 'open_url' (recipient opens a vetted https URL). Returns { action_id, token, link, expires_at }. Send the `link` to the person via mDM/mIRC/mp0st; they open it, consent, and the browser performs the action in its sandbox (no install, no OS access). The action is owned by you (the calling user). HONEST LIMITS: this is browser-sandbox only — it cannot click other apps, run programs, or read files the user didn't pick; and file_request payloads are not yet end-to-end encrypted (don't request sensitive files until Tier 1.1).",
|
|
151
151
|
inputSchema: action_create_input,
|
|
152
152
|
handler: action_create as MosaddTool["handler"],
|
|
153
153
|
},
|
package/src/tools/attachments.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Symmetric voice + file attachments across channels (mDM,
|
|
2
|
+
* Symmetric voice + file attachments across channels (mDM, mIRC).
|
|
3
3
|
*
|
|
4
4
|
* GOAL (Lane C): an AGENT must be able to participate in every channel the same
|
|
5
5
|
* way a human does — including sending VOICE notes and FILES, not just text.
|
|
@@ -194,52 +194,6 @@ async function mDM_send_file(input: z.infer<typeof mDM_send_file_input>, ctx: Mo
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
// ====================================================================
|
|
198
|
-
// mROOM voice/file
|
|
199
|
-
// ====================================================================
|
|
200
|
-
|
|
201
|
-
const mROOM_send_voice_input = z.object({
|
|
202
|
-
room_id: RoomId,
|
|
203
|
-
audio_base64: Base64Body,
|
|
204
|
-
mime: Mime.default("audio/ogg"),
|
|
205
|
-
duration_ms: DurationMs,
|
|
206
|
-
caption: z.string().max(2_000).optional(),
|
|
207
|
-
reply_to_id: ReplyTo,
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const mROOM_send_file_input = z.object({
|
|
211
|
-
room_id: RoomId,
|
|
212
|
-
file_base64: Base64Body,
|
|
213
|
-
filename: Filename,
|
|
214
|
-
mime: Mime,
|
|
215
|
-
caption: z.string().max(2_000).optional(),
|
|
216
|
-
reply_to_id: ReplyTo,
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
async function mROOM_send_voice(input: z.infer<typeof mROOM_send_voice_input>, ctx: MosaddToolContext) {
|
|
220
|
-
const thread_id = `privroom:${input.room_id}`;
|
|
221
|
-
const attachment = await uploadBlob({
|
|
222
|
-
kind: "voice",
|
|
223
|
-
bytes: decodeBase64Body(input.audio_base64),
|
|
224
|
-
mime: input.mime,
|
|
225
|
-
prefix: thread_id,
|
|
226
|
-
duration_ms: input.duration_ms,
|
|
227
|
-
});
|
|
228
|
-
return sendAttachmentMessage(ctx, { space_id: "rooms", thread_id, message_type: "voice", attachment, caption: input.caption, reply_to_id: input.reply_to_id });
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
async function mROOM_send_file(input: z.infer<typeof mROOM_send_file_input>, ctx: MosaddToolContext) {
|
|
232
|
-
const thread_id = `privroom:${input.room_id}`;
|
|
233
|
-
const attachment = await uploadBlob({
|
|
234
|
-
kind: "file",
|
|
235
|
-
bytes: decodeBase64Body(input.file_base64),
|
|
236
|
-
mime: input.mime,
|
|
237
|
-
prefix: thread_id,
|
|
238
|
-
filename: input.filename,
|
|
239
|
-
});
|
|
240
|
-
return sendAttachmentMessage(ctx, { space_id: "rooms", thread_id, message_type: "file", attachment, caption: input.caption, reply_to_id: input.reply_to_id });
|
|
241
|
-
}
|
|
242
|
-
|
|
243
197
|
// ====================================================================
|
|
244
198
|
// mIRC voice/file
|
|
245
199
|
// ====================================================================
|
|
@@ -297,20 +251,6 @@ export const attachmentTools: MosaddTool[] = [
|
|
|
297
251
|
inputSchema: mDM_send_file_input,
|
|
298
252
|
handler: mDM_send_file as MosaddTool["handler"],
|
|
299
253
|
},
|
|
300
|
-
{
|
|
301
|
-
name: "mROOM_send_voice",
|
|
302
|
-
requires: "network",
|
|
303
|
-
description: "Send a VOICE note into a room as a first-class `voice` message. Base64 audio → Storage → message-send. Be a room member first (mROOM_join).",
|
|
304
|
-
inputSchema: mROOM_send_voice_input,
|
|
305
|
-
handler: mROOM_send_voice as MosaddTool["handler"],
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
name: "mROOM_send_file",
|
|
309
|
-
requires: "network",
|
|
310
|
-
description: "Send a FILE into a room as a first-class `file` message. Base64 bytes → Storage → message-send.",
|
|
311
|
-
inputSchema: mROOM_send_file_input,
|
|
312
|
-
handler: mROOM_send_file as MosaddTool["handler"],
|
|
313
|
-
},
|
|
314
254
|
{
|
|
315
255
|
name: "mIRC_send_voice",
|
|
316
256
|
requires: "network",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* comms_embed — let a builder-agent drop a LIVE mosadd channel into the app/site
|
|
3
|
+
* it is generating.
|
|
4
|
+
*
|
|
5
|
+
* Mints a publishable embed key (`m_pk_live_…`) scoped to a channel + the app's
|
|
6
|
+
* domain(s) via the `embed-keys` Edge Function, and returns a paste-in HTML
|
|
7
|
+
* snippet that loads the mosadd widget from the CDN (embed.mosadd.com/v1.js).
|
|
8
|
+
*
|
|
9
|
+
* Security: the publishable key is safe to ship in HTML — it can ONLY mint
|
|
10
|
+
* channel-scoped JWTs (the widget exchanges it at runtime via `mirc-embed-token`,
|
|
11
|
+
* validated against the key's origin allow-list). Your hub key (`mosadd_sk_live_…`)
|
|
12
|
+
* never enters the browser. The action is owned by the calling user (user-JWT
|
|
13
|
+
* scoped — `mosadd login` / MOSADD_USER_JWT / hub-key exchange).
|
|
14
|
+
*
|
|
15
|
+
* Reuses the shipped embed infra (apps/embed widget + embed-keys + mirc-embed-token).
|
|
16
|
+
* RFC 0001: channel-agnostic capability → `comms_` namespace (not an m<MODULE>_ prefix).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
21
|
+
import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
|
|
22
|
+
|
|
23
|
+
/** Widget CDN base. Override with MOSADD_EMBED_CDN for self-host / dev. */
|
|
24
|
+
const EMBED_CDN = (process.env.MOSADD_EMBED_CDN ?? "https://embed.mosadd.com").replace(/\/+$/, "");
|
|
25
|
+
|
|
26
|
+
const POSITIONS = ["inline", "sidebar-left", "sidebar-right", "floating-bl", "floating-br", "fullscreen"] as const;
|
|
27
|
+
const SKINS = ["default", "retro-irc-1990", "terminal", "minimal-dark", "minimal-light"] as const;
|
|
28
|
+
|
|
29
|
+
const embed_create_input = z.object({
|
|
30
|
+
channel: z
|
|
31
|
+
.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/)
|
|
32
|
+
.describe("The mIRC channel id everyone on the embed shares (e.g. 'acme-support'). Auto-created on first message if new."),
|
|
33
|
+
allowed_origins: z
|
|
34
|
+
.array(z.string().min(1)).min(1).max(10)
|
|
35
|
+
.describe("REQUIRED. Domain(s) where the widget will be served — the key only works from these origins. Use the host(s) of the app you're building, e.g. ['app.acme.com','*.acme.com']. For local testing use mode:'test' and e.g. 'localhost:3000'."),
|
|
36
|
+
name: z.string().max(64).optional().describe("Label for the key in the owner's dashboard. Default 'embed: <channel>'."),
|
|
37
|
+
position: z.enum(POSITIONS).optional().describe("Where the widget renders. Default 'inline'."),
|
|
38
|
+
skin: z.enum(SKINS).optional().describe("Visual skin. Default 'default' (mosadd-branded retro mIRC)."),
|
|
39
|
+
title: z.string().max(60).optional().describe("Header title shown in the widget. Default 'mIRC'."),
|
|
40
|
+
anon: z.boolean().optional().describe("Allow visitors to join with just a nick (no mosadd account). Default true."),
|
|
41
|
+
locale: z.enum(["en", "pl"]).optional().describe("Widget UI language. Default 'en'."),
|
|
42
|
+
mode: z.enum(["live", "test"]).optional().describe("Key mode — 'test' for local/dev origins, 'live' for production. Default 'live'."),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
interface EmbedKeyResult {
|
|
46
|
+
id?: string;
|
|
47
|
+
key?: string;
|
|
48
|
+
pk_prefix?: string;
|
|
49
|
+
allowed_channels?: string[];
|
|
50
|
+
error?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface EmbedCreateResult {
|
|
54
|
+
embed_key: string;
|
|
55
|
+
channel: string;
|
|
56
|
+
allowed_origins: string[];
|
|
57
|
+
snippet: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** HTML-attr-safe: drop quotes/angle brackets (inputs are already length-bounded). */
|
|
61
|
+
const attrSafe = (s: string): string => s.replace(/["'<>]/g, "");
|
|
62
|
+
|
|
63
|
+
function buildSnippet(input: z.infer<typeof embed_create_input>, key: string): string {
|
|
64
|
+
const attrs = [`data-channel="${attrSafe(input.channel)}"`, `data-position="${input.position ?? "inline"}"`];
|
|
65
|
+
if (input.skin) attrs.push(`data-skin="${input.skin}"`);
|
|
66
|
+
if (input.title) attrs.push(`data-title="${attrSafe(input.title)}"`);
|
|
67
|
+
if (input.anon === false) attrs.push(`data-anon="false"`);
|
|
68
|
+
if (input.locale) attrs.push(`data-locale="${input.locale}"`);
|
|
69
|
+
return (
|
|
70
|
+
`<div id="mosadd-mirc" ${attrs.join(" ")}></div>\n` +
|
|
71
|
+
`<script src="${EMBED_CDN}/v1.js" data-key="${key}"></script>`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function embed_create(
|
|
76
|
+
input: z.infer<typeof embed_create_input>,
|
|
77
|
+
ctx: MosaddToolContext,
|
|
78
|
+
): Promise<EmbedCreateResult> {
|
|
79
|
+
readSupabaseEnv();
|
|
80
|
+
ctx.log("debug", "comms_embed_create minting embed key", { channel: input.channel, origins: input.allowed_origins.length });
|
|
81
|
+
|
|
82
|
+
const res = await invokeFunction<EmbedKeyResult>("embed-keys", {
|
|
83
|
+
name: input.name ?? `embed: ${input.channel}`,
|
|
84
|
+
channels: [input.channel],
|
|
85
|
+
allowed_origins: input.allowed_origins,
|
|
86
|
+
mode: input.mode ?? "live",
|
|
87
|
+
});
|
|
88
|
+
if (res.error) throw new Error(res.error);
|
|
89
|
+
if (!res.key) throw new Error("embed-keys returned no publishable key (missing `key`).");
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
embed_key: res.key,
|
|
93
|
+
channel: input.channel,
|
|
94
|
+
allowed_origins: input.allowed_origins,
|
|
95
|
+
snippet: buildSnippet(input, res.key),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const embedTools: MosaddTool[] = [
|
|
100
|
+
{
|
|
101
|
+
name: "comms_embed_create",
|
|
102
|
+
requires: "network",
|
|
103
|
+
description:
|
|
104
|
+
"Embed a LIVE mosadd chat channel into an app/site you're building (great for builder-agents on Lovable/Bolt/Cursor/v0). Mints a publishable embed key scoped to a channel + the app's domain(s) and returns a ready-to-paste HTML snippet (a <div> + <script src=embed.mosadd.com/v1.js data-key=…>). Visitors of the host page chat in real time (anonymous nick or mosadd login). REQUIRES `allowed_origins` — the domain(s) the app is served from (the key only works there). The publishable key is browser-safe (mints only channel-scoped JWTs); your hub key never leaves the server. Returns { embed_key, channel, allowed_origins, snippet }.",
|
|
105
|
+
inputSchema: embed_create_input,
|
|
106
|
+
handler: embed_create as MosaddTool["handler"],
|
|
107
|
+
},
|
|
108
|
+
];
|
package/src/tools/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool registry. Each m* module contributes a set of tools.
|
|
3
3
|
*
|
|
4
|
-
* Live modules (
|
|
4
|
+
* Live modules (5): mDM, mIRC, mTALK, mp0st, mRAG (58 channel tools) + comms (4)
|
|
5
|
+
* + threat_catalog/threat_classify (pure defensive engine, LINEAR-3498) = 64 callable.
|
|
6
|
+
* mROOM was KILLED (LINEAR-3414, channel re-cut → ephemeral private mIRC): its tools
|
|
7
|
+
* live in tools/mroom.ts + mroom-messages.ts but are NOT registered here.
|
|
5
8
|
* Plus action links: comms_action_create (agent → user one-link browser action,
|
|
6
9
|
* incl. screen_share) + comms_action_frame_get (see the recipient's shared screen).
|
|
7
10
|
* mURL is a consumer/brand surface (murl.mosadd.com), NOT a dev product — its tools
|
|
@@ -18,8 +21,8 @@ import { mircTools } from "./mirc.js";
|
|
|
18
21
|
import { mircMembersTools } from "./mirc-members.js";
|
|
19
22
|
import { mircMessagesTools } from "./mirc-messages.js";
|
|
20
23
|
import { mircEdgeTools } from "./mirc-edge.js";
|
|
21
|
-
import { mroomTools } from "./mroom.js";
|
|
22
|
-
import { mroomMessagesTools } from "./mroom-messages.js";
|
|
24
|
+
// import { mroomTools } from "./mroom.js"; // mROOM: killed (LINEAR-3414) — not registered
|
|
25
|
+
// import { mroomMessagesTools } from "./mroom-messages.js"; // mROOM: killed (LINEAR-3414) — not registered
|
|
23
26
|
import { mailTools } from "./mail.js";
|
|
24
27
|
import { mailProvenanceTools } from "./mail-provenance.js";
|
|
25
28
|
import { mtalkTools } from "./mtalk.js";
|
|
@@ -28,6 +31,8 @@ import { pttIngestTools } from "./ptt-ingest.js";
|
|
|
28
31
|
// import { mcallTools } from "./mcall.js"; // mCALL: carrier-pending — not registered (see header note)
|
|
29
32
|
import { knowledgeTools } from "./knowledge.js";
|
|
30
33
|
import { actionTools } from "./actions.js";
|
|
34
|
+
import { embedTools } from "./embed.js";
|
|
35
|
+
import { threatTools } from "./threat.js";
|
|
31
36
|
// import { murlTools } from "./murl.js"; // mURL: brand/consumer surface, not a dev product — not registered
|
|
32
37
|
import { makeCapabilitiesTool } from "./capabilities.js";
|
|
33
38
|
|
|
@@ -39,8 +44,8 @@ const channelTools: MosaddTool[] = [
|
|
|
39
44
|
...mircMembersTools,
|
|
40
45
|
...mircMessagesTools,
|
|
41
46
|
...mircEdgeTools,
|
|
42
|
-
...mroomTools,
|
|
43
|
-
...mroomMessagesTools,
|
|
47
|
+
// ...mroomTools, // mROOM: killed (LINEAR-3414) — channel re-cut into ephemeral private mIRC
|
|
48
|
+
// ...mroomMessagesTools, // mROOM: killed (LINEAR-3414)
|
|
44
49
|
...mailTools,
|
|
45
50
|
...mailProvenanceTools,
|
|
46
51
|
...mtalkTools,
|
|
@@ -48,6 +53,8 @@ const channelTools: MosaddTool[] = [
|
|
|
48
53
|
...pttIngestTools,
|
|
49
54
|
...knowledgeTools,
|
|
50
55
|
...actionTools, // Action links (Tier 1): agent → user one-link browser action via action-create EF
|
|
56
|
+
...embedTools, // comms_embed_create: agent embeds a live channel into the app it builds (embed-keys EF + embed.mosadd.com widget)
|
|
57
|
+
...threatTools, // threat_catalog + threat_classify: pure defensive threat-event engine (@mosadd/threat-engine, LINEAR-3498)
|
|
51
58
|
// ...murlTools, // mURL: brand/consumer surface (murl.mosadd.com), not a dev product
|
|
52
59
|
// ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
|
|
53
60
|
// mirlTools,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* mp0st provenance — agent-attributed email send.
|
|
3
3
|
*
|
|
4
|
-
* The plain `
|
|
4
|
+
* The plain `mp0st_send` (mail.ts) sends as the USER. When an AGENT sends mail on
|
|
5
5
|
* the user's behalf, the recipient (and the audit trail) should be able to tell
|
|
6
6
|
* it was agent-originated. Per the Lane A contract, `mp0st-send`, when called
|
|
7
7
|
* with a HUB-CLAIM JWT, stamps the row with:
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* This tool mints/forwards that hub-claim JWT and sets the provenance fields.
|
|
11
11
|
*
|
|
12
|
-
* AUTH MODEL (differs from the rest of
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
12
|
+
* AUTH MODEL (differs from the rest of mp0st):
|
|
13
|
+
* - mp0st_send uses the user's Supabase session JWT (via invokeFunction).
|
|
14
|
+
* - mp0st_send_as_agent presents a HUB-CLAIM JWT (hub key → claim exchange) so
|
|
15
15
|
* mp0st-send can attribute the send to the agent/task.
|
|
16
16
|
*
|
|
17
17
|
* STATUS: scaffold. The hub-claim exchange endpoint is assumed (TODO Lane A —
|
|
@@ -39,7 +39,7 @@ function hubKey(): string | null {
|
|
|
39
39
|
|
|
40
40
|
const EmailAddress = z.string().email().max(254);
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const mp0st_send_as_agent_input = z.object({
|
|
43
43
|
to: z.union([EmailAddress, z.array(EmailAddress).min(1).max(50)]),
|
|
44
44
|
subject: z.string().min(1).max(998),
|
|
45
45
|
body_text: z.string().max(1_048_576).optional(),
|
|
@@ -69,7 +69,7 @@ const mAIL_send_as_agent_input = z.object({
|
|
|
69
69
|
async function mintHubClaim(agentId: string, taskId?: string): Promise<string> {
|
|
70
70
|
const key = hubKey();
|
|
71
71
|
if (!key) {
|
|
72
|
-
throw new Error("
|
|
72
|
+
throw new Error("mp0st_send_as_agent needs MOSADD_API_KEY (hub key) to mint a provenance claim.");
|
|
73
73
|
}
|
|
74
74
|
const r = await fetch(`${supabaseUrl()}/functions/v1/hub-claim-mint`, {
|
|
75
75
|
method: "POST",
|
|
@@ -85,19 +85,19 @@ async function mintHubClaim(agentId: string, taskId?: string): Promise<string> {
|
|
|
85
85
|
return data.token;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
async function
|
|
89
|
-
input: z.infer<typeof
|
|
88
|
+
async function mp0st_send_as_agent(
|
|
89
|
+
input: z.infer<typeof mp0st_send_as_agent_input>,
|
|
90
90
|
ctx: MosaddToolContext,
|
|
91
91
|
): Promise<{ message_id: string; status: string; is_internal: boolean; sent_by: "agent" }> {
|
|
92
92
|
if (!input.body_text && !input.body_html) {
|
|
93
|
-
throw new Error("
|
|
93
|
+
throw new Error("mp0st_send_as_agent requires at least one of body_text or body_html.");
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// Present the hub-claim JWT directly to mp0st-send (NOT the user session client)
|
|
97
97
|
// so the EF attributes the row to the agent. TODO(Lane A): confirm mp0st-send
|
|
98
98
|
// accepts a Bearer hub-claim and reads sent_by_agent_id / sent_by_task_id.
|
|
99
99
|
const claim = await mintHubClaim(input.agent_id, input.task_id);
|
|
100
|
-
ctx.log("debug", "
|
|
100
|
+
ctx.log("debug", "mp0st_send_as_agent invoking mp0st-send with hub-claim", { agent_id: input.agent_id });
|
|
101
101
|
|
|
102
102
|
const { agent_id, task_id, ...mailFields } = input;
|
|
103
103
|
const r = await fetch(`${supabaseUrl()}/functions/v1/mp0st-send`, {
|
|
@@ -127,11 +127,11 @@ async function mAIL_send_as_agent(
|
|
|
127
127
|
|
|
128
128
|
export const mailProvenanceTools: MosaddTool[] = [
|
|
129
129
|
{
|
|
130
|
-
name: "
|
|
130
|
+
name: "mp0st_send_as_agent",
|
|
131
131
|
requires: "network",
|
|
132
132
|
description:
|
|
133
|
-
"Send an email ATTRIBUTED TO THE AGENT (provenance-stamped). Unlike
|
|
134
|
-
inputSchema:
|
|
135
|
-
handler:
|
|
133
|
+
"Send an email ATTRIBUTED TO THE AGENT (provenance-stamped). Unlike mp0st_send (sends as the user), this stamps sent_by='agent' plus your agent_id and optional task_id onto the email record and audit trail — so recipients and compliance can see the mail was agent-originated. Auth: presents a hub-claim JWT (needs MOSADD_API_KEY). SCAFFOLD: depends on mp0st-send honoring the hub-claim + provenance fields (TODO Lane A).",
|
|
134
|
+
inputSchema: mp0st_send_as_agent_input,
|
|
135
|
+
handler: mp0st_send_as_agent as MosaddTool["handler"],
|
|
136
136
|
},
|
|
137
137
|
];
|