@mosadd/mcp 3.0.0-alpha.55 → 3.0.0-alpha.57
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 +15 -11
- package/README.md +152 -150
- package/dist/bin/mcp.js +1 -1
- package/dist/{chunk-IWUGKLDX.js → chunk-WEGSITAH.js} +30 -14
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/__tests__/blob-upload.test.ts +93 -93
- package/src/__tests__/channel-e2ee.test.ts +62 -62
- package/src/__tests__/flota-jawnie.test.ts +2 -2
- package/src/__tests__/golden-path.test.ts +139 -139
- package/src/__tests__/integration.test.ts +217 -182
- package/src/__tests__/label-room-owner.test.ts +22 -0
- package/src/__tests__/mdm-e2ee.test.ts +212 -212
- package/src/__tests__/mdm-mcp-readable.test.ts +390 -390
- package/src/__tests__/mirc-invite.test.ts +112 -112
- package/src/__tests__/mtalk.test.ts +122 -122
- package/src/__tests__/presence.test.ts +199 -199
- package/src/__tests__/server.test.ts +71 -71
- package/src/__tests__/tool-count-consistency.test.ts +259 -199
- package/src/__tests__/voice-fields.test.ts +24 -0
- package/src/bin/login.ts +138 -138
- package/src/bin/mcp.ts +145 -145
- package/src/config.ts +66 -66
- package/src/crypto/channel-e2ee.ts +288 -288
- package/src/crypto/mdm-session.ts +842 -842
- package/src/index.ts +19 -19
- package/src/observability/sentry.ts +79 -79
- package/src/providers/blob-upload.ts +162 -162
- package/src/providers/memory-voice.ts +79 -79
- package/src/providers/supabase-dm.ts +212 -202
- package/src/providers/supabase-voice.ts +103 -91
- package/src/server.ts +195 -195
- package/src/tools/actions.ts +166 -166
- package/src/tools/attachments.ts +276 -276
- package/src/tools/capabilities.ts +70 -70
- package/src/tools/channel-payload.ts +2 -2
- package/src/tools/embed.ts +110 -110
- package/src/tools/index.ts +181 -181
- package/src/tools/knowledge.ts +344 -344
- package/src/tools/mail-aliases.ts +25 -25
- package/src/tools/mail-provenance.ts +137 -137
- package/src/tools/mail.ts +403 -403
- package/src/tools/mdm-as-agent.ts +138 -126
- package/src/tools/mdm.ts +6 -4
- package/src/tools/mirc-edge.ts +196 -196
- package/src/tools/mirc-members.ts +287 -287
- package/src/tools/mirc-messages.ts +1 -1
- package/src/tools/mirc.ts +308 -308
- package/src/tools/mroom.ts +221 -221
- package/src/tools/mtalk.ts +131 -131
- package/src/tools/presence.ts +442 -442
- package/src/tools/voice-format.ts +43 -28
- package/src/types.ts +121 -121
- package/src/voice/floor.ts +132 -132
|
@@ -1,126 +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
|
|
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 (
|
|
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
|
-
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
inputSchema:
|
|
124
|
-
handler:
|
|
125
|
-
},
|
|
126
|
-
|
|
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.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { z } from "zod";
|
|
18
18
|
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
19
|
-
import { formatVoiceIfAny } from "./voice-format.js";
|
|
19
|
+
import { formatVoiceIfAny, voiceFields } from "./voice-format.js";
|
|
20
20
|
import { invokeFunction, getSupabase, readSupabaseEnv } from "../providers/supabase.js";
|
|
21
21
|
import {
|
|
22
22
|
encryptForPeer,
|
|
@@ -211,8 +211,8 @@ async function mDM_send(
|
|
|
211
211
|
// linie<->Krol, czlowiek->linia: jawnie). Plaintext is readable by every key of the line and by
|
|
212
212
|
// the recipient's app on every device, and no bundle is needed, so nothing can flap.
|
|
213
213
|
//
|
|
214
|
-
//
|
|
215
|
-
//
|
|
214
|
+
// 29.09.2026 (owner decision 28.09: no encryption on agent-line conversations, in any channel or
|
|
215
|
+
// identity): a note to SELF (to === selfId) goes in the
|
|
216
216
|
// clear too. MCP sessions on the King's key sealed his own thread (11 envelopes 21.09) and the
|
|
217
217
|
// server now refuses envelopes there (message-send `fleet_plaintext_only`). Kinds of BOTH sides
|
|
218
218
|
// are read from `identities.kind` before any sealing; only person↔person stays E2EE.
|
|
@@ -221,7 +221,7 @@ async function mDM_send(
|
|
|
221
221
|
const peerKind = selfKind === "agent" || noteToSelf ? selfKind : await peerKindOf(dm, input.to);
|
|
222
222
|
if (selfKind === "agent" || peerKind === "agent" || noteToSelf) {
|
|
223
223
|
const payload = packPlaintextPayload(input.text);
|
|
224
|
-
ctx.log("debug", "mDM_send
|
|
224
|
+
ctx.log("debug", "mDM_send agent-line plaintext (owner decisions 20.09 + 28.09)", {
|
|
225
225
|
thread_id: threadId,
|
|
226
226
|
self_kind: selfKind,
|
|
227
227
|
peer_kind: peerKind,
|
|
@@ -402,6 +402,7 @@ async function mDM_list(
|
|
|
402
402
|
timestamp: string;
|
|
403
403
|
thread_id: string;
|
|
404
404
|
encrypted: boolean;
|
|
405
|
+
voice?: { transcript: string | null; audio_url: string | null; duration_ms: number | null };
|
|
405
406
|
}>;
|
|
406
407
|
next_cursor: string | null;
|
|
407
408
|
threads: string[];
|
|
@@ -434,6 +435,7 @@ async function mDM_list(
|
|
|
434
435
|
sender_identity_id: m.senderId,
|
|
435
436
|
timestamp: m.timestamp,
|
|
436
437
|
thread_id: m.threadId,
|
|
438
|
+
...voiceFields(m),
|
|
437
439
|
};
|
|
438
440
|
// Legacy plaintext envelope (deprecated path) — unpack directly.
|
|
439
441
|
if (!isE2eeEnvelope(m.payload)) {
|