@mosadd/mcp 3.0.0-alpha.54 → 3.0.0-alpha.56
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 +29 -11
- package/LICENSE +21 -0
- package/README.md +12 -11
- package/dist/bin/mcp.js +1 -1
- package/dist/{chunk-3PUOM4R5.js → chunk-T3KDVUAT.js} +66 -28
- package/dist/index.js +1 -1
- package/package.json +10 -10
- package/src/__tests__/flota-jawnie.test.ts +244 -0
- package/src/__tests__/integration.test.ts +34 -7
- package/src/__tests__/mdm-mcp-readable.test.ts +10 -6
- package/src/__tests__/presence.test.ts +199 -199
- package/src/__tests__/tool-count-consistency.test.ts +85 -29
- package/src/index.ts +1 -1
- package/src/providers/blob-upload.ts +162 -162
- package/src/server.ts +1 -1
- package/src/tools/channel-payload.ts +69 -0
- package/src/tools/embed.ts +1 -1
- package/src/tools/mdm-as-agent.ts +18 -6
- package/src/tools/mdm.ts +26 -11
- package/src/tools/mirc-edge.ts +1 -1
- package/src/tools/mirc-messages.ts +10 -14
- package/src/tools/mroom-messages.ts +4 -12
- package/src/tools/presence.ts +3 -3
|
@@ -13,6 +13,7 @@ import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
|
13
13
|
import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
|
|
14
14
|
import { formatVoiceIfAny } from "./voice-format.js";
|
|
15
15
|
import { decryptChannelPayload, encryptChannelPayload, unwrapEnvelopeText } from "../crypto/channel-e2ee.js";
|
|
16
|
+
import { decodeStoredPayloadText } from "./channel-payload.js";
|
|
16
17
|
|
|
17
18
|
const PROTOCOL_VERSION = "mosadd.chat.v1";
|
|
18
19
|
|
|
@@ -32,7 +33,7 @@ const mIRC_post_message_input = z.object({
|
|
|
32
33
|
.optional()
|
|
33
34
|
.describe(
|
|
34
35
|
"Post AS ONE OF YOUR OWN AGENTS instead of as the key's owner — its mosADD address " +
|
|
35
|
-
"(
|
|
36
|
+
"(<agent>@mosadd.com), its identity id, or its display name. An API key is bound to a USER, " +
|
|
36
37
|
"so without this every message from an agent runtime is attributed to the owner: a whole fleet " +
|
|
37
38
|
"reporting in one channel shows up as one person. Same field name and same ownership rule as " +
|
|
38
39
|
"mDM_send_as_agent. The server verifies you OWN that agent and that it is an active member of " +
|
|
@@ -64,21 +65,16 @@ function buildPlaintextEnvelope(text: string, replyToId?: string): string {
|
|
|
64
65
|
return JSON.stringify(envelope);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
return { text: "<ciphertext>" };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Stored payload → readable text. Group-key decrypt first; legacy base64 envelope second. */
|
|
68
|
+
/**
|
|
69
|
+
* Stored payload → readable text. Group-key decrypt first; then the plain decode, which reads BOTH
|
|
70
|
+
* the toolkit's JSON envelope AND the app's raw UTF-8 text (29.09: the King's posts on the open
|
|
71
|
+
* #adm/#command used to come back as "<ciphertext>"). "<ciphertext>" is left only for a sealed
|
|
72
|
+
* envelope this line holds no key for (channel-payload.ts).
|
|
73
|
+
*/
|
|
78
74
|
async function payloadToText(channelId: string, payload: string): Promise<string> {
|
|
79
75
|
const decrypted = await decryptChannelPayload(channelId, payload);
|
|
80
76
|
if (decrypted !== null) return unwrapEnvelopeText(decrypted);
|
|
81
|
-
return
|
|
77
|
+
return decodeStoredPayloadText(payload);
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
/** Resolve a channel's backing space id (metadata.linked_space_id) via channel-manage. */
|
|
@@ -198,7 +194,7 @@ export const mircMessagesTools: MosaddTool[] = [
|
|
|
198
194
|
annotations: { readOnlyHint: true },
|
|
199
195
|
requires: "network",
|
|
200
196
|
description:
|
|
201
|
-
"List recent text messages in a persistent channel (mIRC), newest first, cursor-paginated. Pass channel_id; the backing space is resolved automatically. ENCRYPTION: messages your line can decrypt (group-key channels — auto-provisioned key material) come back as readable text;
|
|
197
|
+
"List recent text messages in a persistent channel (mIRC), newest first, cursor-paginated. Pass channel_id; the backing space is resolved automatically. ENCRYPTION: messages your line can decrypt (group-key channels — auto-provisioned key material) come back as readable text; everything else is decoded as written: the app's plain text and the toolkit's JSON envelope both come back as readable text (open channels such as #adm and #command are never encrypted). Only a sealed group-key envelope your line holds no key for reads <ciphertext>.",
|
|
202
198
|
inputSchema: mIRC_list_messages_input,
|
|
203
199
|
handler: mIRC_list_messages as MosaddTool["handler"],
|
|
204
200
|
},
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
15
15
|
import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
|
|
16
|
+
import { formatVoiceIfAny } from "./voice-format.js";
|
|
17
|
+
import { decodeStoredPayloadText } from "./channel-payload.js";
|
|
16
18
|
|
|
17
19
|
const PROTOCOL_VERSION = "mosadd.chat.v1";
|
|
18
20
|
|
|
@@ -41,17 +43,6 @@ function packPlaintextPayload(text: string, replyToId?: string): string {
|
|
|
41
43
|
return Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
function unpackPayload(payload: string): { text: string } {
|
|
45
|
-
try {
|
|
46
|
-
const json = Buffer.from(payload, "base64").toString("utf8");
|
|
47
|
-
const obj = JSON.parse(json);
|
|
48
|
-
if (typeof obj?.text === "string") return obj;
|
|
49
|
-
} catch {
|
|
50
|
-
/* fall through */
|
|
51
|
-
}
|
|
52
|
-
return { text: "<ciphertext>" };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
46
|
async function mROOM_send_message(
|
|
56
47
|
input: z.infer<typeof mROOM_send_message_input>,
|
|
57
48
|
ctx: MosaddToolContext,
|
|
@@ -115,7 +106,8 @@ async function mROOM_list_messages(
|
|
|
115
106
|
messages: (data?.messages ?? []).map((m) => ({
|
|
116
107
|
id: m.id,
|
|
117
108
|
sender_identity_id: m.sender_identity_id,
|
|
118
|
-
|
|
109
|
+
// same decode as mIRC (29.09): plain text from the app reads as text, not "<ciphertext>"
|
|
110
|
+
text: formatVoiceIfAny(decodeStoredPayloadText(m.encrypted_payload)),
|
|
119
111
|
timestamp: m.created_at,
|
|
120
112
|
})),
|
|
121
113
|
next_cursor: data?.next_cursor ?? null,
|
package/src/tools/presence.ts
CHANGED
|
@@ -130,7 +130,7 @@ async function resolveSelf(
|
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* Resolve ONE agent OWNED by the caller from what they typed: identity uuid, mosADD address
|
|
133
|
-
* (
|
|
133
|
+
* (<agent>@mosadd.com) or display name. Mirrors the server-side ownership rule
|
|
134
134
|
* (m0ssad-3 `_shared/ownedAgent.ts`): kind='agent' AND owner_user_id = caller AND not retired.
|
|
135
135
|
* Ownership is part of the QUERY — a stranger's agent resolves to nothing, never to a row we
|
|
136
136
|
* would then have to remember to reject.
|
|
@@ -190,7 +190,7 @@ const comms_session_attach_input = z.object({
|
|
|
190
190
|
.max(200)
|
|
191
191
|
.optional()
|
|
192
192
|
.describe(
|
|
193
|
-
"Speak as ONE OF THE OWNER'S AGENT LINES while holding the owner's key — its mosADD address (
|
|
193
|
+
"Speak as ONE OF THE OWNER'S AGENT LINES while holding the owner's key — its mosADD address (<agent>@mosadd.com), identity id, or display name. Declares ONCE per session whose line this session speaks for: the gateway then signs your CHANNEL posts as that agent automatically (no per-post `agent` field needed), and that agent's cloud stand-in defers to you. The server verifies you OWN the agent; a stranger's agent is refused. Omit to claim the key's own line, exactly as before.",
|
|
194
194
|
),
|
|
195
195
|
release: z
|
|
196
196
|
.boolean()
|
|
@@ -362,7 +362,7 @@ export const presenceTools: MosaddTool[] = [
|
|
|
362
362
|
annotations: { destructiveHint: false, idempotentHint: true },
|
|
363
363
|
requires: "network",
|
|
364
364
|
description:
|
|
365
|
-
"Claim a mosADD reply lane for the CURRENT agent session, so the 24/7 cloud stand-in stops answering in its place and the owner talks to you instead. Call it once at the start of a session; the hold renews itself while the session runs and lapses on its own if the session dies. Holding the OWNER's key while working as one of their agent lines? Pass as_agent:'<address of YOUR line>' (e.g.
|
|
365
|
+
"Claim a mosADD reply lane for the CURRENT agent session, so the 24/7 cloud stand-in stops answering in its place and the owner talks to you instead. Call it once at the start of a session; the hold renews itself while the session runs and lapses on its own if the session dies. Holding the OWNER's key while working as one of their agent lines? Pass as_agent:'<address of YOUR line>' (e.g. <agent>@mosadd.com) — the gateway then signs your channel posts as that agent automatically for the whole session and silences that agent's stand-in; ownership is verified server-side. Pass release:true when finishing to hand everything back immediately. Owner-scoped: a session can only claim the account whose key it holds, or a line of an agent that account owns.",
|
|
366
366
|
inputSchema: comms_session_attach_input,
|
|
367
367
|
handler: comms_session_attach as MosaddTool["handler"],
|
|
368
368
|
},
|