@mosadd/mcp 3.0.0-alpha.6 → 3.0.0
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 +410 -0
- package/README.md +79 -40
- package/dist/bin/mcp.js +132 -8
- package/dist/chunk-VMMJJYXF.js +4233 -0
- package/dist/index.d.ts +110 -6
- 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__/flota-jawnie.test.ts +244 -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 +35 -1
- package/src/__tests__/mdm-mcp-readable.test.ts +390 -0
- package/src/__tests__/mirc-invite.test.ts +112 -0
- package/src/__tests__/mrag-search-answer.test.ts +42 -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 +476 -37
- 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 +351 -132
- 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 +284 -38
- package/src/tools/mdm-as-agent.ts +138 -0
- package/src/tools/mdm-voice.ts +17 -3
- package/src/tools/mdm.ts +303 -57
- package/src/tools/mirc-edge.ts +8 -2
- package/src/tools/mirc-members.ts +130 -20
- package/src/tools/mirc-messages.ts +80 -35
- package/src/tools/mirc.ts +149 -11
- package/src/tools/mroom-messages.ts +4 -12
- 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 +43 -0
- package/src/types.ts +36 -0
- package/src/version.ts +8 -0
- package/LICENSE +0 -201
- package/dist/chunk-KAPG5FBN.js +0 -1844
|
@@ -0,0 +1,138 @@
|
|
|
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 filed as LINEAR-5625; 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
|
+
* LINEAR-5620.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import { z } from "zod";
|
|
41
|
+
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
42
|
+
import { invokeFunction } from "../providers/supabase.js";
|
|
43
|
+
|
|
44
|
+
const mDM_send_as_agent_input = z.object({
|
|
45
|
+
agent: z
|
|
46
|
+
.string()
|
|
47
|
+
.min(1)
|
|
48
|
+
.max(200)
|
|
49
|
+
.describe(
|
|
50
|
+
"Which of YOUR agents to speak as — its mosADD address (<agent>@mosadd.com), " +
|
|
51
|
+
"its identity id, or its display name. Must be an agent you own.",
|
|
52
|
+
),
|
|
53
|
+
text: z.string().min(1).max(8000).describe("The message body, as the agent would write it."),
|
|
54
|
+
to: z
|
|
55
|
+
.string()
|
|
56
|
+
.max(200)
|
|
57
|
+
.optional()
|
|
58
|
+
.describe(
|
|
59
|
+
"Recipient identity id or mosADD address. Defaults to YOU (the key's owner) — " +
|
|
60
|
+
"the common case is an agent reporting to its owner. Must be a person, not another agent.",
|
|
61
|
+
),
|
|
62
|
+
thread_label: z
|
|
63
|
+
.string()
|
|
64
|
+
.min(1)
|
|
65
|
+
.max(120)
|
|
66
|
+
.regex(/^[a-zA-Z0-9._-]+$/)
|
|
67
|
+
.optional()
|
|
68
|
+
.describe(
|
|
69
|
+
"Optional thread label (same as mDM_send). Omit for the MAIN unlabeled thread — required for " +
|
|
70
|
+
"SOVEREIGN/King traffic until rename/UI merge (LINEAR-6577). A new label opens a new thread.",
|
|
71
|
+
),
|
|
72
|
+
silent: z
|
|
73
|
+
.boolean()
|
|
74
|
+
.optional()
|
|
75
|
+
.describe("Deliver without waking a phone: the message still arrives and shows unread, only the OS push is skipped."),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const mDM_list_my_agents_input = z.object({});
|
|
79
|
+
|
|
80
|
+
type SendResult = {
|
|
81
|
+
ok: boolean;
|
|
82
|
+
sent_as: { identity_id: string; address: string | null; display_name: string | null };
|
|
83
|
+
to: { identity_id: string; display_name: string | null };
|
|
84
|
+
thread_id: string;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
async function mDM_send_as_agent(
|
|
88
|
+
input: z.infer<typeof mDM_send_as_agent_input>,
|
|
89
|
+
ctx: MosaddToolContext,
|
|
90
|
+
): Promise<SendResult> {
|
|
91
|
+
ctx.log("debug", "mDM_send_as_agent", { agent: input.agent, thread_label: input.thread_label });
|
|
92
|
+
return await invokeFunction<SendResult>("mdm-send-as-agent", {
|
|
93
|
+
agent: input.agent,
|
|
94
|
+
text: input.text,
|
|
95
|
+
...(input.to ? { to: input.to } : {}),
|
|
96
|
+
...(input.thread_label ? { thread_label: input.thread_label } : {}),
|
|
97
|
+
...(input.silent ? { silent: true } : {}),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function mDM_list_my_agents(
|
|
102
|
+
_input: z.infer<typeof mDM_list_my_agents_input>,
|
|
103
|
+
ctx: MosaddToolContext,
|
|
104
|
+
): Promise<{ agents: Array<{ identity_id: string; address: string | null; display_name: string | null }> }> {
|
|
105
|
+
ctx.log("debug", "mDM_list_my_agents");
|
|
106
|
+
return await invokeFunction("mdm-send-as-agent", { action: "list_agents" });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const mdmAsAgentTools: MosaddTool[] = [
|
|
110
|
+
{
|
|
111
|
+
name: "mDM_send_as_agent",
|
|
112
|
+
title: "Send DM as your agent",
|
|
113
|
+
annotations: { readOnlyHint: false },
|
|
114
|
+
requires: "network",
|
|
115
|
+
description:
|
|
116
|
+
"Send a direct message AS ONE OF YOUR OWN AGENTS instead of as yourself. Use this when you are an " +
|
|
117
|
+
"agent runtime (Dispatch, Hermes, a CTO agent) connected with your owner's key: without it every " +
|
|
118
|
+
"message you send appears to come FROM the owner, so the owner has no thread with you. Names the " +
|
|
119
|
+
"agent by mosADD address, identity id or display name; `to` defaults to the key's owner. Optional " +
|
|
120
|
+
"`thread_label` selects a named thread (omit = MAIN unlabeled — required for King/SOVEREIGN until " +
|
|
121
|
+
"rename lands). The server verifies you OWN that agent — speaking as someone else's agent, or as " +
|
|
122
|
+
"another person, is refused. Recipient must be a person: agent-to-agent DM stays blocked.",
|
|
123
|
+
inputSchema: mDM_send_as_agent_input,
|
|
124
|
+
handler: mDM_send_as_agent as MosaddTool["handler"],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "mDM_list_my_agents",
|
|
128
|
+
title: "List your agents",
|
|
129
|
+
annotations: { readOnlyHint: true },
|
|
130
|
+
requires: "network",
|
|
131
|
+
description:
|
|
132
|
+
"List the agents you are allowed to speak as with mDM_send_as_agent — every live agent owned by " +
|
|
133
|
+
"the account behind this key, with its identity id, mosADD address and display name. Call this " +
|
|
134
|
+
"first when you are unsure which agent identity you hold.",
|
|
135
|
+
inputSchema: mDM_list_my_agents_input,
|
|
136
|
+
handler: mDM_list_my_agents as MosaddTool["handler"],
|
|
137
|
+
},
|
|
138
|
+
];
|
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.",
|