@mosadd/mcp 3.0.0-alpha.25 → 3.0.0-alpha.27
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/README.md +17 -9
- package/dist/bin/mcp.js +1 -1
- package/dist/{chunk-EJQT6FXI.js → chunk-EE7UQFSI.js} +96 -40
- package/dist/index.d.ts +13 -9
- package/dist/index.js +1 -1
- package/package.json +6 -6
- package/src/__tests__/integration.test.ts +3 -2
- package/src/__tests__/server.test.ts +5 -4
- package/src/server.ts +1 -1
- package/src/tools/index.ts +22 -24
- package/src/tools/mail-aliases.ts +2 -2
- package/src/tools/mail-provenance.ts +22 -24
- package/src/tools/mail.ts +5 -5
- package/src/tools/murl.ts +27 -13
- package/src/tools/ptt-ingest.ts +58 -53
- package/src/tools/threat.ts +30 -3
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# @mosadd/mcp
|
|
2
2
|
|
|
3
|
-
MCP server for [mosADD](https://mosadd.com) —
|
|
3
|
+
**They're apps. We're the layer.** The MCP server for [mosADD](https://mosadd.com) — the omnichannel comms layer for humans, agents, and robots. It exposes the OS modules (m\*) — **mDM (1:1 E2EE), mIRC (in-app channels), mURL (open/embeddable rooms), and mAYL (email 3.0)** — as Model Context Protocol tools, so any agent runtime becomes a first-class contact your team can message and direct: Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, or your own.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
One key, one server, 70+ tools — MCP-native, no SDK to wire up. **Encrypted where it counts, honest where it isn't:** only mDM is end-to-end (Signal X3DH + Double Ratchet, keys on-device, never on our servers); every other channel is server-readable and labeled as such.
|
|
6
|
+
|
|
7
|
+
> **70+ tools** across **4 modules** (mDM, mIRC, mURL, mAYL) + cross-cutting capabilities (mTALK voice, mRAG search, comms agent-actions) + agent→user action links + the `comms_capabilities` discovery tool, wired to the mosADD backend (BYOK) as a strangler-fig step. Phase 2 routes through the hosted gateway at `mcp.mosadd.com`.
|
|
6
8
|
|
|
7
9
|
## Connect your agent
|
|
8
10
|
|
|
9
|
-
Three ways to authenticate, friendliest first — all three end with the same
|
|
11
|
+
Three ways to authenticate, friendliest first — all three end with the same 70+ tools.
|
|
10
12
|
|
|
11
13
|
### 1. `mosadd login` — recommended (one command, stays logged in)
|
|
12
14
|
|
|
@@ -65,19 +67,19 @@ In Phase 2 the hosted gateway at `mcp.mosadd.com` removes even this — add a UR
|
|
|
65
67
|
|
|
66
68
|
## Tools shipped in alpha
|
|
67
69
|
|
|
68
|
-
**
|
|
70
|
+
**70+ tools** — 4 modules (mDM, mIRC, mURL, mAYL) + capabilities (mTALK voice, mRAG search, comms agent-actions) + the `comms_capabilities` discovery tool. Highlights per module:
|
|
69
71
|
|
|
70
72
|
| Module | Tools | What it does |
|
|
71
73
|
|---|---|---|
|
|
72
|
-
| **mDM** (14) | `mDM_list_contacts`, `mDM_send`, `mDM_send_unencrypted
|
|
74
|
+
| **mDM** (14) | `mDM_list_contacts`, `mDM_send`, `mDM_send_unencrypted` (DEPRECATED — migration-window fallback, only when the peer hasn't published keys), `mDM_edit`, `mDM_delete`, `mDM_list`, `mDM_publish_keys`, `mDM_respond_request`, `mDM_call_start/answer/end`, `mDM_voice_note`, `mDM_send_voice`, `mDM_send_file` | 1:1 text, voice notes, calls + file/voice attachments. Multi-thread per contact. `mDM_send` is end-to-end encrypted by default (X3DH / Double Ratchet, `mosadd.e2ee.v2`); the operator cannot read message content |
|
|
73
75
|
| **mIRC** (22) | `mIRC_create/list/get/update/delete`, member RBAC (`mIRC_join/leave/kick/ban/unban/set_role/set_ptt/approve_request/reject_request/request_access`), `mIRC_post_message`, `mIRC_list_messages`, edge (`mIRC_mint_channel_token`, `mIRC_send_edge`, `mIRC_history_edge`), `mIRC_send_voice/file` | Persistent Discord/Slack-style channels + the agent-coordination edge transport |
|
|
74
|
-
| **
|
|
76
|
+
| **mURL** (4) | `mURL_read_channel`, `mURL_post`, `mURL_presence`, `mURL_list_channels` | IRC-for-URLs — open-web text rooms you can embed/share, no account needed; transport-encrypted, server-readable/public by design |
|
|
77
|
+
| **mAYL** (11) | `mAYL_send`, `mAYL_view`, `mAYL_list`, `mAYL_delete`, `mAYL_stats`, `mAYL_events`, `mAYL_metrics`, `mAYL_revoke`, `mAYL_audit_export`, `mAYL_consent`, `mAYL_notify` | Mail; every user gets `<id>@mosadd.com`. Transport + at-rest encrypted (server-readable), NOT E2EE. `mAYL_revoke` recalls secure-reader access; `mAYL_audit_export` emits an HMAC-SHA256-signed engagement audit; `mAYL_consent` manages recipient tracking opt-outs (GDPR); `mAYL_notify` pulls the inbound-mail feed. (Was mp0st; deprecated `mp0st_*` aliases still function until alpha.27) |
|
|
75
78
|
| **mTALK** (5) | `mTALK_open`, `mTALK_join`, `mTALK_press`, `mTALK_release`, `mTALK_state` | Half-duplex push-to-talk: one speaker, FIFO queue, anti-hog auto-release |
|
|
76
79
|
| **mRAG** (4) | `mRAG_ingest`, `mRAG_search`, `mRAG_list_sources`, `mRAG_delete` | RAG recall over the user's own data (hybrid vector + BM25) |
|
|
77
80
|
| **comms_** (3) | `comms_action_create`, `comms_action_frame_get`, `comms_capabilities` | `comms_action_create` mints an agent→user one-link browser action (Tier 1); `comms_action_frame_get` fetches a framed action; `comms_capabilities` is one-call discovery of every tool's transport `requires` flag |
|
|
78
|
-
| **threat_** (2) | `threat_catalog`, `threat_classify` | Pure defensive threat-event classification engine — enumerate the catalog and classify an operation against it |
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
Module tools: mDM (14) + mIRC (22) + mURL (4) + mAYL (11) = 51; capabilities: mTALK (5) + mRAG (4) + comms (3) = 12; plus the deprecated `mp0st_*` back-compat aliases for the mAYL rename — **70+ callable tools** in total. `threat_*` is unregistered — threat classification lives on-device as a security pillar, not as MCP tools. `mCALL` (telephony), `mROOM` — and the `mAYL_send_as_agent` provenance, `mTALK_ingest_ptt` PTT-ingest, and `comms_embed_create` (embed-keys EF undeployed) scaffolds — exist in the source but are **not registered**, so agents only ever see tools that actually work.
|
|
81
83
|
|
|
82
84
|
All tool names follow [RFC 0001](https://github.com/Hei33enberg/mosadd-os/blob/main/docs/rfcs/0001-module-naming.md) — `m<MODULE>_<operation>` snake_case.
|
|
83
85
|
|
|
@@ -125,7 +127,7 @@ For PTT / CALL (real-time media), the architecture separates **control plane** (
|
|
|
125
127
|
| `MOSADD_SUPABASE_URL` | Supabase project URL — DM / IRC / mail / KB backend | yes (BYOK) |
|
|
126
128
|
| `MOSADD_SUPABASE_ANON_KEY` | Supabase anon key | yes (BYOK) |
|
|
127
129
|
| `MOSADD_USER_JWT` | User session token | yes (for tools that touch user data) |
|
|
128
|
-
| `MOSADD_RESEND_API_KEY` | Resend API key — enables `
|
|
130
|
+
| `MOSADD_RESEND_API_KEY` | Resend API key — enables `mAYL` outbound mail (deprecated `mp0st_*` aliases still function) | no (mAYL disabled if unset) |
|
|
129
131
|
| `MOSADD_LIVEKIT_URL` | LiveKit `wss://…` URL — enables `mTALK` voice | no (voice disabled if unset) |
|
|
130
132
|
| `MOSADD_LIVEKIT_API_KEY` | LiveKit API key | no (with `…_URL` / `…_API_SECRET`) |
|
|
131
133
|
| `MOSADD_LIVEKIT_API_SECRET` | LiveKit API secret | no |
|
|
@@ -136,6 +138,12 @@ For PTT / CALL (real-time media), the architecture separates **control plane** (
|
|
|
136
138
|
|
|
137
139
|
Missing optional keys fail closed — that channel is simply absent from `comms_capabilities`.
|
|
138
140
|
|
|
141
|
+
## Links
|
|
142
|
+
|
|
143
|
+
- **Mint a key + docs** — [mosadd.com/keys](https://mosadd.com/keys) · [mosadd.com/docs](https://mosadd.com/docs) · [mosadd.com/mcp](https://mosadd.com/mcp)
|
|
144
|
+
- **Hosted gateway** — `https://mcp.mosadd.com/mcp` (BYOK key broker, zero-install for remote agents)
|
|
145
|
+
- **Source + self-host** — [github.com/Hei33enberg/mosADD-OS](https://github.com/Hei33enberg/mosADD-OS) (Apache-2.0)
|
|
146
|
+
|
|
139
147
|
## License
|
|
140
148
|
|
|
141
149
|
Apache-2.0. See repo [LICENSE](https://github.com/Hei33enberg/mosadd-os/blob/main/LICENSE) and [NOTICE](https://github.com/Hei33enberg/mosadd-os/blob/main/NOTICE).
|
package/dist/bin/mcp.js
CHANGED
|
@@ -1260,7 +1260,7 @@ var mircEdgeTools = [
|
|
|
1260
1260
|
// src/tools/mail.ts
|
|
1261
1261
|
import { z as z7 } from "zod";
|
|
1262
1262
|
var EmailAddress = z7.string().email().max(254).describe("RFC 5321 email address.");
|
|
1263
|
-
var MessageId = z7.string().min(1).describe("Message id (UUID) from
|
|
1263
|
+
var MessageId = z7.string().min(1).describe("Message id (UUID) from mAYL_send or inbox.");
|
|
1264
1264
|
var mp0st_send_input = z7.object({
|
|
1265
1265
|
to: z7.union([EmailAddress, z7.array(EmailAddress).min(1).max(50)]).describe(
|
|
1266
1266
|
"Recipient(s). Single address or array of up to 50."
|
|
@@ -1388,7 +1388,7 @@ var mailTools = [
|
|
|
1388
1388
|
{
|
|
1389
1389
|
name: "mAYL_list",
|
|
1390
1390
|
requires: "network",
|
|
1391
|
-
description: "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
|
|
1391
|
+
description: "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.",
|
|
1392
1392
|
inputSchema: mp0st_list_input,
|
|
1393
1393
|
handler: mp0st_list
|
|
1394
1394
|
},
|
|
@@ -1409,7 +1409,7 @@ var mailTools = [
|
|
|
1409
1409
|
{
|
|
1410
1410
|
name: "mAYL_delete",
|
|
1411
1411
|
requires: "network",
|
|
1412
|
-
description: "Delete one of the user's emails by message_id (from
|
|
1412
|
+
description: "Delete one of the user's emails by message_id (from mAYL_list). Soft-delete \u2014 it stops showing in mAYL_list. Owner-scoped: only your own mail.",
|
|
1413
1413
|
inputSchema: mp0st_delete_input,
|
|
1414
1414
|
handler: mp0st_delete
|
|
1415
1415
|
},
|
|
@@ -1423,7 +1423,7 @@ var mailTools = [
|
|
|
1423
1423
|
{
|
|
1424
1424
|
name: "mAYL_events",
|
|
1425
1425
|
requires: "network",
|
|
1426
|
-
description: "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
|
|
1426
|
+
description: "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.",
|
|
1427
1427
|
inputSchema: mp0st_events_input,
|
|
1428
1428
|
handler: mp0st_events
|
|
1429
1429
|
},
|
|
@@ -1451,7 +1451,7 @@ var mailTools = [
|
|
|
1451
1451
|
{
|
|
1452
1452
|
name: "mAYL_consent",
|
|
1453
1453
|
requires: "network",
|
|
1454
|
-
description: "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;
|
|
1454
|
+
description: "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.",
|
|
1455
1455
|
inputSchema: mp0st_consent_input,
|
|
1456
1456
|
handler: mp0st_consent
|
|
1457
1457
|
},
|
|
@@ -1468,7 +1468,7 @@ var mailTools = [
|
|
|
1468
1468
|
var mailAliasTools = mailTools.map((tool) => ({
|
|
1469
1469
|
...tool,
|
|
1470
1470
|
name: tool.name.replace(/^mAYL_/, "mp0st_"),
|
|
1471
|
-
description: `[DEPRECATED \u2014 use ${tool.name} instead. mp0st_* aliases stay through alpha.25 for back-compat; will be removed in alpha.
|
|
1471
|
+
description: `[DEPRECATED \u2014 use ${tool.name} instead. mp0st_* aliases stay through alpha.25 for back-compat; will be removed in a later alpha.] ` + tool.description
|
|
1472
1472
|
}));
|
|
1473
1473
|
|
|
1474
1474
|
// src/tools/mtalk.ts
|
|
@@ -1971,8 +1971,63 @@ var actionTools = [
|
|
|
1971
1971
|
}
|
|
1972
1972
|
];
|
|
1973
1973
|
|
|
1974
|
-
// src/tools/
|
|
1974
|
+
// src/tools/threat.ts
|
|
1975
1975
|
import { z as z12 } from "zod";
|
|
1976
|
+
import {
|
|
1977
|
+
THREAT_EVENTS,
|
|
1978
|
+
THREAT_EVENT_COUNT,
|
|
1979
|
+
evaluateEvent,
|
|
1980
|
+
getEventDef
|
|
1981
|
+
} from "@mosadd/threat-engine";
|
|
1982
|
+
var threat_catalog_input = z12.object({
|
|
1983
|
+
category: z12.enum(["COMINT", "ELINT", "MASINT", "CYBER", "BEHAVIORAL", "PRIVACY", "SIGINT", "OSINT", "MPOST"]).optional().describe("Filter the catalog to one intelligence-discipline category. Omit for the full catalog."),
|
|
1984
|
+
platform: z12.enum(["apk", "ios", "pwa", "harmony"]).optional().describe("Filter to events detectable on this platform. Omit for all platforms.")
|
|
1985
|
+
});
|
|
1986
|
+
async function threat_catalog(input, _ctx) {
|
|
1987
|
+
let events = THREAT_EVENTS;
|
|
1988
|
+
if (input.category) events = events.filter((e) => e.category === input.category);
|
|
1989
|
+
if (input.platform) events = events.filter((e) => e.platforms.includes(input.platform));
|
|
1990
|
+
return { count: events.length, total: THREAT_EVENT_COUNT, events };
|
|
1991
|
+
}
|
|
1992
|
+
var threat_classify_input = z12.object({
|
|
1993
|
+
event_type: z12.string().min(1).max(120).describe('Event type to classify, e.g. "SIM_SWAP", "AUTH_BRUTEFORCE", "TOLL_FRAUD". Case-insensitive.'),
|
|
1994
|
+
severity: z12.string().optional().describe('Optional producer severity hint. "killswitch" \u2192 lock_account; "critical" \u2192 revoke_sessions; anything else is informational.'),
|
|
1995
|
+
details: z12.string().max(2e3).optional().describe("Optional free-text context (informational only).")
|
|
1996
|
+
});
|
|
1997
|
+
async function threat_classify(input, _ctx) {
|
|
1998
|
+
const def = getEventDef(String(input.event_type).toUpperCase());
|
|
1999
|
+
if (def) {
|
|
2000
|
+
return {
|
|
2001
|
+
action: "monitor",
|
|
2002
|
+
severity: def.severity,
|
|
2003
|
+
reason: `${def.label} (${def.category}) \u2014 classified from the mosadd threat taxonomy. Monitor-only: surfaced for you to act on, no automatic action taken.`,
|
|
2004
|
+
known_event: true,
|
|
2005
|
+
category: def.category,
|
|
2006
|
+
label: def.label
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
const decision = evaluateEvent({ eventType: input.event_type, severity: input.severity, details: input.details });
|
|
2010
|
+
return { ...decision, known_event: false, category: null, label: null };
|
|
2011
|
+
}
|
|
2012
|
+
var threatTools = [
|
|
2013
|
+
{
|
|
2014
|
+
name: "threat_catalog",
|
|
2015
|
+
requires: "any",
|
|
2016
|
+
description: "List the canonical mosadd threat-event taxonomy (the full radar catalog: id, category, default severity, auto-actions, per-platform availability). Filter by category or platform. Pure/offline \u2014 returns { count, total, events }. Use to discover what the defensive engine recognises.",
|
|
2017
|
+
inputSchema: threat_catalog_input,
|
|
2018
|
+
handler: threat_catalog
|
|
2019
|
+
},
|
|
2020
|
+
{
|
|
2021
|
+
name: "threat_classify",
|
|
2022
|
+
requires: "any",
|
|
2023
|
+
description: `Classify a single telemetry event against the mosadd threat taxonomy + DECK engine. For a known event type (e.g. PROCESS_INJECTION, STINGRAY_DETECT, IMSI_CATCHER_SCAN, MEMORY_INJECTION) it returns that event's real severity (info|warning|elevated|critical|killswitch) with action="monitor" \u2014 Pegasus-class events surface as critical immediately, but the engine NEVER auto-acts (it tells you, it never disconnects/locks). Unknown strings fall back to the pure DECK decision (log_only|revoke_sessions|lock_account|suspend_did). Returns { action, severity, reason, known_event, category, label }. Deterministic, offline, no backend.`,
|
|
2024
|
+
inputSchema: threat_classify_input,
|
|
2025
|
+
handler: threat_classify
|
|
2026
|
+
}
|
|
2027
|
+
];
|
|
2028
|
+
|
|
2029
|
+
// src/tools/murl.ts
|
|
2030
|
+
import { z as z13 } from "zod";
|
|
1976
2031
|
var DEFAULT_EDGE_URL2 = "https://mosadd-edge.mr-brics-33.workers.dev";
|
|
1977
2032
|
function edgeUrl2() {
|
|
1978
2033
|
return process.env.MOSADD_EDGE_URL?.replace(/\/$/, "") ?? DEFAULT_EDGE_URL2;
|
|
@@ -1982,22 +2037,26 @@ function hubKey2() {
|
|
|
1982
2037
|
if (!key) throw new Error("MOSADD_API_KEY required for mURL tools (see `mosadd login` / hub-keys).");
|
|
1983
2038
|
return key;
|
|
1984
2039
|
}
|
|
1985
|
-
function
|
|
1986
|
-
let
|
|
1987
|
-
|
|
2040
|
+
function urlToSlug(input) {
|
|
2041
|
+
let s = String(input).trim().toLowerCase();
|
|
2042
|
+
s = s.replace(/^[a-z]+:\/\//, "").replace(/[?#].*$/, "");
|
|
2043
|
+
const slash = s.indexOf("/");
|
|
2044
|
+
let host = (slash >= 0 ? s.slice(0, slash) : s).replace(/:\d+$/, "");
|
|
1988
2045
|
if (host.startsWith("www.")) host = host.slice(4);
|
|
1989
2046
|
if (!host || !/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(host)) {
|
|
1990
|
-
throw new Error(`Invalid
|
|
2047
|
+
throw new Error(`Invalid URL: "${input}" \u2014 pass a domain like "example.com" or a full URL.`);
|
|
1991
2048
|
}
|
|
1992
|
-
|
|
2049
|
+
const segs = (slash >= 0 ? s.slice(slash) : "").split("/").map((seg) => seg.replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "")).filter(Boolean);
|
|
2050
|
+
const base = host.replace(/\./g, "-");
|
|
2051
|
+
return { domain: host, slug: segs.length ? `${base}__${segs.join("__")}` : base };
|
|
1993
2052
|
}
|
|
1994
|
-
var DomainArg =
|
|
1995
|
-
var mURL_read_channel_input =
|
|
2053
|
+
var DomainArg = z13.string().min(3).max(2048).describe("A domain ('example.com') or a full URL. Keyed PER-URL: a bare domain \u2192 the domain room; a URL with a path (e.g. 'site.com/articles/abc') \u2192 that page's own room.");
|
|
2054
|
+
var mURL_read_channel_input = z13.object({
|
|
1996
2055
|
domain: DomainArg,
|
|
1997
|
-
limit:
|
|
2056
|
+
limit: z13.number().int().min(1).max(100).optional().describe("Recent messages to return (max 100). Default 50.")
|
|
1998
2057
|
});
|
|
1999
2058
|
async function mURL_read_channel(input, ctx) {
|
|
2000
|
-
const { domain, slug: slug2 } =
|
|
2059
|
+
const { domain, slug: slug2 } = urlToSlug(input.domain);
|
|
2001
2060
|
const limit = input.limit ?? 50;
|
|
2002
2061
|
ctx.log("debug", "mURL_read_channel", { domain });
|
|
2003
2062
|
const r = await fetch(`${edgeUrl2()}/c/${slug2}/history?limit=${limit}`, {
|
|
@@ -2013,13 +2072,13 @@ async function mURL_read_channel(input, ctx) {
|
|
|
2013
2072
|
messages: (data.messages ?? []).map((m) => ({ id: m.id, from: m.from ?? null, text: m.text, timestamp: m.ts }))
|
|
2014
2073
|
};
|
|
2015
2074
|
}
|
|
2016
|
-
var mURL_post_input =
|
|
2075
|
+
var mURL_post_input = z13.object({
|
|
2017
2076
|
domain: DomainArg,
|
|
2018
|
-
text:
|
|
2019
|
-
from:
|
|
2077
|
+
text: z13.string().min(1).max(2e3).describe("Message body (max 2000 chars, up to 3 lines \u2014 Worker-enforced)."),
|
|
2078
|
+
from: z13.string().max(120).optional().describe("Sender hint shown to others (defaults to the hub-key owner / your agent name).")
|
|
2020
2079
|
});
|
|
2021
2080
|
async function mURL_post(input, ctx) {
|
|
2022
|
-
const { domain, slug: slug2 } =
|
|
2081
|
+
const { domain, slug: slug2 } = urlToSlug(input.domain);
|
|
2023
2082
|
ctx.log("debug", "mURL_post", { domain });
|
|
2024
2083
|
const r = await fetch(`${edgeUrl2()}/c/${slug2}/send`, {
|
|
2025
2084
|
method: "POST",
|
|
@@ -2034,12 +2093,12 @@ async function mURL_post(input, ctx) {
|
|
|
2034
2093
|
if (!data?.id) throw new Error("mosadd-edge: send returned no id");
|
|
2035
2094
|
return { domain, message_id: data.id, posted_at: data.ts ?? Date.now() };
|
|
2036
2095
|
}
|
|
2037
|
-
var mURL_list_channels_input =
|
|
2038
|
-
action:
|
|
2039
|
-
limit:
|
|
2040
|
-
hours:
|
|
2041
|
-
status:
|
|
2042
|
-
cursor:
|
|
2096
|
+
var mURL_list_channels_input = z13.object({
|
|
2097
|
+
action: z13.enum(["trending", "list", "mine"]).optional().describe("'trending' (default) = most active domain channels in the last N hours; 'list' = paginated catalogue filtered by status; 'mine' = channels you own (DNS-verified)."),
|
|
2098
|
+
limit: z13.number().int().min(1).max(100).optional().describe("Max channels to return. Default 20."),
|
|
2099
|
+
hours: z13.number().int().min(1).max(168).optional().describe("Trending window in hours. Default 24, max 168 (7d)."),
|
|
2100
|
+
status: z13.enum(["open", "claimed", "blocked"]).optional().describe("For action='list': filter (default 'open')."),
|
|
2101
|
+
cursor: z13.string().optional().describe("For action='list': pagination \u2014 pass previous response's next_cursor (created_at ISO).")
|
|
2043
2102
|
});
|
|
2044
2103
|
async function mURL_list_channels(input, ctx) {
|
|
2045
2104
|
readSupabaseEnv();
|
|
@@ -2053,9 +2112,9 @@ async function mURL_list_channels(input, ctx) {
|
|
|
2053
2112
|
cursor: input.cursor ?? null
|
|
2054
2113
|
});
|
|
2055
2114
|
}
|
|
2056
|
-
var mURL_presence_input =
|
|
2115
|
+
var mURL_presence_input = z13.object({ domain: DomainArg });
|
|
2057
2116
|
async function mURL_presence(input, ctx) {
|
|
2058
|
-
const { domain, slug: slug2 } =
|
|
2117
|
+
const { domain, slug: slug2 } = urlToSlug(input.domain);
|
|
2059
2118
|
ctx.log("debug", "mURL_presence", { domain });
|
|
2060
2119
|
const r = await fetch(`${edgeUrl2()}/c/${slug2}/presence`);
|
|
2061
2120
|
if (!r.ok) {
|
|
@@ -2097,7 +2156,7 @@ var murlTools = [
|
|
|
2097
2156
|
];
|
|
2098
2157
|
|
|
2099
2158
|
// src/tools/capabilities.ts
|
|
2100
|
-
import { z as
|
|
2159
|
+
import { z as z14 } from "zod";
|
|
2101
2160
|
var CONTRACT_VERSION = "1.0.0";
|
|
2102
2161
|
var ALL_REQUIREMENTS = ["any", "radio", "network"];
|
|
2103
2162
|
function buildCapabilityManifest(tools) {
|
|
@@ -2120,7 +2179,7 @@ function makeCapabilitiesTool(channelTools2) {
|
|
|
2120
2179
|
name: "comms_capabilities",
|
|
2121
2180
|
requires: "any",
|
|
2122
2181
|
description: "Discover which mosadd tools are available and what transport each requires (any | radio | network). Carrier-aware hosts (e.g. off-grid radio devices) call this once to gate the tool list to what the current carrier supports. Returns a manifest with per-tool requirements grouped by transport.",
|
|
2123
|
-
inputSchema:
|
|
2182
|
+
inputSchema: z14.object({}),
|
|
2124
2183
|
handler: async () => buildCapabilityManifest([...channelTools2, tool])
|
|
2125
2184
|
};
|
|
2126
2185
|
return tool;
|
|
@@ -2139,20 +2198,17 @@ var channelTools = [
|
|
|
2139
2198
|
...mailTools,
|
|
2140
2199
|
// mAYL_*: canonical email module (was mp0st_*; renamed re-arch 2026-06-27)
|
|
2141
2200
|
...mailAliasTools,
|
|
2142
|
-
// mp0st_*: back-compat aliases — DEPRECATED, removed in alpha
|
|
2143
|
-
// ...mailProvenanceTools,
|
|
2144
|
-
// endpoint (404s every call) + sends provenance body fields the EF never reads. Unregister until
|
|
2145
|
-
// rewired onto hub-key-exchange (agent_id/task_id + mosadd_hub JWT claim). See consistency ticket.
|
|
2201
|
+
// mp0st_*: back-compat aliases — DEPRECATED, removed in a later alpha
|
|
2202
|
+
// ...mailProvenanceTools, // mAYL_send_as_agent: UNREGISTERED 2026-07-14 — hub-claim EF 404s every call; re-register when rewired onto hub-key-exchange (CTO-1 live-ping)
|
|
2146
2203
|
...mtalkTools,
|
|
2147
2204
|
...attachmentTools,
|
|
2148
|
-
// ...pttIngestTools,
|
|
2149
|
-
// ptt-ingest EF (needs {direction, audio_base64, mime_type, message_id|thread_id} → 400s every
|
|
2150
|
-
// call) and the PTT→RAG path needs rework. Unregister until both are fixed. See consistency ticket.
|
|
2205
|
+
// ...pttIngestTools, // mTALK_ingest_ptt: UNREGISTERED 2026-07-14 — ptt-ingest EF 400s every call; re-register when payload + PTT→RAG path fixed (CTO-1 live-ping)
|
|
2151
2206
|
...knowledgeTools,
|
|
2152
2207
|
...actionTools,
|
|
2153
2208
|
// Action links (Tier 1): agent → user one-link browser action via action-create EF
|
|
2154
|
-
// ...embedTools,
|
|
2155
|
-
|
|
2209
|
+
// ...embedTools, // comms_embed_create: UNREGISTERED 2026-07-14 — widget backend not live e2e; re-register when embed.mosadd.com ships (CTO-1 live-ping)
|
|
2210
|
+
...threatTools,
|
|
2211
|
+
// threat_catalog + threat_classify: RE-REGISTERED 2026-07-15 (founder directive + LINEAR-3498) — pure/offline, makes the Pegasus-class classification claim a live, callable capability
|
|
2156
2212
|
...murlTools
|
|
2157
2213
|
// mURL: revived as a full module (founder 2026-06-27) — read/post/presence/list_channels over live domain channels
|
|
2158
2214
|
// ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
|
|
@@ -2331,7 +2387,7 @@ function createMosaddServer(options = {}) {
|
|
|
2331
2387
|
const server = new McpServer(
|
|
2332
2388
|
{
|
|
2333
2389
|
name: "mosadd",
|
|
2334
|
-
version: "3.0.0-alpha.
|
|
2390
|
+
version: "3.0.0-alpha.27"
|
|
2335
2391
|
},
|
|
2336
2392
|
{
|
|
2337
2393
|
capabilities: {
|
package/dist/index.d.ts
CHANGED
|
@@ -202,23 +202,27 @@ declare function createMosaddServer(options?: MosaddServerOptions): McpServer;
|
|
|
202
202
|
*
|
|
203
203
|
* User-facing modules (4): mDM, mIRC, mURL, mAYL — the re-arch (LINEAR-3938)
|
|
204
204
|
* mAYL replaces the old mp0st name (mp0st_* still registered as back-compat
|
|
205
|
-
* aliases via mail-aliases.ts; will be removed in alpha
|
|
205
|
+
* aliases via mail-aliases.ts; will be removed in a later alpha).
|
|
206
206
|
*
|
|
207
207
|
* Capabilities (not modules — cross-cutting agent tooling): mRAG, comms_.
|
|
208
208
|
* mTALK = voice tier inside mIRC, still its own tools for now; folding into
|
|
209
|
-
* mIRC_voice_* in a follow-up release. threat_*
|
|
210
|
-
*
|
|
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.
|
|
211
213
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
214
|
+
* ~70+ callable tools registered (public copy says "70+ tools", matching mosadd.com).
|
|
215
|
+
* Modules (4): mDM, mIRC, mURL, mAYL. Capabilities: mTALK (voice/PTT), mRAG, comms_.
|
|
216
|
+
* mp0st_* stay as DEPRECATED back-compat aliases for mAYL_* (removed in a later alpha).
|
|
217
|
+
* Exact integer pending a live EF ping (CTO-1) — don't hard-code a drifting count.
|
|
218
|
+
* UNREGISTERED 2026-07-14 (broken scaffolds whose EFs 404/400 every call — re-register when
|
|
219
|
+
* live): mAYL_send_as_agent (mail-provenance), mTALK_ingest_ptt (ptt-ingest), comms_embed_create.
|
|
216
220
|
* mROOM was KILLED (LINEAR-3414, channel re-cut → ephemeral private mIRC): its tools
|
|
217
221
|
* live in tools/mroom.ts + mroom-messages.ts but are NOT registered here.
|
|
218
222
|
* Plus action links: comms_action_create (agent → user one-link browser action,
|
|
219
223
|
* incl. screen_share) + comms_action_frame_get (see the recipient's shared screen).
|
|
220
|
-
* mURL is a
|
|
221
|
-
*
|
|
224
|
+
* mURL is a FULL registered dev module (revived, founder 2026-06-27) — IRC-for-URLs,
|
|
225
|
+
* agent-native; backends live (mosadd-edge + murl-channels EF). tools/murl.ts.
|
|
222
226
|
* mCALL is carrier-pending (no telephony carrier live yet): its tools live in
|
|
223
227
|
* tools/mcall.ts but are NOT registered here, so an agent only ever discovers
|
|
224
228
|
* tools that actually work. Re-register the one line below when a carrier ships.
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosadd/mcp",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.27",
|
|
4
4
|
"mcpName": "io.github.hei33enberg/mosadd-mcp",
|
|
5
|
-
"description": "Model Context Protocol server for mosadd. Exposes 4 modules (mDM, mIRC, mURL, mAYL) and capabilities (mTALK, mRAG) plus comms agent-actions —
|
|
5
|
+
"description": "Model Context Protocol server for mosadd. Exposes 4 modules (mDM, mIRC, mURL, mAYL) and capabilities (mTALK, mRAG) plus comms agent-actions — 70+ tools (mp0st_* aliases for back-compat) — to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
|
|
6
6
|
"homepage": "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
39
39
|
"@supabase/supabase-js": "^2.48.0",
|
|
40
40
|
"zod": "^4.3.6",
|
|
41
|
-
"@mosadd/
|
|
42
|
-
"@mosadd/
|
|
43
|
-
"@mosadd/
|
|
44
|
-
"@mosadd/
|
|
41
|
+
"@mosadd/threat-engine": "3.0.0-alpha.26",
|
|
42
|
+
"@mosadd/providers": "3.0.0-alpha.26",
|
|
43
|
+
"@mosadd/protocol": "3.0.0-alpha.26",
|
|
44
|
+
"@mosadd/crypto": "3.0.0-alpha.26"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"tsup": "^8.3.5",
|
|
@@ -137,8 +137,9 @@ describe("@mosadd/mcp — integration (real stdio)", () => {
|
|
|
137
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("mURL_post"); // mURL revived module (2026-06-27)
|
|
141
|
+
expect(names).toContain("mAYL_send"); // mAYL = email 3.0 (was mp0st); threat_catalog/threat_classify ARE registered (LINEAR-3498)
|
|
142
|
+
expect(names).toContain("mp0st_send"); // deprecated back-compat alias
|
|
142
143
|
expect(names).toContain("mTALK_press"); // mTALK PTT now shipped
|
|
143
144
|
expect(names).toContain("mRAG_search"); // mRAG RAG-for-devs now shipped
|
|
144
145
|
expect(names).toContain("mIRC_post_message"); // channel messaging now shipped
|
|
@@ -15,10 +15,11 @@ describe("@mosadd/mcp", () => {
|
|
|
15
15
|
// mIRC (5 tools)
|
|
16
16
|
expect(names).toContain("mIRC_create");
|
|
17
17
|
expect(names).toContain("mIRC_delete");
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
expect(names).toContain("
|
|
21
|
-
|
|
18
|
+
// mURL (revived module) + mAYL (email 3.0, was mp0st) — threat_* re-registered (LINEAR-3498)
|
|
19
|
+
// (surveillance-era direction killed 2026-06-27; on-device security pillar, not an MCP tool)
|
|
20
|
+
expect(names).toContain("mURL_post");
|
|
21
|
+
expect(names).toContain("mAYL_send");
|
|
22
|
+
// mp0st_* remain as deprecated back-compat aliases for mAYL_*
|
|
22
23
|
expect(names).toContain("mp0st_send");
|
|
23
24
|
expect(names).toContain("mp0st_view");
|
|
24
25
|
});
|
package/src/server.ts
CHANGED
package/src/tools/index.ts
CHANGED
|
@@ -3,23 +3,27 @@
|
|
|
3
3
|
*
|
|
4
4
|
* User-facing modules (4): mDM, mIRC, mURL, mAYL — the re-arch (LINEAR-3938)
|
|
5
5
|
* mAYL replaces the old mp0st name (mp0st_* still registered as back-compat
|
|
6
|
-
* aliases via mail-aliases.ts; will be removed in alpha
|
|
6
|
+
* aliases via mail-aliases.ts; will be removed in a later alpha).
|
|
7
7
|
*
|
|
8
8
|
* Capabilities (not modules — cross-cutting agent tooling): mRAG, comms_.
|
|
9
9
|
* mTALK = voice tier inside mIRC, still its own tools for now; folding into
|
|
10
|
-
* mIRC_voice_* in a follow-up release. threat_*
|
|
11
|
-
*
|
|
10
|
+
* mIRC_voice_* in a follow-up release. threat_* (threat_catalog + threat_classify)
|
|
11
|
+
* are REGISTERED (2026-07-15, founder directive + LINEAR-3498): pure/offline
|
|
12
|
+
* defensive classification over the threat taxonomy — the surveillance-era
|
|
13
|
+
* *marketing* was killed, the classification engine is real and wanted.
|
|
12
14
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* ~70+ callable tools registered (public copy says "70+ tools", matching mosadd.com).
|
|
16
|
+
* Modules (4): mDM, mIRC, mURL, mAYL. Capabilities: mTALK (voice/PTT), mRAG, comms_.
|
|
17
|
+
* mp0st_* stay as DEPRECATED back-compat aliases for mAYL_* (removed in a later alpha).
|
|
18
|
+
* Exact integer pending a live EF ping (CTO-1) — don't hard-code a drifting count.
|
|
19
|
+
* UNREGISTERED 2026-07-14 (broken scaffolds whose EFs 404/400 every call — re-register when
|
|
20
|
+
* live): mAYL_send_as_agent (mail-provenance), mTALK_ingest_ptt (ptt-ingest), comms_embed_create.
|
|
17
21
|
* mROOM was KILLED (LINEAR-3414, channel re-cut → ephemeral private mIRC): its tools
|
|
18
22
|
* live in tools/mroom.ts + mroom-messages.ts but are NOT registered here.
|
|
19
23
|
* Plus action links: comms_action_create (agent → user one-link browser action,
|
|
20
24
|
* incl. screen_share) + comms_action_frame_get (see the recipient's shared screen).
|
|
21
|
-
* mURL is a
|
|
22
|
-
*
|
|
25
|
+
* mURL is a FULL registered dev module (revived, founder 2026-06-27) — IRC-for-URLs,
|
|
26
|
+
* agent-native; backends live (mosadd-edge + murl-channels EF). tools/murl.ts.
|
|
23
27
|
* mCALL is carrier-pending (no telephony carrier live yet): its tools live in
|
|
24
28
|
* tools/mcall.ts but are NOT registered here, so an agent only ever discovers
|
|
25
29
|
* tools that actually work. Re-register the one line below when a carrier ships.
|
|
@@ -36,17 +40,15 @@ import { mircEdgeTools } from "./mirc-edge.js";
|
|
|
36
40
|
// import { mroomMessagesTools } from "./mroom-messages.js"; // mROOM: killed (LINEAR-3414) — not registered
|
|
37
41
|
import { mailTools } from "./mail.js";
|
|
38
42
|
import { mailAliasTools } from "./mail-aliases.js"; // mp0st_* back-compat aliases for mAYL_*
|
|
39
|
-
// import { mailProvenanceTools } from "./mail-provenance.js"; //
|
|
43
|
+
// import { mailProvenanceTools } from "./mail-provenance.js"; // mAYL_send_as_agent SCAFFOLD — UNREGISTERED 2026-07-14 (hub-claim EF 404s; re-register when live — CTO-1 live-ping)
|
|
40
44
|
import { mtalkTools } from "./mtalk.js";
|
|
41
45
|
import { attachmentTools } from "./attachments.js";
|
|
42
|
-
// import { pttIngestTools } from "./ptt-ingest.js"; //
|
|
46
|
+
// import { pttIngestTools } from "./ptt-ingest.js"; // mTALK_ingest_ptt SCAFFOLD — UNREGISTERED 2026-07-14 (ptt-ingest EF 400s; re-register when fixed — CTO-1 live-ping)
|
|
43
47
|
// import { mcallTools } from "./mcall.js"; // mCALL: carrier-pending — not registered (see header note)
|
|
44
48
|
import { knowledgeTools } from "./knowledge.js";
|
|
45
49
|
import { actionTools } from "./actions.js";
|
|
46
|
-
// import { embedTools } from "./embed.js"; // comms_embed_create
|
|
47
|
-
|
|
48
|
-
// widget surface is parked. Unregister until both ship. See consistency ticket.
|
|
49
|
-
// import { threatTools } from "./threat.js"; // threat_*: UNREGISTERED 2026-06-27 (re-arch). Surveillance-era direction killed; source kept for archival.
|
|
50
|
+
// import { embedTools } from "./embed.js"; // comms_embed_create SCAFFOLD — UNREGISTERED 2026-07-14 (widget backend not live e2e; re-register when embed.mosadd.com ships — CTO-1 live-ping)
|
|
51
|
+
import { threatTools } from "./threat.js"; // threat_*: RE-REGISTERED 2026-07-15 (founder directive + LINEAR-3498). Pure/offline classification of the real Pegasus-class threat taxonomy — the engine DECIDES, the caller acts; no surveillance, no backend.
|
|
50
52
|
import { murlTools } from "./murl.js"; // mURL: REGISTERED — revived as a full dev module (founder 2026-06-27, re-arch). IRC-for-URLs, agent-native; backends live (mosadd-edge + murl-channels EF).
|
|
51
53
|
import { makeCapabilitiesTool } from "./capabilities.js";
|
|
52
54
|
|
|
@@ -61,19 +63,15 @@ const channelTools: MosaddTool[] = [
|
|
|
61
63
|
// ...mroomTools, // mROOM: killed (LINEAR-3414) — channel re-cut into ephemeral private mIRC
|
|
62
64
|
// ...mroomMessagesTools, // mROOM: killed (LINEAR-3414)
|
|
63
65
|
...mailTools, // mAYL_*: canonical email module (was mp0st_*; renamed re-arch 2026-06-27)
|
|
64
|
-
...mailAliasTools, // mp0st_*: back-compat aliases — DEPRECATED, removed in alpha
|
|
65
|
-
// ...mailProvenanceTools,
|
|
66
|
-
// endpoint (404s every call) + sends provenance body fields the EF never reads. Unregister until
|
|
67
|
-
// rewired onto hub-key-exchange (agent_id/task_id + mosadd_hub JWT claim). See consistency ticket.
|
|
66
|
+
...mailAliasTools, // mp0st_*: back-compat aliases — DEPRECATED, removed in a later alpha
|
|
67
|
+
// ...mailProvenanceTools, // mAYL_send_as_agent: UNREGISTERED 2026-07-14 — hub-claim EF 404s every call; re-register when rewired onto hub-key-exchange (CTO-1 live-ping)
|
|
68
68
|
...mtalkTools,
|
|
69
69
|
...attachmentTools,
|
|
70
|
-
// ...pttIngestTools,
|
|
71
|
-
// ptt-ingest EF (needs {direction, audio_base64, mime_type, message_id|thread_id} → 400s every
|
|
72
|
-
// call) and the PTT→RAG path needs rework. Unregister until both are fixed. See consistency ticket.
|
|
70
|
+
// ...pttIngestTools, // mTALK_ingest_ptt: UNREGISTERED 2026-07-14 — ptt-ingest EF 400s every call; re-register when payload + PTT→RAG path fixed (CTO-1 live-ping)
|
|
73
71
|
...knowledgeTools,
|
|
74
72
|
...actionTools, // Action links (Tier 1): agent → user one-link browser action via action-create EF
|
|
75
|
-
// ...embedTools,
|
|
76
|
-
|
|
73
|
+
// ...embedTools, // comms_embed_create: UNREGISTERED 2026-07-14 — widget backend not live e2e; re-register when embed.mosadd.com ships (CTO-1 live-ping)
|
|
74
|
+
...threatTools, // threat_catalog + threat_classify: RE-REGISTERED 2026-07-15 (founder directive + LINEAR-3498) — pure/offline, makes the Pegasus-class classification claim a live, callable capability
|
|
77
75
|
...murlTools, // mURL: revived as a full module (founder 2026-06-27) — read/post/presence/list_channels over live domain channels
|
|
78
76
|
// ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
|
|
79
77
|
// mirlTools,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
//
|
|
9
9
|
// Rule: never drop an alias in the release that adds its replacement — live
|
|
10
10
|
// agents would 404. mp0st_* aliases stay through alpha.25 and the next minor;
|
|
11
|
-
// flag for removal goes into the
|
|
11
|
+
// flag for removal goes into the a later release's notes.
|
|
12
12
|
// =============================================================================
|
|
13
13
|
|
|
14
14
|
import type { MosaddTool } from "../types.js";
|
|
@@ -20,6 +20,6 @@ export const mailAliasTools: MosaddTool[] = mailTools.map((tool) => ({
|
|
|
20
20
|
name: tool.name.replace(/^mAYL_/, "mp0st_"),
|
|
21
21
|
description:
|
|
22
22
|
`[DEPRECATED — use ${tool.name} instead. mp0st_* aliases stay through alpha.25 ` +
|
|
23
|
-
`for back-compat; will be removed in alpha.
|
|
23
|
+
`for back-compat; will be removed in a later alpha.] ` +
|
|
24
24
|
tool.description,
|
|
25
25
|
}));
|
|
@@ -62,53 +62,51 @@ const mp0st_send_as_agent_input = z.object({
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Exchange the hub key for
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* Exchange the hub key for an HS256 hub-claim JWT that authorizes agent-attributed
|
|
66
|
+
* mail sends. The `mp0st-send` EF verifies this token with HUB_JWT_SECRET and reads
|
|
67
|
+
* `agent_id` + `task_id` from its claims authoritatively (body fields are NOT trusted
|
|
68
|
+
* for provenance). LINEAR-3991.
|
|
68
69
|
*/
|
|
69
70
|
async function mintHubClaim(agentId: string, taskId?: string): Promise<string> {
|
|
70
71
|
const key = hubKey();
|
|
71
72
|
if (!key) {
|
|
72
|
-
throw new Error("
|
|
73
|
+
throw new Error("mAYL_send_as_agent needs MOSADD_API_KEY (hub key) to mint a provenance claim.");
|
|
73
74
|
}
|
|
74
75
|
const r = await fetch(`${supabaseUrl()}/functions/v1/hub-claim-mint`, {
|
|
75
76
|
method: "POST",
|
|
76
77
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
|
|
77
|
-
body: JSON.stringify({
|
|
78
|
+
body: JSON.stringify({ agent_id: agentId, task_id: taskId ?? null }),
|
|
78
79
|
});
|
|
79
80
|
if (!r.ok) {
|
|
80
81
|
const b = await r.text().catch(() => "");
|
|
81
82
|
throw new Error(`hub-claim-mint ${r.status}: ${b.slice(0, 200)}`);
|
|
82
83
|
}
|
|
83
|
-
const data = (await r.json()) as {
|
|
84
|
-
if (!data?.
|
|
85
|
-
return data.
|
|
84
|
+
const data = (await r.json()) as { access_token?: string };
|
|
85
|
+
if (!data?.access_token) throw new Error("hub-claim-mint: no access_token in response");
|
|
86
|
+
return data.access_token;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
async function
|
|
89
|
+
async function mAYL_send_as_agent(
|
|
89
90
|
input: z.infer<typeof mp0st_send_as_agent_input>,
|
|
90
91
|
ctx: MosaddToolContext,
|
|
91
92
|
): Promise<{ message_id: string; status: string; is_internal: boolean; sent_by: "agent" }> {
|
|
92
93
|
if (!input.body_text && !input.body_html) {
|
|
93
|
-
throw new Error("
|
|
94
|
+
throw new Error("mAYL_send_as_agent requires at least one of body_text or body_html.");
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
//
|
|
97
|
-
// so the EF attributes the row to the agent.
|
|
98
|
-
//
|
|
97
|
+
// Mint the hub-claim JWT and present it directly to mp0st-send (NOT the user
|
|
98
|
+
// session client) so the EF attributes the row to the agent. mp0st-send verifies
|
|
99
|
+
// the HS256 signature with HUB_JWT_SECRET and stamps sent_by_agent_id /
|
|
100
|
+
// sent_by_task_id from the verified claims — body fields are NOT trusted for
|
|
101
|
+
// provenance.
|
|
99
102
|
const claim = await mintHubClaim(input.agent_id, input.task_id);
|
|
100
|
-
ctx.log("debug", "
|
|
103
|
+
ctx.log("debug", "mAYL_send_as_agent invoking mp0st-send with hub-claim", { agent_id: input.agent_id });
|
|
101
104
|
|
|
102
|
-
const { agent_id, task_id, ...mailFields } = input;
|
|
105
|
+
const { agent_id: _ai, task_id: _ti, ...mailFields } = input;
|
|
103
106
|
const r = await fetch(`${supabaseUrl()}/functions/v1/mp0st-send`, {
|
|
104
107
|
method: "POST",
|
|
105
108
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${claim}` },
|
|
106
|
-
body: JSON.stringify(
|
|
107
|
-
...mailFields,
|
|
108
|
-
sent_by: "agent",
|
|
109
|
-
sent_by_agent_id: agent_id,
|
|
110
|
-
sent_by_task_id: task_id ?? null,
|
|
111
|
-
}),
|
|
109
|
+
body: JSON.stringify(mailFields),
|
|
112
110
|
});
|
|
113
111
|
if (!r.ok) {
|
|
114
112
|
const b = await r.text().catch(() => "");
|
|
@@ -127,11 +125,11 @@ async function mp0st_send_as_agent(
|
|
|
127
125
|
|
|
128
126
|
export const mailProvenanceTools: MosaddTool[] = [
|
|
129
127
|
{
|
|
130
|
-
name: "
|
|
128
|
+
name: "mAYL_send_as_agent",
|
|
131
129
|
requires: "network",
|
|
132
130
|
description:
|
|
133
|
-
"Send an email ATTRIBUTED TO THE AGENT (provenance-stamped). Unlike
|
|
131
|
+
"Send an email ATTRIBUTED TO THE AGENT (provenance-stamped). Unlike mAYL_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). The mp0st-send EF verifies the claim with HUB_JWT_SECRET; body trust is never granted for provenance.",
|
|
134
132
|
inputSchema: mp0st_send_as_agent_input,
|
|
135
|
-
handler:
|
|
133
|
+
handler: mAYL_send_as_agent as MosaddTool["handler"],
|
|
136
134
|
},
|
|
137
135
|
];
|
package/src/tools/mail.ts
CHANGED
|
@@ -19,7 +19,7 @@ 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
24
|
const mp0st_send_input = z.object({
|
|
25
25
|
to: z.union([EmailAddress, z.array(EmailAddress).min(1).max(50)]).describe(
|
|
@@ -295,7 +295,7 @@ export const mailTools: MosaddTool[] = [
|
|
|
295
295
|
name: "mAYL_list",
|
|
296
296
|
requires: "network",
|
|
297
297
|
description:
|
|
298
|
-
"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
|
|
298
|
+
"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.",
|
|
299
299
|
inputSchema: mp0st_list_input,
|
|
300
300
|
handler: mp0st_list as MosaddTool["handler"],
|
|
301
301
|
},
|
|
@@ -318,7 +318,7 @@ export const mailTools: MosaddTool[] = [
|
|
|
318
318
|
name: "mAYL_delete",
|
|
319
319
|
requires: "network",
|
|
320
320
|
description:
|
|
321
|
-
"Delete one of the user's emails by message_id (from
|
|
321
|
+
"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.",
|
|
322
322
|
inputSchema: mp0st_delete_input,
|
|
323
323
|
handler: mp0st_delete as MosaddTool["handler"],
|
|
324
324
|
},
|
|
@@ -334,7 +334,7 @@ export const mailTools: MosaddTool[] = [
|
|
|
334
334
|
name: "mAYL_events",
|
|
335
335
|
requires: "network",
|
|
336
336
|
description:
|
|
337
|
-
"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
|
|
337
|
+
"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.",
|
|
338
338
|
inputSchema: mp0st_events_input,
|
|
339
339
|
handler: mp0st_events as MosaddTool["handler"],
|
|
340
340
|
},
|
|
@@ -366,7 +366,7 @@ export const mailTools: MosaddTool[] = [
|
|
|
366
366
|
name: "mAYL_consent",
|
|
367
367
|
requires: "network",
|
|
368
368
|
description:
|
|
369
|
-
"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;
|
|
369
|
+
"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.",
|
|
370
370
|
inputSchema: mp0st_consent_input,
|
|
371
371
|
handler: mp0st_consent as MosaddTool["handler"],
|
|
372
372
|
},
|
package/src/tools/murl.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* mURL — IRC-for-URLs: real-time chat attached to any web DOMAIN, AGENT-NATIVE.
|
|
3
3
|
*
|
|
4
4
|
* Same mosadd-edge Cloudflare Worker / Durable Object backend as mIRC edge, but the
|
|
5
|
-
* channel id is the
|
|
6
|
-
*
|
|
5
|
+
* channel id is the URL SLUG: host("."→"-") + path("/"→"__") (RFC-0004). A bare domain
|
|
6
|
+
* → the domain room; a full URL with a path → a per-PAGE room (the per-article ask).
|
|
7
|
+
* Auto-created on first activity (status "open"); the domain owner can verify/claim the
|
|
8
|
+
* whole domain (a domain block covers all its page rooms).
|
|
7
9
|
*
|
|
8
10
|
* THE WEDGE: every prior "chat on a web page" (Google Sidewiki, Genius, Hypothes.is,
|
|
9
11
|
* HERE.fm) died on the empty-room cold-start because they were HUMAN-ONLY — you arrive,
|
|
@@ -28,22 +30,34 @@ function hubKey(): string {
|
|
|
28
30
|
return key;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
/** A domain OR full URL → { domain, slug }.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
/** A domain OR full URL → { domain, slug }. mURL is keyed PER-URL (RFC-0004):
|
|
34
|
+
* slug = host("."→"-") + each path segment ("/"→"__"); scheme, query, fragment and
|
|
35
|
+
* trailing slash are stripped and segments are sanitised to [a-z0-9-]. A bare domain
|
|
36
|
+
* (no path) yields the DOMAIN room (back-compat); a URL with a path yields a PER-PAGE
|
|
37
|
+
* room. `domain` (host only) is returned for status/branding — a domain block covers
|
|
38
|
+
* every page room under it. */
|
|
39
|
+
function urlToSlug(input: string): { domain: string; slug: string } {
|
|
40
|
+
let s = String(input).trim().toLowerCase();
|
|
41
|
+
s = s.replace(/^[a-z]+:\/\//, "").replace(/[?#].*$/, ""); // strip scheme + query + fragment
|
|
42
|
+
const slash = s.indexOf("/");
|
|
43
|
+
let host = (slash >= 0 ? s.slice(0, slash) : s).replace(/:\d+$/, "");
|
|
35
44
|
if (host.startsWith("www.")) host = host.slice(4);
|
|
36
45
|
if (!host || !/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(host)) {
|
|
37
|
-
throw new Error(`Invalid
|
|
46
|
+
throw new Error(`Invalid URL: "${input}" — pass a domain like "example.com" or a full URL.`);
|
|
38
47
|
}
|
|
39
|
-
|
|
48
|
+
const segs = (slash >= 0 ? s.slice(slash) : "")
|
|
49
|
+
.split("/")
|
|
50
|
+
.map((seg) => seg.replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, ""))
|
|
51
|
+
.filter(Boolean);
|
|
52
|
+
const base = host.replace(/\./g, "-");
|
|
53
|
+
return { domain: host, slug: segs.length ? `${base}__${segs.join("__")}` : base };
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
const DomainArg = z
|
|
43
57
|
.string()
|
|
44
58
|
.min(3)
|
|
45
|
-
.max(
|
|
46
|
-
.describe("A domain (
|
|
59
|
+
.max(2048)
|
|
60
|
+
.describe("A domain ('example.com') or a full URL. Keyed PER-URL: a bare domain → the domain room; a URL with a path (e.g. 'site.com/articles/abc') → that page's own room.");
|
|
47
61
|
|
|
48
62
|
// ── read ──────────────────────────────────────────────────────────────────────
|
|
49
63
|
const mURL_read_channel_input = z.object({
|
|
@@ -54,7 +68,7 @@ async function mURL_read_channel(
|
|
|
54
68
|
input: z.infer<typeof mURL_read_channel_input>,
|
|
55
69
|
ctx: MosaddToolContext,
|
|
56
70
|
): Promise<{ domain: string; messages: Array<{ id: string; from: string | null; text: string; timestamp: number }> }> {
|
|
57
|
-
const { domain, slug } =
|
|
71
|
+
const { domain, slug } = urlToSlug(input.domain);
|
|
58
72
|
const limit = input.limit ?? 50;
|
|
59
73
|
ctx.log("debug", "mURL_read_channel", { domain });
|
|
60
74
|
const r = await fetch(`${edgeUrl()}/c/${slug}/history?limit=${limit}`, {
|
|
@@ -81,7 +95,7 @@ async function mURL_post(
|
|
|
81
95
|
input: z.infer<typeof mURL_post_input>,
|
|
82
96
|
ctx: MosaddToolContext,
|
|
83
97
|
): Promise<{ domain: string; message_id: string; posted_at: number }> {
|
|
84
|
-
const { domain, slug } =
|
|
98
|
+
const { domain, slug } = urlToSlug(input.domain);
|
|
85
99
|
ctx.log("debug", "mURL_post", { domain });
|
|
86
100
|
const r = await fetch(`${edgeUrl()}/c/${slug}/send`, {
|
|
87
101
|
method: "POST",
|
|
@@ -148,7 +162,7 @@ async function mURL_presence(
|
|
|
148
162
|
input: z.infer<typeof mURL_presence_input>,
|
|
149
163
|
ctx: MosaddToolContext,
|
|
150
164
|
): Promise<{ domain: string; count: number; roster: string[]; status: string }> {
|
|
151
|
-
const { domain, slug } =
|
|
165
|
+
const { domain, slug } = urlToSlug(input.domain);
|
|
152
166
|
ctx.log("debug", "mURL_presence", { domain });
|
|
153
167
|
const r = await fetch(`${edgeUrl()}/c/${slug}/presence`);
|
|
154
168
|
if (!r.ok) {
|
package/src/tools/ptt-ingest.ts
CHANGED
|
@@ -1,82 +1,87 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PTT
|
|
2
|
+
* mTALK_ingest_ptt — submit a recorded PTT "over" for transcription + RAG ingest.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The actual mIRC/mDM voice-message PERSISTENCE (writing a message_meta row,
|
|
5
|
+
* fanning it out to listeners) is owned by the message-send/send-voice path,
|
|
6
|
+
* NOT by this tool. ptt-ingest exists purely to bridge a finished PTT segment
|
|
7
|
+
* into the user's RAG index — a row in `ptt_transcripts` (status='pending')
|
|
8
|
+
* + a transcribe job that lands in `user_embeddings(source_type='ptt')`.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* 2. call `ptt-ingest` EF with the attachment descriptor + routing (which
|
|
13
|
-
* channel/room the "over" belongs to). The EF persists a queued-PTT message.
|
|
14
|
-
* 3. if the user has opted in to RAG, `rag-transcribe` runs and the transcript
|
|
15
|
-
* lands in user_embeddings(source_type='ptt').
|
|
10
|
+
* Use this when an agent has a PTT audio buffer it wants searchable in the
|
|
11
|
+
* user's RAG later (e.g. "what did Alice tell me on PTT yesterday?"). The
|
|
12
|
+
* voice message itself is sent separately via mDM_send_voice / mIRC_send_voice.
|
|
16
13
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* Auth: standard Supabase session JWT (the caller's RAG opt-in is read from
|
|
15
|
+
* their account; opted-out callers get status='skipped_optout').
|
|
16
|
+
* LINEAR-3998 (P4.1 PTT unify) — re-arch 2026-06-27.
|
|
19
17
|
*/
|
|
20
|
-
|
|
21
18
|
import { z } from "zod";
|
|
22
19
|
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
23
20
|
import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
|
|
24
|
-
import { uploadBlob, decodeBase64Body } from "../providers/blob-upload.js";
|
|
25
21
|
|
|
26
22
|
const mTALK_ingest_ptt_input = z.object({
|
|
27
23
|
audio_base64: z
|
|
28
24
|
.string()
|
|
29
25
|
.min(1)
|
|
30
26
|
.max(20_000_000)
|
|
31
|
-
.describe("Recorded PTT 'over' as base64 (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
27
|
+
.describe("Recorded PTT 'over' as base64 (a 'data:audio/…;base64,…' prefix is stripped if present)."),
|
|
28
|
+
mime_type: z
|
|
29
|
+
.string()
|
|
30
|
+
.min(1)
|
|
31
|
+
.max(120)
|
|
32
|
+
.default("audio/webm")
|
|
33
|
+
.describe("MIME type of the audio. Default audio/webm (browser MediaRecorder default)."),
|
|
34
|
+
direction: z
|
|
35
|
+
.enum(["human_to_agent", "agent_to_human"])
|
|
36
|
+
.describe("Direction the PTT crossed: who originated, who received. 'human_to_agent' = user spoke to an agent; 'agent_to_human' = agent spoke to the user."),
|
|
37
|
+
message_id: z
|
|
38
|
+
.string()
|
|
39
|
+
.min(1)
|
|
40
|
+
.max(120)
|
|
40
41
|
.optional()
|
|
41
|
-
.describe("
|
|
42
|
+
.describe("Optional id of the messages_meta row this PTT belongs to. When present, links the transcript back to the message for jump-to-source from RAG."),
|
|
43
|
+
thread_id: z
|
|
44
|
+
.string()
|
|
45
|
+
.min(1)
|
|
46
|
+
.max(120)
|
|
47
|
+
.optional()
|
|
48
|
+
.describe("Optional thread id (e.g. `chat:<channel_id>` or `dm:<a>:<b>`) so the transcript carries its conversational scope into RAG."),
|
|
42
49
|
});
|
|
43
50
|
|
|
51
|
+
interface PttIngestResponse {
|
|
52
|
+
ptt_id?: string;
|
|
53
|
+
status?: "pending" | "skipped_optout" | "queued";
|
|
54
|
+
enqueued?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
async function mTALK_ingest_ptt(
|
|
45
58
|
input: z.infer<typeof mTALK_ingest_ptt_input>,
|
|
46
59
|
ctx: MosaddToolContext,
|
|
47
|
-
): Promise<{ ptt_id: string;
|
|
60
|
+
): Promise<{ ptt_id: string; status: string; opted_in: boolean }> {
|
|
48
61
|
readSupabaseEnv();
|
|
49
|
-
if (!input.channel_id && !input.room_id) {
|
|
50
|
-
throw new Error("mTALK_ingest_ptt requires one of channel_id or room_id to route the queued PTT.");
|
|
51
|
-
}
|
|
52
|
-
const prefix = input.channel_id ? `chat:${input.channel_id}` : `room:${input.room_id}`;
|
|
53
|
-
const attachment = await uploadBlob({
|
|
54
|
-
kind: "ptt",
|
|
55
|
-
bytes: decodeBase64Body(input.audio_base64),
|
|
56
|
-
mime: input.mime,
|
|
57
|
-
prefix,
|
|
58
|
-
duration_ms: input.duration_ms,
|
|
59
|
-
});
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
// Tolerate a "data:audio/…;base64,…" prefix from MediaRecorder/canvas captures.
|
|
64
|
+
const audio = input.audio_base64.replace(/^data:[^;]+;base64,/, "");
|
|
65
|
+
|
|
66
|
+
ctx.log("debug", "mTALK_ingest_ptt invoking ptt-ingest", {
|
|
67
|
+
direction: input.direction,
|
|
68
|
+
thread_id: input.thread_id ?? null,
|
|
69
|
+
mime_type: input.mime_type,
|
|
70
|
+
});
|
|
62
71
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}>("ptt-ingest", {
|
|
70
|
-
attachment,
|
|
71
|
-
channel_id: input.channel_id ?? null,
|
|
72
|
-
room_id: input.room_id ?? null,
|
|
73
|
-
transcribe: input.transcribe ?? true,
|
|
72
|
+
const res = await invokeFunction<PttIngestResponse>("ptt-ingest", {
|
|
73
|
+
audio_base64: audio,
|
|
74
|
+
mime_type: input.mime_type,
|
|
75
|
+
direction: input.direction,
|
|
76
|
+
message_id: input.message_id ?? null,
|
|
77
|
+
thread_id: input.thread_id ?? null,
|
|
74
78
|
});
|
|
75
79
|
|
|
80
|
+
const status = res.status ?? "pending";
|
|
76
81
|
return {
|
|
77
82
|
ptt_id: res.ptt_id ?? "",
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
status,
|
|
84
|
+
opted_in: status !== "skipped_optout",
|
|
80
85
|
};
|
|
81
86
|
}
|
|
82
87
|
|
|
@@ -85,7 +90,7 @@ export const pttIngestTools: MosaddTool[] = [
|
|
|
85
90
|
name: "mTALK_ingest_ptt",
|
|
86
91
|
requires: "network",
|
|
87
92
|
description:
|
|
88
|
-
"
|
|
93
|
+
"Submit a finished PTT 'over' (push-to-talk audio segment) for transcription into the caller's RAG index — so 'what did X say on PTT?' is searchable later. The PERSISTENCE of the voice message itself (the message_meta row + fan-out) is handled by mDM_send_voice / mIRC_send_voice; this tool is the transcription bridge only. Honors per-user RAG opt-in: opted-out callers get status='skipped_optout' (no transcript stored). Auth: Supabase session JWT.",
|
|
89
94
|
inputSchema: mTALK_ingest_ptt_input,
|
|
90
95
|
handler: mTALK_ingest_ptt as MosaddTool["handler"],
|
|
91
96
|
},
|
package/src/tools/threat.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
THREAT_EVENTS,
|
|
23
23
|
THREAT_EVENT_COUNT,
|
|
24
24
|
evaluateEvent,
|
|
25
|
+
getEventDef,
|
|
25
26
|
type ThreatEventDef,
|
|
26
27
|
} from "@mosadd/threat-engine";
|
|
27
28
|
|
|
@@ -66,8 +67,34 @@ const threat_classify_input = z.object({
|
|
|
66
67
|
async function threat_classify(
|
|
67
68
|
input: z.infer<typeof threat_classify_input>,
|
|
68
69
|
_ctx: MosaddToolContext,
|
|
69
|
-
): Promise<{
|
|
70
|
-
|
|
70
|
+
): Promise<{
|
|
71
|
+
action: string;
|
|
72
|
+
severity: string;
|
|
73
|
+
reason: string;
|
|
74
|
+
known_event: boolean;
|
|
75
|
+
category: string | null;
|
|
76
|
+
label: string | null;
|
|
77
|
+
}> {
|
|
78
|
+
// Known taxonomy event → surface ITS severity immediately. Pegasus-class events
|
|
79
|
+
// (PROCESS_INJECTION, STINGRAY_DETECT, IMSI_CATCHER_SCAN, MEMORY_INJECTION, SS7_PROBE…)
|
|
80
|
+
// classify as critical/killswitch right away. But the engine NEVER auto-acts:
|
|
81
|
+
// action is always "monitor" — it tells you, it never disconnects, locks, or wipes.
|
|
82
|
+
// The taxonomy's own autoActions are what a stricter host policy COULD do; we do
|
|
83
|
+
// not execute them here ("monitoruje, nie działa").
|
|
84
|
+
const def = getEventDef(String(input.event_type).toUpperCase());
|
|
85
|
+
if (def) {
|
|
86
|
+
return {
|
|
87
|
+
action: "monitor",
|
|
88
|
+
severity: def.severity,
|
|
89
|
+
reason: `${def.label} (${def.category}) — classified from the mosadd threat taxonomy. Monitor-only: surfaced for you to act on, no automatic action taken.`,
|
|
90
|
+
known_event: true,
|
|
91
|
+
category: def.category,
|
|
92
|
+
label: def.label,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Unknown event string → fall back to the pure DECK decision engine (unchanged).
|
|
96
|
+
const decision = evaluateEvent({ eventType: input.event_type, severity: input.severity, details: input.details });
|
|
97
|
+
return { ...decision, known_event: false, category: null, label: null };
|
|
71
98
|
}
|
|
72
99
|
|
|
73
100
|
// ── Registration ──
|
|
@@ -85,7 +112,7 @@ export const threatTools: MosaddTool[] = [
|
|
|
85
112
|
name: "threat_classify",
|
|
86
113
|
requires: "any",
|
|
87
114
|
description:
|
|
88
|
-
"Classify a single telemetry event
|
|
115
|
+
"Classify a single telemetry event against the mosadd threat taxonomy + DECK engine. For a known event type (e.g. PROCESS_INJECTION, STINGRAY_DETECT, IMSI_CATCHER_SCAN, MEMORY_INJECTION) it returns that event's real severity (info|warning|elevated|critical|killswitch) with action=\"monitor\" — Pegasus-class events surface as critical immediately, but the engine NEVER auto-acts (it tells you, it never disconnects/locks). Unknown strings fall back to the pure DECK decision (log_only|revoke_sessions|lock_account|suspend_did). Returns { action, severity, reason, known_event, category, label }. Deterministic, offline, no backend.",
|
|
89
116
|
inputSchema: threat_classify_input,
|
|
90
117
|
handler: threat_classify as MosaddTool["handler"],
|
|
91
118
|
},
|