@mosadd/mcp 3.0.0-alpha.31 → 3.0.0-alpha.33
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 +74 -0
- package/README.md +11 -11
- package/dist/bin/mcp.js +1 -1
- package/dist/{chunk-P4ENU5MW.js → chunk-IWLN5EO5.js} +665 -140
- package/dist/index.js +1 -1
- package/package.json +15 -15
- package/src/__tests__/golden-path.test.ts +137 -137
- package/src/__tests__/integration.test.ts +179 -179
- package/src/__tests__/knowledge-ingest.test.ts +114 -0
- package/src/__tests__/mdm-e2ee.test.ts +212 -212
- package/src/__tests__/mtalk.test.ts +122 -122
- package/src/__tests__/presence.test.ts +141 -0
- package/src/__tests__/server.test.ts +71 -71
- package/src/__tests__/tool-count-consistency.test.ts +164 -0
- package/src/bin/login.ts +138 -138
- package/src/bin/mcp.ts +145 -145
- package/src/config.ts +66 -66
- package/src/crypto/mdm-session.ts +502 -502
- package/src/index.ts +19 -19
- package/src/observability/sentry.ts +79 -79
- package/src/providers/blob-upload.ts +116 -116
- package/src/providers/memory-voice.ts +79 -79
- package/src/providers/supabase-dm.ts +122 -122
- package/src/providers/supabase-voice.ts +91 -91
- package/src/providers/supabase.ts +148 -148
- package/src/server.ts +1 -1
- package/src/tools/actions.ts +162 -162
- package/src/tools/attachments.ts +268 -268
- package/src/tools/capabilities.ts +68 -68
- package/src/tools/embed.ts +108 -108
- package/src/tools/index.ts +173 -104
- package/src/tools/knowledge-graph.ts +178 -0
- package/src/tools/knowledge.ts +319 -191
- package/src/tools/mail-agentbox.ts +147 -0
- package/src/tools/mail-aliases.ts +25 -25
- package/src/tools/mail-provenance.ts +135 -135
- package/src/tools/mail.ts +381 -381
- package/src/tools/mdm.ts +476 -479
- package/src/tools/mirc-edge.ts +190 -190
- package/src/tools/mirc-members.ts +5 -5
- package/src/tools/mirc-messages.ts +155 -155
- package/src/tools/mirc.ts +63 -3
- package/src/tools/mroom-messages.ts +142 -142
- package/src/tools/mroom.ts +221 -221
- package/src/tools/mtalk.ts +121 -121
- package/src/tools/murl.ts +4 -2
- package/src/tools/presence.ts +208 -0
- package/src/types.ts +94 -94
- package/src/voice/floor.ts +132 -132
- package/LICENSE +0 -201
- package/dist/bin/login.d.ts +0 -13
- package/dist/bin/mcp.d.ts +0 -1
- package/dist/index.d.ts +0 -266
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* mIRC text mode — post + list messages inside a channel.
|
|
3
|
-
*
|
|
4
|
-
* Channel messages route through the same the mosadd backend's `message-send` / `message-list`
|
|
5
|
-
* Edge Functions as DMs, but with `thread_id: 'chat:<channelId>'` so the
|
|
6
|
-
* RLS / access checks apply channel-membership rules. Each channel is linked to a
|
|
7
|
-
* backing space (`metadata.linked_space_id`); message-send needs that space id, so
|
|
8
|
-
* these tools resolve it from the channel automatically (or accept an override).
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
13
|
-
import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
|
|
14
|
-
|
|
15
|
-
const PROTOCOL_VERSION = "mosadd.chat.v1";
|
|
16
|
-
|
|
17
|
-
const ChannelId = z.string().min(1).max(120).describe("Channel id (UUID). From mIRC_create / mIRC_list.");
|
|
18
|
-
|
|
19
|
-
const mIRC_post_message_input = z.object({
|
|
20
|
-
channel_id: ChannelId,
|
|
21
|
-
text: z.string().min(1).max(64_000).describe("Message body (UTF-8). Max 64 KB."),
|
|
22
|
-
reply_to_id: z.string().optional().describe("Optional id of the message being replied to."),
|
|
23
|
-
space_id: z
|
|
24
|
-
.string()
|
|
25
|
-
.optional()
|
|
26
|
-
.describe("Optional backing space id. Resolved automatically from the channel if omitted."),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const mIRC_list_messages_input = z.object({
|
|
30
|
-
channel_id: ChannelId,
|
|
31
|
-
limit: z.number().int().min(1).max(200).default(50).optional(),
|
|
32
|
-
cursor: z.string().optional().describe("Opaque pagination cursor from a prior list response."),
|
|
33
|
-
space_id: z.string().optional().describe("Optional backing space id. Resolved automatically if omitted."),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// ALPHA: channel messages are NOT end-to-end encrypted here — the body is wrapped
|
|
37
|
-
// in a JSON envelope and base64-encoded (server-readable). The mosadd.com app
|
|
38
|
-
// encrypts channel messages with a per-channel group key, so app clients cannot
|
|
39
|
-
// decrypt these dev-posted plaintext payloads (and vice-versa) until the toolkit
|
|
40
|
-
// adopts the same group-key scheme. See docs/security/e2ee-posture.md.
|
|
41
|
-
function packPlaintextPayload(text: string, replyToId?: string): string {
|
|
42
|
-
const envelope = {
|
|
43
|
-
v: PROTOCOL_VERSION,
|
|
44
|
-
type: "text",
|
|
45
|
-
text,
|
|
46
|
-
reply_to: replyToId ?? null,
|
|
47
|
-
sent_at: new Date().toISOString(),
|
|
48
|
-
};
|
|
49
|
-
return Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function unpackPayload(payload: string): { text: string } {
|
|
53
|
-
try {
|
|
54
|
-
const obj = JSON.parse(Buffer.from(payload, "base64").toString("utf8"));
|
|
55
|
-
if (typeof obj?.text === "string") return obj;
|
|
56
|
-
} catch {
|
|
57
|
-
/* fall through */
|
|
58
|
-
}
|
|
59
|
-
return { text: "<ciphertext>" };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** Resolve a channel's backing space id (metadata.linked_space_id) via channel-manage. */
|
|
63
|
-
async function resolveLinkedSpaceId(channelId: string): Promise<string> {
|
|
64
|
-
type GetResponse = {
|
|
65
|
-
channel?: { metadata?: { linked_space_id?: string } | null };
|
|
66
|
-
linked_space_id?: string;
|
|
67
|
-
};
|
|
68
|
-
const data = await invokeFunction<GetResponse>("channel-manage", { action: "get", channel_id: channelId });
|
|
69
|
-
const spaceId = data?.linked_space_id ?? data?.channel?.metadata?.linked_space_id;
|
|
70
|
-
if (!spaceId) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
`Channel ${channelId} has no linked space yet. Run mIRC_list (which repairs linked spaces) or mIRC_join first, ` +
|
|
73
|
-
`or pass space_id explicitly.`,
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
return spaceId;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function mIRC_post_message(
|
|
80
|
-
input: z.infer<typeof mIRC_post_message_input>,
|
|
81
|
-
ctx: MosaddToolContext,
|
|
82
|
-
): Promise<{ message_id: string; delivered_at: string; thread_id: string }> {
|
|
83
|
-
readSupabaseEnv();
|
|
84
|
-
const space_id = input.space_id ?? (await resolveLinkedSpaceId(input.channel_id));
|
|
85
|
-
const thread_id = `chat:${input.channel_id}`;
|
|
86
|
-
ctx.log("debug", "mIRC_post_message", { thread_id, space_id });
|
|
87
|
-
|
|
88
|
-
const data = await invokeFunction<{ message?: { id: string; created_at: string } }>("message-send", {
|
|
89
|
-
space_id,
|
|
90
|
-
thread_id,
|
|
91
|
-
encrypted_payload: packPlaintextPayload(input.text, input.reply_to_id),
|
|
92
|
-
message_type: "txt",
|
|
93
|
-
protocol_version: PROTOCOL_VERSION,
|
|
94
|
-
reply_to_id: input.reply_to_id ?? null,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
if (!data?.message?.id) throw new Error("message-send returned no message id");
|
|
98
|
-
return { message_id: data.message.id, delivered_at: data.message.created_at ?? new Date().toISOString(), thread_id };
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async function mIRC_list_messages(
|
|
102
|
-
input: z.infer<typeof mIRC_list_messages_input>,
|
|
103
|
-
ctx: MosaddToolContext,
|
|
104
|
-
): Promise<{
|
|
105
|
-
messages: Array<{ id: string; sender_identity_id: string; text: string; timestamp: string }>;
|
|
106
|
-
next_cursor: string | null;
|
|
107
|
-
}> {
|
|
108
|
-
readSupabaseEnv();
|
|
109
|
-
const space_id = input.space_id ?? (await resolveLinkedSpaceId(input.channel_id));
|
|
110
|
-
const thread_id = `chat:${input.channel_id}`;
|
|
111
|
-
ctx.log("debug", "mIRC_list_messages", { thread_id, space_id });
|
|
112
|
-
|
|
113
|
-
type MessageListResponse = {
|
|
114
|
-
messages?: Array<{ id: string; sender_identity_id: string; encrypted_payload: string; created_at: string }>;
|
|
115
|
-
next_before?: string | null;
|
|
116
|
-
cursor?: string | null;
|
|
117
|
-
};
|
|
118
|
-
// message-list reads `before` (history) / `since` (incremental) — NOT `cursor`.
|
|
119
|
-
// Sending `cursor` left `before` unset → every call returned the newest page.
|
|
120
|
-
const data = await invokeFunction<MessageListResponse>("message-list", {
|
|
121
|
-
space_id,
|
|
122
|
-
thread_id,
|
|
123
|
-
limit: input.limit ?? 50,
|
|
124
|
-
before: input.cursor,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
messages: (data?.messages ?? []).map((m) => ({
|
|
129
|
-
id: m.id,
|
|
130
|
-
sender_identity_id: m.sender_identity_id,
|
|
131
|
-
text: unpackPayload(m.encrypted_payload).text,
|
|
132
|
-
timestamp: m.created_at,
|
|
133
|
-
})),
|
|
134
|
-
next_cursor: data?.next_before ?? data?.cursor ?? null,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export const mircMessagesTools: MosaddTool[] = [
|
|
139
|
-
{
|
|
140
|
-
name: "mIRC_post_message",
|
|
141
|
-
requires: "network",
|
|
142
|
-
description:
|
|
143
|
-
"Post a text message into a persistent channel (mIRC). Pass channel_id from mIRC_create / mIRC_list; the backing space is resolved automatically.
|
|
144
|
-
inputSchema: mIRC_post_message_input,
|
|
145
|
-
handler: mIRC_post_message as MosaddTool["handler"],
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: "mIRC_list_messages",
|
|
149
|
-
requires: "network",
|
|
150
|
-
description:
|
|
151
|
-
"List recent text messages in a persistent channel (mIRC), newest first, cursor-paginated. Pass channel_id; the backing space is resolved automatically.",
|
|
152
|
-
inputSchema: mIRC_list_messages_input,
|
|
153
|
-
handler: mIRC_list_messages as MosaddTool["handler"],
|
|
154
|
-
},
|
|
155
|
-
];
|
|
1
|
+
/**
|
|
2
|
+
* mIRC text mode — post + list messages inside a channel.
|
|
3
|
+
*
|
|
4
|
+
* Channel messages route through the same the mosadd backend's `message-send` / `message-list`
|
|
5
|
+
* Edge Functions as DMs, but with `thread_id: 'chat:<channelId>'` so the
|
|
6
|
+
* RLS / access checks apply channel-membership rules. Each channel is linked to a
|
|
7
|
+
* backing space (`metadata.linked_space_id`); message-send needs that space id, so
|
|
8
|
+
* these tools resolve it from the channel automatically (or accept an override).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import type { MosaddTool, MosaddToolContext } from "../types.js";
|
|
13
|
+
import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
|
|
14
|
+
|
|
15
|
+
const PROTOCOL_VERSION = "mosadd.chat.v1";
|
|
16
|
+
|
|
17
|
+
const ChannelId = z.string().min(1).max(120).describe("Channel id (UUID). From mIRC_create / mIRC_list.");
|
|
18
|
+
|
|
19
|
+
const mIRC_post_message_input = z.object({
|
|
20
|
+
channel_id: ChannelId,
|
|
21
|
+
text: z.string().min(1).max(64_000).describe("Message body (UTF-8). Max 64 KB."),
|
|
22
|
+
reply_to_id: z.string().optional().describe("Optional id of the message being replied to."),
|
|
23
|
+
space_id: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Optional backing space id. Resolved automatically from the channel if omitted."),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const mIRC_list_messages_input = z.object({
|
|
30
|
+
channel_id: ChannelId,
|
|
31
|
+
limit: z.number().int().min(1).max(200).default(50).optional(),
|
|
32
|
+
cursor: z.string().optional().describe("Opaque pagination cursor from a prior list response."),
|
|
33
|
+
space_id: z.string().optional().describe("Optional backing space id. Resolved automatically if omitted."),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// ALPHA: channel messages are NOT end-to-end encrypted here — the body is wrapped
|
|
37
|
+
// in a JSON envelope and base64-encoded (server-readable). The mosadd.com app
|
|
38
|
+
// encrypts channel messages with a per-channel group key, so app clients cannot
|
|
39
|
+
// decrypt these dev-posted plaintext payloads (and vice-versa) until the toolkit
|
|
40
|
+
// adopts the same group-key scheme. See docs/security/e2ee-posture.md.
|
|
41
|
+
function packPlaintextPayload(text: string, replyToId?: string): string {
|
|
42
|
+
const envelope = {
|
|
43
|
+
v: PROTOCOL_VERSION,
|
|
44
|
+
type: "text",
|
|
45
|
+
text,
|
|
46
|
+
reply_to: replyToId ?? null,
|
|
47
|
+
sent_at: new Date().toISOString(),
|
|
48
|
+
};
|
|
49
|
+
return Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function unpackPayload(payload: string): { text: string } {
|
|
53
|
+
try {
|
|
54
|
+
const obj = JSON.parse(Buffer.from(payload, "base64").toString("utf8"));
|
|
55
|
+
if (typeof obj?.text === "string") return obj;
|
|
56
|
+
} catch {
|
|
57
|
+
/* fall through */
|
|
58
|
+
}
|
|
59
|
+
return { text: "<ciphertext>" };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Resolve a channel's backing space id (metadata.linked_space_id) via channel-manage. */
|
|
63
|
+
async function resolveLinkedSpaceId(channelId: string): Promise<string> {
|
|
64
|
+
type GetResponse = {
|
|
65
|
+
channel?: { metadata?: { linked_space_id?: string } | null };
|
|
66
|
+
linked_space_id?: string;
|
|
67
|
+
};
|
|
68
|
+
const data = await invokeFunction<GetResponse>("channel-manage", { action: "get", channel_id: channelId });
|
|
69
|
+
const spaceId = data?.linked_space_id ?? data?.channel?.metadata?.linked_space_id;
|
|
70
|
+
if (!spaceId) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Channel ${channelId} has no linked space yet. Run mIRC_list (which repairs linked spaces) or mIRC_join first, ` +
|
|
73
|
+
`or pass space_id explicitly.`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return spaceId;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function mIRC_post_message(
|
|
80
|
+
input: z.infer<typeof mIRC_post_message_input>,
|
|
81
|
+
ctx: MosaddToolContext,
|
|
82
|
+
): Promise<{ message_id: string; delivered_at: string; thread_id: string }> {
|
|
83
|
+
readSupabaseEnv();
|
|
84
|
+
const space_id = input.space_id ?? (await resolveLinkedSpaceId(input.channel_id));
|
|
85
|
+
const thread_id = `chat:${input.channel_id}`;
|
|
86
|
+
ctx.log("debug", "mIRC_post_message", { thread_id, space_id });
|
|
87
|
+
|
|
88
|
+
const data = await invokeFunction<{ message?: { id: string; created_at: string } }>("message-send", {
|
|
89
|
+
space_id,
|
|
90
|
+
thread_id,
|
|
91
|
+
encrypted_payload: packPlaintextPayload(input.text, input.reply_to_id),
|
|
92
|
+
message_type: "txt",
|
|
93
|
+
protocol_version: PROTOCOL_VERSION,
|
|
94
|
+
reply_to_id: input.reply_to_id ?? null,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (!data?.message?.id) throw new Error("message-send returned no message id");
|
|
98
|
+
return { message_id: data.message.id, delivered_at: data.message.created_at ?? new Date().toISOString(), thread_id };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function mIRC_list_messages(
|
|
102
|
+
input: z.infer<typeof mIRC_list_messages_input>,
|
|
103
|
+
ctx: MosaddToolContext,
|
|
104
|
+
): Promise<{
|
|
105
|
+
messages: Array<{ id: string; sender_identity_id: string; text: string; timestamp: string }>;
|
|
106
|
+
next_cursor: string | null;
|
|
107
|
+
}> {
|
|
108
|
+
readSupabaseEnv();
|
|
109
|
+
const space_id = input.space_id ?? (await resolveLinkedSpaceId(input.channel_id));
|
|
110
|
+
const thread_id = `chat:${input.channel_id}`;
|
|
111
|
+
ctx.log("debug", "mIRC_list_messages", { thread_id, space_id });
|
|
112
|
+
|
|
113
|
+
type MessageListResponse = {
|
|
114
|
+
messages?: Array<{ id: string; sender_identity_id: string; encrypted_payload: string; created_at: string }>;
|
|
115
|
+
next_before?: string | null;
|
|
116
|
+
cursor?: string | null;
|
|
117
|
+
};
|
|
118
|
+
// message-list reads `before` (history) / `since` (incremental) — NOT `cursor`.
|
|
119
|
+
// Sending `cursor` left `before` unset → every call returned the newest page.
|
|
120
|
+
const data = await invokeFunction<MessageListResponse>("message-list", {
|
|
121
|
+
space_id,
|
|
122
|
+
thread_id,
|
|
123
|
+
limit: input.limit ?? 50,
|
|
124
|
+
before: input.cursor,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
messages: (data?.messages ?? []).map((m) => ({
|
|
129
|
+
id: m.id,
|
|
130
|
+
sender_identity_id: m.sender_identity_id,
|
|
131
|
+
text: unpackPayload(m.encrypted_payload).text,
|
|
132
|
+
timestamp: m.created_at,
|
|
133
|
+
})),
|
|
134
|
+
next_cursor: data?.next_before ?? data?.cursor ?? null,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export const mircMessagesTools: MosaddTool[] = [
|
|
139
|
+
{
|
|
140
|
+
name: "mIRC_post_message",
|
|
141
|
+
requires: "network",
|
|
142
|
+
description:
|
|
143
|
+
"Post a text message into a persistent channel (mIRC). Pass channel_id from mIRC_create / mIRC_list; the backing space is resolved automatically. This is how an agent actually talks in a channel — the other mIRC_* tools only manage it. ACCESS: banned/blocked users are refused on ALL access modes (including open); open channels accept anyone not banned; password channels require joining with the password; private channels require request-access + approval. ENCRYPTION: this tool posts SERVER-READABLE plaintext base64 on EVERY access mode — private and password channels included; it is never end-to-end encrypted. Open channels: app clients CAN read toolkit-posted messages. Password/private channels: the mosadd.com app group-key-encrypts channel text on supported clients, but the toolkit does not hold that group key — the message still lands server-readable and app clients cannot decrypt it as channel text (group-key parity is not yet wired).",
|
|
144
|
+
inputSchema: mIRC_post_message_input,
|
|
145
|
+
handler: mIRC_post_message as MosaddTool["handler"],
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "mIRC_list_messages",
|
|
149
|
+
requires: "network",
|
|
150
|
+
description:
|
|
151
|
+
"List recent text messages in a persistent channel (mIRC), newest first, cursor-paginated. Pass channel_id; the backing space is resolved automatically.",
|
|
152
|
+
inputSchema: mIRC_list_messages_input,
|
|
153
|
+
handler: mIRC_list_messages as MosaddTool["handler"],
|
|
154
|
+
},
|
|
155
|
+
];
|
package/src/tools/mirc.ts
CHANGED
|
@@ -30,10 +30,12 @@ const AccessMode = z
|
|
|
30
30
|
const Capabilities = z
|
|
31
31
|
.object({
|
|
32
32
|
txt: z.boolean().default(true),
|
|
33
|
+
voice: z.boolean().default(false),
|
|
34
|
+
files: z.boolean().default(false),
|
|
33
35
|
ptt: z.boolean().default(false),
|
|
34
36
|
live: z.boolean().default(false),
|
|
35
37
|
})
|
|
36
|
-
.describe("Which modes are enabled
|
|
38
|
+
.describe("Which modes are enabled: txt (text), voice (group voice), files (file attach), ptt (push-to-talk), live (live stream). Voice/PTT/live are server-relayed via LiveKit — NOT end-to-end encrypted.")
|
|
37
39
|
.optional();
|
|
38
40
|
|
|
39
41
|
const mIRC_create_input = z.object({
|
|
@@ -42,11 +44,15 @@ const mIRC_create_input = z.object({
|
|
|
42
44
|
access_mode: AccessMode.default("open"),
|
|
43
45
|
password: z.string().min(6).max(120).optional().describe("Password (only for access_mode=password)."),
|
|
44
46
|
capabilities: Capabilities,
|
|
47
|
+
discoverable: z
|
|
48
|
+
.boolean()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe("List this channel in the PUBLIC directory (mIRC_discover). Honoured ONLY for access_mode=open; ignored for password/private."),
|
|
45
51
|
wrapped_group_key: z
|
|
46
52
|
.string()
|
|
47
53
|
.optional()
|
|
48
54
|
.describe(
|
|
49
|
-
"Required for access_mode=password|private (these are
|
|
55
|
+
"Required for access_mode=password|private (these channels are provisioned for group-key text encryption on supported clients): the channel's group key wrapped to the creator's identity key. Open channels ignore it. If omitted on a non-open channel the backend rejects the call with a 'wrapped_group_key required' error.",
|
|
50
56
|
),
|
|
51
57
|
});
|
|
52
58
|
|
|
@@ -70,6 +76,19 @@ const mIRC_update_input = z.object({
|
|
|
70
76
|
// switching an existing channel to/from an E2EE (password/private) mode needs
|
|
71
77
|
// group-key handling that isn't wired yet. Recreate the channel to change mode.
|
|
72
78
|
capabilities: Capabilities,
|
|
79
|
+
discoverable: z.boolean().optional().describe("Toggle public-directory listing (open channels only)."),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const mIRC_discover_input = z.object({
|
|
83
|
+
q: z.string().max(100).optional().describe("Optional channel-name filter."),
|
|
84
|
+
limit: z.number().int().min(1).max(500).default(50).optional(),
|
|
85
|
+
offset: z.number().int().min(0).default(0).optional(),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const mIRC_report_input = z.object({
|
|
89
|
+
channel_id: ChannelId,
|
|
90
|
+
reason: z.enum(["spam", "abuse", "harassment", "illegal", "other"]).describe("Report reason."),
|
|
91
|
+
detail: z.string().max(1000).optional().describe("Optional free-text context."),
|
|
73
92
|
});
|
|
74
93
|
|
|
75
94
|
const mIRC_delete_input = z.object({
|
|
@@ -147,6 +166,31 @@ async function mIRC_delete(
|
|
|
147
166
|
return { deleted: true };
|
|
148
167
|
}
|
|
149
168
|
|
|
169
|
+
async function mIRC_discover(
|
|
170
|
+
input: z.infer<typeof mIRC_discover_input>,
|
|
171
|
+
ctx: MosaddToolContext,
|
|
172
|
+
): Promise<{ channels: unknown[] }> {
|
|
173
|
+
readSupabaseEnv();
|
|
174
|
+
ctx.log("debug", "mIRC_discover invoking channel-manage");
|
|
175
|
+
return await invokeFunction<{ channels: unknown[] }>("channel-manage", {
|
|
176
|
+
action: "discover",
|
|
177
|
+
...input,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async function mIRC_report(
|
|
182
|
+
input: z.infer<typeof mIRC_report_input>,
|
|
183
|
+
ctx: MosaddToolContext,
|
|
184
|
+
): Promise<{ ok: boolean }> {
|
|
185
|
+
readSupabaseEnv();
|
|
186
|
+
ctx.log("debug", "mIRC_report invoking report-content", { channel_id: input.channel_id });
|
|
187
|
+
return await invokeFunction<{ ok: boolean }>("report-content", {
|
|
188
|
+
thread_id: `channel:${input.channel_id}`,
|
|
189
|
+
reason: input.reason,
|
|
190
|
+
detail: input.detail,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
150
194
|
// ---- Registration ----
|
|
151
195
|
|
|
152
196
|
export const mircTools: MosaddTool[] = [
|
|
@@ -154,7 +198,7 @@ export const mircTools: MosaddTool[] = [
|
|
|
154
198
|
name: "mIRC_create",
|
|
155
199
|
requires: "network",
|
|
156
200
|
description:
|
|
157
|
-
"Create a new persistent channel (Discord/Slack-style). Set access_mode to open (anyone joins), password (shared-password gated), or private (invite-only). capabilities controls modes (txt/ptt/live). NOTE: password
|
|
201
|
+
"Create a new persistent channel (Discord/Slack-style). Set access_mode to open (anyone joins), password (shared-password gated), or private (invite-only). capabilities controls modes (txt/voice/files/ptt/live; voice/ptt/live are server-relayed via LiveKit, NOT E2EE). Set discoverable:true (open channels only) to list it in the public directory. NOTE: password/private channels are provisioned for group-key TEXT encryption — supply wrapped_group_key (the group key wrapped to your identity key); open channels do not need it. The mosadd.com app encrypts/decrypts channel text with that key on supported clients; the toolkit's own mIRC_post_message posts server-readable text today (group-key parity is the next milestone). Channel voice is never E2EE.",
|
|
158
202
|
inputSchema: mIRC_create_input,
|
|
159
203
|
handler: mIRC_create as MosaddTool["handler"],
|
|
160
204
|
},
|
|
@@ -187,4 +231,20 @@ export const mircTools: MosaddTool[] = [
|
|
|
187
231
|
inputSchema: mIRC_delete_input,
|
|
188
232
|
handler: mIRC_delete as MosaddTool["handler"],
|
|
189
233
|
},
|
|
234
|
+
{
|
|
235
|
+
name: "mIRC_discover",
|
|
236
|
+
requires: "network",
|
|
237
|
+
description:
|
|
238
|
+
"Browse the PUBLIC channel DIRECTORY — open channels whose owners opted in (discoverable=true). Returns {id, channel_key, name, description, capabilities, member_count, is_member}. Filter by name with q; paginated. Join a result with mIRC_join (open = one-click). Private/password/partner channels never appear.",
|
|
239
|
+
inputSchema: mIRC_discover_input,
|
|
240
|
+
handler: mIRC_discover as MosaddTool["handler"],
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "mIRC_report",
|
|
244
|
+
requires: "network",
|
|
245
|
+
description:
|
|
246
|
+
"Report a channel for abuse (spam/harassment/illegal/etc). Metadata + reason only — never message content. The reported party is the channel owner (server-derived). Use for public-directory moderation.",
|
|
247
|
+
inputSchema: mIRC_report_input,
|
|
248
|
+
handler: mIRC_report as MosaddTool["handler"],
|
|
249
|
+
},
|
|
190
250
|
];
|