@mosadd/mcp 3.0.0-alpha.3 → 3.0.0-alpha.30
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 +212 -0
- package/README.md +150 -116
- package/dist/bin/mcp.js +42 -3
- package/dist/chunk-6PGDNIKR.js +2556 -0
- package/dist/index.d.ts +99 -7
- package/dist/index.js +7 -3
- package/package.json +10 -7
- package/src/__tests__/golden-path.test.ts +137 -132
- package/src/__tests__/integration.test.ts +179 -175
- package/src/__tests__/mdm-e2ee.test.ts +212 -149
- package/src/__tests__/mtalk.test.ts +122 -0
- package/src/__tests__/server.test.ts +71 -67
- package/src/bin/login.ts +138 -138
- package/src/bin/mcp.ts +145 -97
- package/src/config.ts +66 -66
- package/src/crypto/mdm-session.ts +502 -378
- package/src/index.ts +19 -17
- package/src/observability/sentry.ts +79 -79
- package/src/providers/blob-upload.ts +116 -0
- package/src/providers/memory-voice.ts +79 -0
- package/src/providers/supabase-dm.ts +122 -117
- package/src/providers/supabase-voice.ts +91 -0
- package/src/providers/supabase.ts +148 -96
- package/src/server.ts +123 -103
- package/src/tools/actions.ts +162 -0
- package/src/tools/attachments.ts +268 -0
- package/src/tools/capabilities.ts +68 -68
- package/src/tools/embed.ts +108 -0
- package/src/tools/index.ts +104 -37
- package/src/tools/knowledge.ts +191 -0
- package/src/tools/mail-aliases.ts +25 -0
- package/src/tools/mail-provenance.ts +135 -0
- package/src/tools/mail.ts +381 -89
- package/src/tools/mcall.ts +216 -0
- package/src/tools/mdm-voice.ts +212 -0
- package/src/tools/mdm.ts +479 -379
- package/src/tools/mirc-edge.ts +190 -0
- package/src/tools/mirc-members.ts +198 -177
- package/src/tools/mirc-messages.ts +155 -0
- package/src/tools/mirc.ts +190 -170
- package/src/tools/mroom-messages.ts +142 -142
- package/src/tools/mroom.ts +221 -189
- package/src/tools/mtalk.ts +121 -0
- package/src/tools/murl.ts +298 -0
- package/src/tools/ptt-ingest.ts +97 -0
- package/src/tools/threat.ts +119 -0
- package/src/types.ts +94 -79
- package/src/voice/floor.ts +132 -0
- package/dist/chunk-HD5RLE5K.js +0 -1193
package/dist/chunk-HD5RLE5K.js
DELETED
|
@@ -1,1193 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isSessionExpired,
|
|
3
|
-
loadSession
|
|
4
|
-
} from "./chunk-Z7WR52GE.js";
|
|
5
|
-
|
|
6
|
-
// src/tools/mdm.ts
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
|
|
9
|
-
// src/providers/supabase.ts
|
|
10
|
-
import { createClient } from "@supabase/supabase-js";
|
|
11
|
-
var MissingSupabaseEnvError = class extends Error {
|
|
12
|
-
constructor(missing) {
|
|
13
|
-
super(
|
|
14
|
-
`Missing Supabase credentials: ${missing.join(", ")}. Run \`mosadd login\`, or set MOSADD_SUPABASE_URL, MOSADD_SUPABASE_ANON_KEY and MOSADD_USER_JWT.`
|
|
15
|
-
);
|
|
16
|
-
this.name = "MissingSupabaseEnvError";
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
function readSupabaseEnv() {
|
|
20
|
-
const env = (canonical, legacy) => process.env[canonical] ?? process.env[legacy];
|
|
21
|
-
const userJwtEnv = env("MOSADD_USER_JWT", "M0SSAD_USER_JWT");
|
|
22
|
-
const session = loadSession();
|
|
23
|
-
const url = env("MOSADD_SUPABASE_URL", "M0SSAD_SUPABASE_URL") ?? session?.url;
|
|
24
|
-
const anonKey = env("MOSADD_SUPABASE_ANON_KEY", "M0SSAD_SUPABASE_ANON_KEY") ?? session?.anonKey;
|
|
25
|
-
const userJwt = userJwtEnv ?? session?.accessToken;
|
|
26
|
-
const missing = [];
|
|
27
|
-
if (!url) missing.push("MOSADD_SUPABASE_URL");
|
|
28
|
-
if (!anonKey) missing.push("MOSADD_SUPABASE_ANON_KEY");
|
|
29
|
-
if (missing.length) throw new MissingSupabaseEnvError(missing);
|
|
30
|
-
if (!userJwtEnv && session && isSessionExpired(session)) {
|
|
31
|
-
throw new Error("Your mosadd session has expired. Run `mosadd login` again to refresh it.");
|
|
32
|
-
}
|
|
33
|
-
return { url, anonKey, userJwt };
|
|
34
|
-
}
|
|
35
|
-
function getSupabase(env = readSupabaseEnv()) {
|
|
36
|
-
return createClient(env.url, env.anonKey, {
|
|
37
|
-
auth: {
|
|
38
|
-
persistSession: false,
|
|
39
|
-
autoRefreshToken: false,
|
|
40
|
-
detectSessionInUrl: false
|
|
41
|
-
},
|
|
42
|
-
global: env.userJwt ? {
|
|
43
|
-
headers: { Authorization: `Bearer ${env.userJwt}` }
|
|
44
|
-
} : void 0
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
async function invokeFunction(fn, body) {
|
|
48
|
-
const client = getSupabase();
|
|
49
|
-
const { data, error } = await client.functions.invoke(fn, { body });
|
|
50
|
-
if (error) {
|
|
51
|
-
const msg = error instanceof Error ? error.message : typeof error?.message === "string" ? error.message : `Edge function ${fn} failed`;
|
|
52
|
-
throw new Error(msg);
|
|
53
|
-
}
|
|
54
|
-
if (data == null) {
|
|
55
|
-
throw new Error(`Edge function ${fn} returned no data`);
|
|
56
|
-
}
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// src/crypto/mdm-session.ts
|
|
61
|
-
import {
|
|
62
|
-
decryptBytes,
|
|
63
|
-
encryptBytes,
|
|
64
|
-
generateEd25519KeyPair,
|
|
65
|
-
generateX25519KeyPair,
|
|
66
|
-
initializeRatchet,
|
|
67
|
-
performX3dh,
|
|
68
|
-
performX3dhResponder,
|
|
69
|
-
ratchetReceive,
|
|
70
|
-
ratchetSend,
|
|
71
|
-
signEd25519,
|
|
72
|
-
verifyEd25519,
|
|
73
|
-
toBase64,
|
|
74
|
-
fromBase64
|
|
75
|
-
} from "@mosadd/crypto";
|
|
76
|
-
var PREKEY_BUNDLE_VERSION = "mosadd.prekeys.v1";
|
|
77
|
-
var E2EE_ENVELOPE_VERSION = "mosadd.e2ee.v1";
|
|
78
|
-
var DEFAULT_ONE_TIME_PREKEYS = 8;
|
|
79
|
-
var InMemoryMdmKeyStore = class {
|
|
80
|
-
material = null;
|
|
81
|
-
oneTimeById = /* @__PURE__ */ new Map();
|
|
82
|
-
sessions = /* @__PURE__ */ new Map();
|
|
83
|
-
async getOwnMaterial() {
|
|
84
|
-
if (this.material) return this.material;
|
|
85
|
-
const identity = await generateX25519KeyPair();
|
|
86
|
-
const signingIdentity = await generateEd25519KeyPair();
|
|
87
|
-
const signedPrekeyPair = await generateX25519KeyPair();
|
|
88
|
-
const signedPrekey = { id: randomId(), pair: signedPrekeyPair };
|
|
89
|
-
const oneTimePrekeys = [];
|
|
90
|
-
for (let i = 0; i < DEFAULT_ONE_TIME_PREKEYS; i += 1) {
|
|
91
|
-
const pair = await generateX25519KeyPair();
|
|
92
|
-
const id = randomId();
|
|
93
|
-
oneTimePrekeys.push({ id, pair });
|
|
94
|
-
this.oneTimeById.set(id, pair.privateKey);
|
|
95
|
-
}
|
|
96
|
-
this.material = { identity, signingIdentity, signedPrekey, oneTimePrekeys };
|
|
97
|
-
return this.material;
|
|
98
|
-
}
|
|
99
|
-
async takeOneTimePrekey(id) {
|
|
100
|
-
const priv = this.oneTimeById.get(id);
|
|
101
|
-
if (priv) this.oneTimeById.delete(id);
|
|
102
|
-
return priv;
|
|
103
|
-
}
|
|
104
|
-
async getSession(peerId) {
|
|
105
|
-
return this.sessions.get(peerId);
|
|
106
|
-
}
|
|
107
|
-
async putSession(peerId, record) {
|
|
108
|
-
this.sessions.set(peerId, record);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
function randomId() {
|
|
112
|
-
return crypto.getRandomValues(new Uint32Array(1))[0];
|
|
113
|
-
}
|
|
114
|
-
function bundleSigningMessage(dhIdentityPub, signedPrekeyPub) {
|
|
115
|
-
const msg = new Uint8Array(dhIdentityPub.length + signedPrekeyPub.length);
|
|
116
|
-
msg.set(dhIdentityPub, 0);
|
|
117
|
-
msg.set(signedPrekeyPub, dhIdentityPub.length);
|
|
118
|
-
return msg;
|
|
119
|
-
}
|
|
120
|
-
function serializePublicBundle(material) {
|
|
121
|
-
const signature = signEd25519(
|
|
122
|
-
material.signingIdentity.privateKey,
|
|
123
|
-
bundleSigningMessage(material.identity.publicKey, material.signedPrekey.pair.publicKey)
|
|
124
|
-
);
|
|
125
|
-
const json = JSON.stringify({
|
|
126
|
-
v: PREKEY_BUNDLE_VERSION,
|
|
127
|
-
ik: toBase64(material.identity.publicKey),
|
|
128
|
-
sik: toBase64(material.signingIdentity.publicKey),
|
|
129
|
-
spk: { id: material.signedPrekey.id, pub: toBase64(material.signedPrekey.pair.publicKey) },
|
|
130
|
-
opks: material.oneTimePrekeys.map((k) => ({ id: k.id, pub: toBase64(k.pair.publicKey) })),
|
|
131
|
-
sig: toBase64(signature)
|
|
132
|
-
});
|
|
133
|
-
return new Uint8Array(Buffer.from(json, "utf8"));
|
|
134
|
-
}
|
|
135
|
-
function parsePublicBundle(bytes) {
|
|
136
|
-
const obj = JSON.parse(Buffer.from(bytes).toString("utf8"));
|
|
137
|
-
if (obj?.v !== PREKEY_BUNDLE_VERSION) {
|
|
138
|
-
throw new Error(`Unsupported prekey bundle version: ${obj?.v}`);
|
|
139
|
-
}
|
|
140
|
-
if (typeof obj.sik !== "string" || typeof obj.sig !== "string") {
|
|
141
|
-
throw new Error("Prekey bundle is missing its signing identity / signature.");
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
identityPublicKey: fromBase64(obj.ik),
|
|
145
|
-
signingIdentityPublicKey: fromBase64(obj.sik),
|
|
146
|
-
signedPrekey: { id: obj.spk.id, publicKey: fromBase64(obj.spk.pub) },
|
|
147
|
-
oneTimePrekeys: (obj.opks ?? []).map((k) => ({
|
|
148
|
-
id: k.id,
|
|
149
|
-
publicKey: fromBase64(k.pub)
|
|
150
|
-
})),
|
|
151
|
-
signature: fromBase64(obj.sig)
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function verifyPublicBundle(bundle) {
|
|
155
|
-
return verifyEd25519(
|
|
156
|
-
bundle.signature,
|
|
157
|
-
bundleSigningMessage(bundle.identityPublicKey, bundle.signedPrekey.publicKey),
|
|
158
|
-
bundle.signingIdentityPublicKey
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
function isE2eeEnvelope(bytes) {
|
|
162
|
-
try {
|
|
163
|
-
const obj = JSON.parse(Buffer.from(bytes).toString("utf8"));
|
|
164
|
-
return obj?.v === E2EE_ENVELOPE_VERSION && typeof obj?.i === "number" && !!obj?.ct;
|
|
165
|
-
} catch {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function serializeEnvelope(env) {
|
|
170
|
-
return new Uint8Array(Buffer.from(JSON.stringify(env), "utf8"));
|
|
171
|
-
}
|
|
172
|
-
function parseEnvelope(bytes) {
|
|
173
|
-
const obj = JSON.parse(Buffer.from(bytes).toString("utf8"));
|
|
174
|
-
if (obj?.v !== E2EE_ENVELOPE_VERSION) throw new Error(`Unsupported mDM envelope version: ${obj?.v}`);
|
|
175
|
-
return obj;
|
|
176
|
-
}
|
|
177
|
-
async function publishOwnPrekeys(keystore, dm) {
|
|
178
|
-
const material = await keystore.getOwnMaterial();
|
|
179
|
-
await dm.publishPrekeyBundle(serializePublicBundle(material));
|
|
180
|
-
return { oneTimePrekeyCount: material.oneTimePrekeys.length };
|
|
181
|
-
}
|
|
182
|
-
async function encryptForPeer(keystore, dm, peerId, plaintext) {
|
|
183
|
-
let session = await keystore.getSession(peerId);
|
|
184
|
-
if (!session) {
|
|
185
|
-
const raw = await dm.fetchPrekeyBundle(peerId);
|
|
186
|
-
if (!raw) {
|
|
187
|
-
throw new Error(
|
|
188
|
-
`Peer "${peerId}" has not published a prekey bundle yet, so an encrypted session cannot be established. Ask them to run mDM_publish_keys, or use mDM_send_unencrypted (deprecated) for the migration window.`
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
const peer = parsePublicBundle(raw);
|
|
192
|
-
if (!verifyPublicBundle(peer)) {
|
|
193
|
-
throw new Error(
|
|
194
|
-
`Prekey bundle for "${peerId}" failed signature verification \u2014 refusing to start an encrypted session (possible tampering / man-in-the-middle).`
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
const own = await keystore.getOwnMaterial();
|
|
198
|
-
const ephemeral = await generateX25519KeyPair();
|
|
199
|
-
const opk = peer.oneTimePrekeys[0];
|
|
200
|
-
const { rootKey } = await performX3dh(own.identity.privateKey, ephemeral.privateKey, {
|
|
201
|
-
identityPublicKey: peer.identityPublicKey,
|
|
202
|
-
signedPreKeyPublicKey: peer.signedPrekey.publicKey,
|
|
203
|
-
oneTimePreKeyPublicKey: opk?.publicKey
|
|
204
|
-
});
|
|
205
|
-
const ratchet = await initializeRatchet(rootKey, "initiator");
|
|
206
|
-
session = {
|
|
207
|
-
ratchet,
|
|
208
|
-
role: "initiator",
|
|
209
|
-
pendingHandshake: { ik: own.identity.publicKey, ek: ephemeral.publicKey, opkId: opk?.id }
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
const step = await ratchetSend(session.ratchet);
|
|
213
|
-
const ct = await encryptBytes(step.messageKey, plaintext);
|
|
214
|
-
const env = { v: E2EE_ENVELOPE_VERSION, i: step.messageIndex, ct };
|
|
215
|
-
if (session.pendingHandshake && step.messageIndex === 0) {
|
|
216
|
-
env.hdr = {
|
|
217
|
-
ik: toBase64(session.pendingHandshake.ik),
|
|
218
|
-
ek: toBase64(session.pendingHandshake.ek),
|
|
219
|
-
opk: session.pendingHandshake.opkId
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
session.pendingHandshake = void 0;
|
|
223
|
-
await keystore.putSession(peerId, session);
|
|
224
|
-
return serializeEnvelope(env);
|
|
225
|
-
}
|
|
226
|
-
async function decryptFromPeer(keystore, peerId, envelopeBytes) {
|
|
227
|
-
const env = parseEnvelope(envelopeBytes);
|
|
228
|
-
let session = await keystore.getSession(peerId);
|
|
229
|
-
if (!session) {
|
|
230
|
-
if (!env.hdr) {
|
|
231
|
-
throw new Error(
|
|
232
|
-
`No session with "${peerId}" and the message carries no handshake header \u2014 cannot decrypt.`
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
const own = await keystore.getOwnMaterial();
|
|
236
|
-
let oneTimePreKeyPrivateKey;
|
|
237
|
-
if (env.hdr.opk !== void 0) {
|
|
238
|
-
oneTimePreKeyPrivateKey = await keystore.takeOneTimePrekey(env.hdr.opk);
|
|
239
|
-
if (!oneTimePreKeyPrivateKey) {
|
|
240
|
-
throw new Error(
|
|
241
|
-
`Handshake references one-time prekey ${env.hdr.opk} which is unknown or already consumed.`
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const { rootKey } = await performX3dhResponder(
|
|
246
|
-
{
|
|
247
|
-
identityPrivateKey: own.identity.privateKey,
|
|
248
|
-
signedPreKeyPrivateKey: own.signedPrekey.pair.privateKey,
|
|
249
|
-
oneTimePreKeyPrivateKey
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
initiatorIdentityPublicKey: fromBase64(env.hdr.ik),
|
|
253
|
-
initiatorEphemeralPublicKey: fromBase64(env.hdr.ek),
|
|
254
|
-
usedOneTimePreKeyId: env.hdr.opk
|
|
255
|
-
}
|
|
256
|
-
);
|
|
257
|
-
const ratchet = await initializeRatchet(rootKey, "responder");
|
|
258
|
-
session = { ratchet, role: "responder" };
|
|
259
|
-
}
|
|
260
|
-
const step = await ratchetReceive(session.ratchet);
|
|
261
|
-
if (step.messageIndex !== env.i) {
|
|
262
|
-
throw new Error(
|
|
263
|
-
`Out-of-order mDM message (expected ratchet index ${step.messageIndex}, got ${env.i}). Skipped-key handling is a tracked follow-up (LINEAR-2357).`
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
const plaintext = await decryptBytes(step.messageKey, env.ct);
|
|
267
|
-
await keystore.putSession(peerId, session);
|
|
268
|
-
return plaintext;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// src/tools/mdm.ts
|
|
272
|
-
var PROTOCOL_VERSION = "mosadd.chat.v1";
|
|
273
|
-
var ContactRef = z.string().min(1).describe(
|
|
274
|
-
"Recipient identity id (UUID). Use mDM_list_contacts first to find the right id. Future versions will accept handle/email/phone directly."
|
|
275
|
-
);
|
|
276
|
-
var ThreadSuffix = z.string().min(1).max(120).regex(/^[a-zA-Z0-9._-]+$/).describe(
|
|
277
|
-
"Optional thread label within the conversation with this contact. Defaults to the contact's main thread. mosadd USP: multiple threads per contact."
|
|
278
|
-
);
|
|
279
|
-
var mDM_send_input = z.object({
|
|
280
|
-
to: ContactRef,
|
|
281
|
-
text: z.string().min(1).max(64e3).describe("Message body (UTF-8). Max 64 KB."),
|
|
282
|
-
thread_label: ThreadSuffix.optional().describe(
|
|
283
|
-
"Optional thread label. If omitted, uses the default thread for this contact."
|
|
284
|
-
),
|
|
285
|
-
reply_to_id: z.string().optional().describe("Optional id of the message being replied to.")
|
|
286
|
-
});
|
|
287
|
-
var mDM_list_input = z.object({
|
|
288
|
-
contact_id: ContactRef.describe("Identity id of the contact to read messages with."),
|
|
289
|
-
thread_label: ThreadSuffix.optional(),
|
|
290
|
-
limit: z.number().int().min(1).max(200).default(50).optional(),
|
|
291
|
-
cursor: z.string().optional().describe("Opaque pagination cursor from a previous response.")
|
|
292
|
-
});
|
|
293
|
-
var mDM_list_contacts_input = z.object({
|
|
294
|
-
limit: z.number().int().min(1).max(500).default(100).optional()
|
|
295
|
-
});
|
|
296
|
-
var mDM_respond_request_input = z.object({
|
|
297
|
-
request_id: z.string().min(1),
|
|
298
|
-
action: z.enum(["accept", "reject"])
|
|
299
|
-
});
|
|
300
|
-
function dmThreadId(selfId, otherId, label) {
|
|
301
|
-
const [a, b] = [selfId, otherId].sort();
|
|
302
|
-
return label ? `dm:${a}:${b}:${label}` : `dm:${a}:${b}`;
|
|
303
|
-
}
|
|
304
|
-
async function resolveSelfIdentityId() {
|
|
305
|
-
const sb = getSupabase();
|
|
306
|
-
const { data: u, error: ue } = await sb.auth.getUser();
|
|
307
|
-
if (ue || !u?.user) {
|
|
308
|
-
throw new Error(
|
|
309
|
-
"Unable to resolve current user. Ensure MOSADD_USER_JWT is set to a valid Supabase session token."
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
const { data: identity, error } = await sb.from("identities").select("id").eq("user_id", u.user.id).maybeSingle();
|
|
313
|
-
if (error || !identity) {
|
|
314
|
-
throw new Error("Current user has no mosadd identity row. Sign in to mosadd.com first.");
|
|
315
|
-
}
|
|
316
|
-
return identity.id;
|
|
317
|
-
}
|
|
318
|
-
function packPlaintextPayload(text, replyToId) {
|
|
319
|
-
const envelope = {
|
|
320
|
-
v: PROTOCOL_VERSION,
|
|
321
|
-
type: "text",
|
|
322
|
-
text,
|
|
323
|
-
reply_to: replyToId ?? null,
|
|
324
|
-
sent_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
325
|
-
};
|
|
326
|
-
return new Uint8Array(Buffer.from(JSON.stringify(envelope), "utf8"));
|
|
327
|
-
}
|
|
328
|
-
function unpackPayload(payload) {
|
|
329
|
-
try {
|
|
330
|
-
const json = Buffer.from(payload).toString("utf8");
|
|
331
|
-
const obj = JSON.parse(json);
|
|
332
|
-
if (typeof obj?.text === "string") return obj;
|
|
333
|
-
} catch {
|
|
334
|
-
}
|
|
335
|
-
return { text: "<ciphertext>" };
|
|
336
|
-
}
|
|
337
|
-
async function mDM_send(input, ctx) {
|
|
338
|
-
const dm = ctx.providers.dm;
|
|
339
|
-
const selfId = await dm.selfId();
|
|
340
|
-
const threadId = dmThreadId(selfId, input.to, input.thread_label);
|
|
341
|
-
const inner = packPlaintextPayload(input.text, input.reply_to_id);
|
|
342
|
-
const sealed = await encryptForPeer(ctx.providers.keys, dm, input.to, inner);
|
|
343
|
-
ctx.log("debug", "mDM_send E2EE via DmProvider", { thread_id: threadId, bytes: sealed.byteLength });
|
|
344
|
-
const result = await dm.send({
|
|
345
|
-
to: input.to,
|
|
346
|
-
threadId,
|
|
347
|
-
payload: sealed,
|
|
348
|
-
replyToId: input.reply_to_id
|
|
349
|
-
});
|
|
350
|
-
return {
|
|
351
|
-
message_id: result.id,
|
|
352
|
-
delivered_at: result.deliveredAt,
|
|
353
|
-
thread_id: threadId,
|
|
354
|
-
encrypted: true
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
async function mDM_send_unencrypted(input, ctx) {
|
|
358
|
-
const dm = ctx.providers.dm;
|
|
359
|
-
const selfId = await dm.selfId();
|
|
360
|
-
const threadId = dmThreadId(selfId, input.to, input.thread_label);
|
|
361
|
-
const payload = packPlaintextPayload(input.text, input.reply_to_id);
|
|
362
|
-
ctx.log("warn", "mDM_send_unencrypted (deprecated, plaintext) via DmProvider", {
|
|
363
|
-
thread_id: threadId,
|
|
364
|
-
bytes: payload.byteLength
|
|
365
|
-
});
|
|
366
|
-
const result = await dm.send({
|
|
367
|
-
to: input.to,
|
|
368
|
-
threadId,
|
|
369
|
-
payload,
|
|
370
|
-
replyToId: input.reply_to_id
|
|
371
|
-
});
|
|
372
|
-
return {
|
|
373
|
-
message_id: result.id,
|
|
374
|
-
delivered_at: result.deliveredAt,
|
|
375
|
-
thread_id: threadId,
|
|
376
|
-
encrypted: false
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
async function mDM_publish_keys(_input, ctx) {
|
|
380
|
-
const { oneTimePrekeyCount } = await publishOwnPrekeys(ctx.providers.keys, ctx.providers.dm);
|
|
381
|
-
ctx.log("debug", "mDM_publish_keys", { one_time_prekeys: oneTimePrekeyCount });
|
|
382
|
-
return { published: true, one_time_prekeys: oneTimePrekeyCount };
|
|
383
|
-
}
|
|
384
|
-
async function mDM_list(input, ctx) {
|
|
385
|
-
const dm = ctx.providers.dm;
|
|
386
|
-
const selfId = await dm.selfId();
|
|
387
|
-
const threadId = dmThreadId(selfId, input.contact_id, input.thread_label);
|
|
388
|
-
ctx.log("debug", "mDM_list via DmProvider", { thread_id: threadId });
|
|
389
|
-
const result = await dm.list({ threadId, limit: input.limit ?? 50, cursor: input.cursor });
|
|
390
|
-
const messages = await Promise.all(
|
|
391
|
-
result.messages.map(async (m) => {
|
|
392
|
-
const base = {
|
|
393
|
-
id: m.id,
|
|
394
|
-
sender_identity_id: m.senderId,
|
|
395
|
-
timestamp: m.timestamp,
|
|
396
|
-
thread_id: m.threadId
|
|
397
|
-
};
|
|
398
|
-
if (!isE2eeEnvelope(m.payload)) {
|
|
399
|
-
return { ...base, text: unpackPayload(m.payload).text, encrypted: false };
|
|
400
|
-
}
|
|
401
|
-
if (m.senderId === selfId) {
|
|
402
|
-
return { ...base, text: "<encrypted \xB7 sent by you>", encrypted: true };
|
|
403
|
-
}
|
|
404
|
-
try {
|
|
405
|
-
const inner = await decryptFromPeer(ctx.providers.keys, m.senderId, m.payload);
|
|
406
|
-
return { ...base, text: unpackPayload(inner).text, encrypted: true };
|
|
407
|
-
} catch (err) {
|
|
408
|
-
ctx.log("warn", "mDM_list failed to decrypt a message", { id: m.id, error: String(err) });
|
|
409
|
-
return { ...base, text: "<undecryptable>", encrypted: true };
|
|
410
|
-
}
|
|
411
|
-
})
|
|
412
|
-
);
|
|
413
|
-
return {
|
|
414
|
-
messages,
|
|
415
|
-
next_cursor: result.nextCursor,
|
|
416
|
-
threads: [threadId]
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
async function mDM_list_contacts(input, ctx) {
|
|
420
|
-
readSupabaseEnv();
|
|
421
|
-
const selfId = await resolveSelfIdentityId();
|
|
422
|
-
const sb = getSupabase();
|
|
423
|
-
ctx.log("debug", "mDM_list_contacts querying contacts table", { selfId });
|
|
424
|
-
const { data, error } = await sb.from("contacts").select("contact_identity_id, state, identities:contact_identity_id(account_id, display_name)").eq("owner_identity_id", selfId).limit(input.limit ?? 100);
|
|
425
|
-
if (error) {
|
|
426
|
-
throw new Error(`Failed to list contacts: ${error.message}`);
|
|
427
|
-
}
|
|
428
|
-
const contacts = data.map((r) => ({
|
|
429
|
-
identity_id: r.contact_identity_id,
|
|
430
|
-
account_id: r.identities?.account_id ?? null,
|
|
431
|
-
display_name: r.identities?.display_name ?? null,
|
|
432
|
-
state: r.state
|
|
433
|
-
}));
|
|
434
|
-
return { contacts };
|
|
435
|
-
}
|
|
436
|
-
async function mDM_respond_request(input, ctx) {
|
|
437
|
-
readSupabaseEnv();
|
|
438
|
-
ctx.log("debug", "mDM_respond_request invoking message-request-respond", input);
|
|
439
|
-
await invokeFunction("message-request-respond", {
|
|
440
|
-
request_id: input.request_id,
|
|
441
|
-
action: input.action
|
|
442
|
-
});
|
|
443
|
-
return { ok: true };
|
|
444
|
-
}
|
|
445
|
-
var mDM_publish_keys_input = z.object({});
|
|
446
|
-
var mdmTools = [
|
|
447
|
-
{
|
|
448
|
-
name: "mDM_list_contacts",
|
|
449
|
-
requires: "any",
|
|
450
|
-
description: "List the user's mosadd contacts. Returns identity_id (use this for mDM_send / mDM_list), account handle, display name, and contact state (pending, accepted, blocked).",
|
|
451
|
-
inputSchema: mDM_list_contacts_input,
|
|
452
|
-
handler: mDM_list_contacts
|
|
453
|
-
},
|
|
454
|
-
{
|
|
455
|
-
name: "mDM_publish_keys",
|
|
456
|
-
requires: "any",
|
|
457
|
-
description: "Publish your mDM prekey bundle so other people can start an end-to-end-encrypted conversation with you. Run this once after sign-in (and to replenish one-time prekeys). Rides the same transport as messages, so it works over network or off-grid radio.",
|
|
458
|
-
inputSchema: mDM_publish_keys_input,
|
|
459
|
-
handler: mDM_publish_keys
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
name: "mDM_send",
|
|
463
|
-
requires: "any",
|
|
464
|
-
description: "Send an END-TO-END-ENCRYPTED direct message via mosadd mDM. Pass `to` as the recipient's mosadd identity_id (look it up with mDM_list_contacts). Establishes an X3DH + Double Ratchet session on first contact (the recipient must have run mDM_publish_keys). Optional thread_label puts the message in a named thread \u2014 mosadd USP: multiple threads per contact, unlike WhatsApp/Telegram. If the recipient has no published keys yet, use mDM_send_unencrypted.",
|
|
465
|
-
inputSchema: mDM_send_input,
|
|
466
|
-
handler: mDM_send
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
name: "mDM_send_unencrypted",
|
|
470
|
-
requires: "any",
|
|
471
|
-
description: "DEPRECATED migration-window fallback: send a direct message WITHOUT end-to-end encryption (plaintext envelope). Only use when the recipient has not yet published prekeys (mDM_send fails with that hint). Prefer mDM_send. Will be removed once E2EE is universal.",
|
|
472
|
-
inputSchema: mDM_send_input,
|
|
473
|
-
handler: mDM_send_unencrypted
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
name: "mDM_list",
|
|
477
|
-
requires: "any",
|
|
478
|
-
description: "List recent direct messages with a specific contact. Pass contact_id as the identity_id from mDM_list_contacts. Decrypts end-to-end-encrypted messages from the contact automatically; legacy plaintext messages are shown as-is. Optionally filter to a single thread_label.",
|
|
479
|
-
inputSchema: mDM_list_input,
|
|
480
|
-
handler: mDM_list
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
name: "mDM_respond_request",
|
|
484
|
-
requires: "any",
|
|
485
|
-
description: "Accept or reject an incoming DM request from a contact who is not yet in the user's whitelist.",
|
|
486
|
-
inputSchema: mDM_respond_request_input,
|
|
487
|
-
handler: mDM_respond_request
|
|
488
|
-
}
|
|
489
|
-
];
|
|
490
|
-
|
|
491
|
-
// src/tools/mirc.ts
|
|
492
|
-
import { z as z2 } from "zod";
|
|
493
|
-
var ChannelId = z2.string().min(1).max(120).describe("Channel id (UUID). Use mIRC_list to discover available channels.");
|
|
494
|
-
var AccessMode = z2.enum(["public", "private", "invite_only"]).describe("public: anyone joins \xB7 private: requires invite + password \xB7 invite_only: invite only.");
|
|
495
|
-
var Capabilities = z2.object({
|
|
496
|
-
txt: z2.boolean().default(true),
|
|
497
|
-
ptt: z2.boolean().default(false),
|
|
498
|
-
live: z2.boolean().default(false)
|
|
499
|
-
}).describe("Which modes are enabled in this channel: txt (text), ptt (push-to-talk voice), live (live stream).").optional();
|
|
500
|
-
var mIRC_create_input = z2.object({
|
|
501
|
-
name: z2.string().min(1).max(80).describe("Channel display name."),
|
|
502
|
-
topic: z2.string().max(500).optional().describe("Optional channel topic/description."),
|
|
503
|
-
access_mode: AccessMode.default("public"),
|
|
504
|
-
password: z2.string().min(6).max(120).optional().describe("Password (only for access_mode=private)."),
|
|
505
|
-
capabilities: Capabilities
|
|
506
|
-
});
|
|
507
|
-
var mIRC_list_input = z2.object({
|
|
508
|
-
limit: z2.number().int().min(1).max(500).default(100).optional(),
|
|
509
|
-
offset: z2.number().int().min(0).default(0).optional(),
|
|
510
|
-
access_mode: AccessMode.optional().describe("Filter to a single access mode.")
|
|
511
|
-
});
|
|
512
|
-
var mIRC_get_input = z2.object({
|
|
513
|
-
channel_id: ChannelId
|
|
514
|
-
});
|
|
515
|
-
var mIRC_update_input = z2.object({
|
|
516
|
-
channel_id: ChannelId,
|
|
517
|
-
name: z2.string().min(1).max(80).optional(),
|
|
518
|
-
topic: z2.string().max(500).optional(),
|
|
519
|
-
access_mode: AccessMode.optional(),
|
|
520
|
-
capabilities: Capabilities
|
|
521
|
-
});
|
|
522
|
-
var mIRC_delete_input = z2.object({
|
|
523
|
-
channel_id: ChannelId
|
|
524
|
-
});
|
|
525
|
-
async function mIRC_create(input, ctx) {
|
|
526
|
-
readSupabaseEnv();
|
|
527
|
-
ctx.log("debug", "mIRC_create invoking channel-manage", { name: input.name });
|
|
528
|
-
return await invokeFunction("channel-manage", {
|
|
529
|
-
action: "create",
|
|
530
|
-
...input
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
async function mIRC_list(input, ctx) {
|
|
534
|
-
readSupabaseEnv();
|
|
535
|
-
ctx.log("debug", "mIRC_list invoking channel-manage");
|
|
536
|
-
return await invokeFunction("channel-manage", {
|
|
537
|
-
action: "list",
|
|
538
|
-
...input
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
async function mIRC_get(input, ctx) {
|
|
542
|
-
readSupabaseEnv();
|
|
543
|
-
ctx.log("debug", "mIRC_get invoking channel-manage", { channel_id: input.channel_id });
|
|
544
|
-
return await invokeFunction("channel-manage", {
|
|
545
|
-
action: "get",
|
|
546
|
-
channel_id: input.channel_id
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
async function mIRC_update(input, ctx) {
|
|
550
|
-
readSupabaseEnv();
|
|
551
|
-
ctx.log("debug", "mIRC_update invoking channel-manage", { channel_id: input.channel_id });
|
|
552
|
-
return await invokeFunction("channel-manage", {
|
|
553
|
-
action: "update",
|
|
554
|
-
...input
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
async function mIRC_delete(input, ctx) {
|
|
558
|
-
readSupabaseEnv();
|
|
559
|
-
ctx.log("debug", "mIRC_delete invoking channel-manage", { channel_id: input.channel_id });
|
|
560
|
-
await invokeFunction("channel-manage", {
|
|
561
|
-
action: "delete",
|
|
562
|
-
channel_id: input.channel_id
|
|
563
|
-
});
|
|
564
|
-
return { deleted: true };
|
|
565
|
-
}
|
|
566
|
-
var mircTools = [
|
|
567
|
-
{
|
|
568
|
-
name: "mIRC_create",
|
|
569
|
-
requires: "network",
|
|
570
|
-
description: "Create a new persistent channel (Discord/Slack-style). Set access_mode to public for open join, private for password-gated, invite_only for explicit invites. capabilities controls modes (txt/ptt/live).",
|
|
571
|
-
inputSchema: mIRC_create_input,
|
|
572
|
-
handler: mIRC_create
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
name: "mIRC_list",
|
|
576
|
-
requires: "network",
|
|
577
|
-
description: "List channels available to the current user. Optionally filter by access_mode.",
|
|
578
|
-
inputSchema: mIRC_list_input,
|
|
579
|
-
handler: mIRC_list
|
|
580
|
-
},
|
|
581
|
-
{
|
|
582
|
-
name: "mIRC_get",
|
|
583
|
-
requires: "network",
|
|
584
|
-
description: "Get full details of a single channel by id.",
|
|
585
|
-
inputSchema: mIRC_get_input,
|
|
586
|
-
handler: mIRC_get
|
|
587
|
-
},
|
|
588
|
-
{
|
|
589
|
-
name: "mIRC_update",
|
|
590
|
-
requires: "network",
|
|
591
|
-
description: "Update channel metadata (name, topic, access_mode, capabilities). Owner only.",
|
|
592
|
-
inputSchema: mIRC_update_input,
|
|
593
|
-
handler: mIRC_update
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
name: "mIRC_delete",
|
|
597
|
-
requires: "network",
|
|
598
|
-
description: "Delete a channel and cascade-remove its members. Owner only.",
|
|
599
|
-
inputSchema: mIRC_delete_input,
|
|
600
|
-
handler: mIRC_delete
|
|
601
|
-
}
|
|
602
|
-
];
|
|
603
|
-
|
|
604
|
-
// src/tools/mirc-members.ts
|
|
605
|
-
import { z as z3 } from "zod";
|
|
606
|
-
var ChannelId2 = z3.string().min(1).max(120).describe("Channel id (UUID). From mIRC_list / mIRC_create.");
|
|
607
|
-
var MemberIdentity = z3.string().min(1).describe("Target user's identity id (UUID). From mDM_list_contacts or radar logs.");
|
|
608
|
-
var Role = z3.enum(["owner", "admin", "moderator", "member", "guest"]).describe("Member role within the channel.");
|
|
609
|
-
var mIRC_join_input = z3.object({
|
|
610
|
-
channel_id: ChannelId2,
|
|
611
|
-
password: z3.string().min(1).optional().describe("Required if the channel is access_mode=private.")
|
|
612
|
-
});
|
|
613
|
-
var mIRC_request_access_input = z3.object({
|
|
614
|
-
channel_id: ChannelId2,
|
|
615
|
-
message: z3.string().max(500).optional().describe("Optional note for the channel owner explaining why.")
|
|
616
|
-
});
|
|
617
|
-
var mIRC_leave_input = z3.object({
|
|
618
|
-
channel_id: ChannelId2
|
|
619
|
-
});
|
|
620
|
-
var mIRC_approve_request_input = z3.object({
|
|
621
|
-
channel_id: ChannelId2,
|
|
622
|
-
request_id: z3.string().min(1).describe("Pending request id.")
|
|
623
|
-
});
|
|
624
|
-
var mIRC_reject_request_input = mIRC_approve_request_input;
|
|
625
|
-
var mIRC_kick_input = z3.object({
|
|
626
|
-
channel_id: ChannelId2,
|
|
627
|
-
identity_id: MemberIdentity,
|
|
628
|
-
reason: z3.string().max(500).optional()
|
|
629
|
-
});
|
|
630
|
-
var mIRC_ban_input = z3.object({
|
|
631
|
-
channel_id: ChannelId2,
|
|
632
|
-
identity_id: MemberIdentity,
|
|
633
|
-
reason: z3.string().max(500).optional(),
|
|
634
|
-
/** Optional unban deadline (ISO-8601). Omit for permanent ban. */
|
|
635
|
-
until: z3.string().optional()
|
|
636
|
-
});
|
|
637
|
-
var mIRC_unban_input = z3.object({
|
|
638
|
-
channel_id: ChannelId2,
|
|
639
|
-
identity_id: MemberIdentity
|
|
640
|
-
});
|
|
641
|
-
var mIRC_set_role_input = z3.object({
|
|
642
|
-
channel_id: ChannelId2,
|
|
643
|
-
identity_id: MemberIdentity,
|
|
644
|
-
role: Role
|
|
645
|
-
});
|
|
646
|
-
var mIRC_set_ptt_input = z3.object({
|
|
647
|
-
channel_id: ChannelId2,
|
|
648
|
-
identity_id: MemberIdentity,
|
|
649
|
-
ptt_enabled: z3.boolean().describe("Allow this member to hold the PTT floor in voice mode.")
|
|
650
|
-
});
|
|
651
|
-
async function invokeChannelMembers(action, body, ctx) {
|
|
652
|
-
readSupabaseEnv();
|
|
653
|
-
ctx.log("debug", `mIRC.${action}`, body);
|
|
654
|
-
return await invokeFunction("channel-members-manage", { action, ...body });
|
|
655
|
-
}
|
|
656
|
-
var mircMembersTools = [
|
|
657
|
-
{
|
|
658
|
-
name: "mIRC_join",
|
|
659
|
-
requires: "network",
|
|
660
|
-
description: "Join a channel as the current user. For private channels pass `password`. Returns a membership row or 409 if already a member.",
|
|
661
|
-
inputSchema: mIRC_join_input,
|
|
662
|
-
handler: ((input, ctx) => invokeChannelMembers("join", input, ctx))
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
name: "mIRC_request_access",
|
|
666
|
-
requires: "network",
|
|
667
|
-
description: "Request access to an invite_only channel. Owner / admins get a notification with the optional message.",
|
|
668
|
-
inputSchema: mIRC_request_access_input,
|
|
669
|
-
handler: ((input, ctx) => invokeChannelMembers("request-access", input, ctx))
|
|
670
|
-
},
|
|
671
|
-
{
|
|
672
|
-
name: "mIRC_leave",
|
|
673
|
-
requires: "network",
|
|
674
|
-
description: "Leave a channel as the current user. Owner cannot leave without transferring ownership first.",
|
|
675
|
-
inputSchema: mIRC_leave_input,
|
|
676
|
-
handler: ((input, ctx) => invokeChannelMembers("leave", input, ctx))
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
name: "mIRC_approve_request",
|
|
680
|
-
requires: "network",
|
|
681
|
-
description: "Approve a pending access request. Admins / moderators / owner only.",
|
|
682
|
-
inputSchema: mIRC_approve_request_input,
|
|
683
|
-
handler: ((input, ctx) => invokeChannelMembers("approve-request", input, ctx))
|
|
684
|
-
},
|
|
685
|
-
{
|
|
686
|
-
name: "mIRC_reject_request",
|
|
687
|
-
requires: "network",
|
|
688
|
-
description: "Reject a pending access request. Admins / moderators / owner only.",
|
|
689
|
-
inputSchema: mIRC_reject_request_input,
|
|
690
|
-
handler: ((input, ctx) => invokeChannelMembers("reject-request", input, ctx))
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
name: "mIRC_kick",
|
|
694
|
-
requires: "network",
|
|
695
|
-
description: "Remove a member from the channel. They can rejoin if not banned. Requires moderator+. `reason` is logged to channel-event-log.",
|
|
696
|
-
inputSchema: mIRC_kick_input,
|
|
697
|
-
handler: ((input, ctx) => invokeChannelMembers("kick", input, ctx))
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
name: "mIRC_ban",
|
|
701
|
-
requires: "network",
|
|
702
|
-
description: "Ban a member from the channel. They cannot rejoin until unbanned. `until` (ISO-8601) for time-bound ban; omit for permanent. Requires admin+.",
|
|
703
|
-
inputSchema: mIRC_ban_input,
|
|
704
|
-
handler: ((input, ctx) => invokeChannelMembers("ban", input, ctx))
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
name: "mIRC_unban",
|
|
708
|
-
requires: "network",
|
|
709
|
-
description: "Lift a ban. Requires admin+.",
|
|
710
|
-
inputSchema: mIRC_unban_input,
|
|
711
|
-
handler: ((input, ctx) => invokeChannelMembers("unban", input, ctx))
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
name: "mIRC_set_role",
|
|
715
|
-
requires: "network",
|
|
716
|
-
description: "Promote / demote a member. Roles: owner > admin > moderator > member > guest. Only owner can promote to admin; only admin+ can promote to moderator.",
|
|
717
|
-
inputSchema: mIRC_set_role_input,
|
|
718
|
-
handler: ((input, ctx) => invokeChannelMembers("set-role", input, ctx))
|
|
719
|
-
},
|
|
720
|
-
{
|
|
721
|
-
name: "mIRC_set_ptt",
|
|
722
|
-
requires: "network",
|
|
723
|
-
description: "Grant or revoke PTT floor permission for a member in voice-capable channels (capabilities.ptt=true). Requires moderator+.",
|
|
724
|
-
inputSchema: mIRC_set_ptt_input,
|
|
725
|
-
handler: ((input, ctx) => invokeChannelMembers("set-ptt", input, ctx))
|
|
726
|
-
}
|
|
727
|
-
];
|
|
728
|
-
|
|
729
|
-
// src/tools/mroom.ts
|
|
730
|
-
import { z as z4 } from "zod";
|
|
731
|
-
var RoomId = z4.string().min(1).describe("Private room id (UUID).");
|
|
732
|
-
var mROOM_create_input = z4.object({
|
|
733
|
-
ttl_seconds: z4.number().int().min(60).max(86400 * 30).default(86400).optional().describe("Time-to-live in seconds. Defaults to 24 h. Max 30 days.")
|
|
734
|
-
});
|
|
735
|
-
var mROOM_join_input = z4.object({
|
|
736
|
-
room_id: RoomId
|
|
737
|
-
});
|
|
738
|
-
var mROOM_close_input = z4.object({
|
|
739
|
-
room_id: RoomId
|
|
740
|
-
});
|
|
741
|
-
var mROOM_leave_input = z4.object({
|
|
742
|
-
room_id: RoomId
|
|
743
|
-
});
|
|
744
|
-
var mROOM_list_input = z4.object({});
|
|
745
|
-
var mROOM_create_guest_link_input = z4.object({
|
|
746
|
-
room_id: RoomId,
|
|
747
|
-
display_name: z4.string().min(1).max(80).describe("Display name the guest will appear under. They never sign up \u2014 this is the only identifier."),
|
|
748
|
-
ttl_seconds: z4.number().int().min(60).max(86400 * 7).default(3600).optional().describe("How long the guest token is valid. Default 1 h, max 7 days.")
|
|
749
|
-
});
|
|
750
|
-
async function mROOM_create(input, ctx) {
|
|
751
|
-
readSupabaseEnv();
|
|
752
|
-
const expires_at = new Date(Date.now() + (input.ttl_seconds ?? 86400) * 1e3).toISOString();
|
|
753
|
-
ctx.log("debug", "mROOM_create invoking privroom-manage", { expires_at });
|
|
754
|
-
return await invokeFunction("privroom-manage", {
|
|
755
|
-
action: "create",
|
|
756
|
-
expires_at
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
async function mROOM_join(input, ctx) {
|
|
760
|
-
readSupabaseEnv();
|
|
761
|
-
ctx.log("debug", "mROOM_join invoking privroom-manage", { room_id: input.room_id });
|
|
762
|
-
return await invokeFunction("privroom-manage", {
|
|
763
|
-
action: "join",
|
|
764
|
-
room_id: input.room_id
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
async function mROOM_close(input, ctx) {
|
|
768
|
-
readSupabaseEnv();
|
|
769
|
-
ctx.log("debug", "mROOM_close invoking privroom-manage", { room_id: input.room_id });
|
|
770
|
-
return await invokeFunction("privroom-manage", {
|
|
771
|
-
action: "close",
|
|
772
|
-
room_id: input.room_id
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
async function mROOM_leave(input, ctx) {
|
|
776
|
-
readSupabaseEnv();
|
|
777
|
-
ctx.log("debug", "mROOM_leave invoking privroom-manage", { room_id: input.room_id });
|
|
778
|
-
return await invokeFunction("privroom-manage", {
|
|
779
|
-
action: "leave",
|
|
780
|
-
room_id: input.room_id
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
async function mROOM_list(_input, ctx) {
|
|
784
|
-
readSupabaseEnv();
|
|
785
|
-
ctx.log("debug", "mROOM_list invoking privroom-manage");
|
|
786
|
-
return await invokeFunction("privroom-manage", { action: "list" });
|
|
787
|
-
}
|
|
788
|
-
async function mROOM_create_guest_link(input, ctx) {
|
|
789
|
-
readSupabaseEnv();
|
|
790
|
-
ctx.log("debug", "mROOM_create_guest_link invoking privroom-guest-token", {
|
|
791
|
-
room_id: input.room_id
|
|
792
|
-
});
|
|
793
|
-
const result = await invokeFunction("privroom-guest-token", {
|
|
794
|
-
room_id: input.room_id,
|
|
795
|
-
display_name: input.display_name,
|
|
796
|
-
ttl_seconds: input.ttl_seconds ?? 3600
|
|
797
|
-
});
|
|
798
|
-
return {
|
|
799
|
-
token: result.token,
|
|
800
|
-
join_url: `https://mosadd.com/r/${input.room_id}?t=${result.token}`,
|
|
801
|
-
expires_at: result.expires_at
|
|
802
|
-
};
|
|
803
|
-
}
|
|
804
|
-
var mroomTools = [
|
|
805
|
-
{
|
|
806
|
-
name: "mROOM_create",
|
|
807
|
-
requires: "network",
|
|
808
|
-
description: "Create an ephemeral private room. Auto-joins the creator. Defaults to 24 h TTL \u2014 pass ttl_seconds to override.",
|
|
809
|
-
inputSchema: mROOM_create_input,
|
|
810
|
-
handler: mROOM_create
|
|
811
|
-
},
|
|
812
|
-
{
|
|
813
|
-
name: "mROOM_create_guest_link",
|
|
814
|
-
requires: "network",
|
|
815
|
-
description: "USP: Generate a short-lived join link that lets a person enter the room WITHOUT a mosadd account. Returns { token, join_url, expires_at }. Share the join_url out-of-band (email, SMS, QR). Use case: support call, live-stream after-party, anonymous tipline.",
|
|
816
|
-
inputSchema: mROOM_create_guest_link_input,
|
|
817
|
-
handler: mROOM_create_guest_link
|
|
818
|
-
},
|
|
819
|
-
{
|
|
820
|
-
name: "mROOM_join",
|
|
821
|
-
requires: "network",
|
|
822
|
-
description: "Join an existing private room (current user, not a guest).",
|
|
823
|
-
inputSchema: mROOM_join_input,
|
|
824
|
-
handler: mROOM_join
|
|
825
|
-
},
|
|
826
|
-
{
|
|
827
|
-
name: "mROOM_leave",
|
|
828
|
-
requires: "network",
|
|
829
|
-
description: "Leave a private room.",
|
|
830
|
-
inputSchema: mROOM_leave_input,
|
|
831
|
-
handler: mROOM_leave
|
|
832
|
-
},
|
|
833
|
-
{
|
|
834
|
-
name: "mROOM_close",
|
|
835
|
-
requires: "network",
|
|
836
|
-
description: "Close a private room and remove all members. Founder only.",
|
|
837
|
-
inputSchema: mROOM_close_input,
|
|
838
|
-
handler: mROOM_close
|
|
839
|
-
},
|
|
840
|
-
{
|
|
841
|
-
name: "mROOM_list",
|
|
842
|
-
requires: "network",
|
|
843
|
-
description: "List private rooms the current user belongs to.",
|
|
844
|
-
inputSchema: mROOM_list_input,
|
|
845
|
-
handler: mROOM_list
|
|
846
|
-
}
|
|
847
|
-
];
|
|
848
|
-
|
|
849
|
-
// src/tools/mroom-messages.ts
|
|
850
|
-
import { z as z5 } from "zod";
|
|
851
|
-
var PROTOCOL_VERSION2 = "mosadd.chat.v1";
|
|
852
|
-
var RoomId2 = z5.string().min(1).describe("Private room id (UUID). From mROOM_create / mROOM_list.");
|
|
853
|
-
var mROOM_send_message_input = z5.object({
|
|
854
|
-
room_id: RoomId2,
|
|
855
|
-
text: z5.string().min(1).max(64e3).describe("Message body (UTF-8). Max 64 KB."),
|
|
856
|
-
reply_to_id: z5.string().optional().describe("Optional id of the message being replied to.")
|
|
857
|
-
});
|
|
858
|
-
var mROOM_list_messages_input = z5.object({
|
|
859
|
-
room_id: RoomId2,
|
|
860
|
-
limit: z5.number().int().min(1).max(200).default(50).optional(),
|
|
861
|
-
cursor: z5.string().optional().describe("Opaque pagination cursor from a prior list response.")
|
|
862
|
-
});
|
|
863
|
-
function packPlaintextPayload2(text, replyToId) {
|
|
864
|
-
const envelope = {
|
|
865
|
-
v: PROTOCOL_VERSION2,
|
|
866
|
-
type: "text",
|
|
867
|
-
text,
|
|
868
|
-
reply_to: replyToId ?? null,
|
|
869
|
-
sent_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
870
|
-
};
|
|
871
|
-
return Buffer.from(JSON.stringify(envelope), "utf8").toString("base64");
|
|
872
|
-
}
|
|
873
|
-
function unpackPayload2(payload) {
|
|
874
|
-
try {
|
|
875
|
-
const json = Buffer.from(payload, "base64").toString("utf8");
|
|
876
|
-
const obj = JSON.parse(json);
|
|
877
|
-
if (typeof obj?.text === "string") return obj;
|
|
878
|
-
} catch {
|
|
879
|
-
}
|
|
880
|
-
return { text: "<ciphertext>" };
|
|
881
|
-
}
|
|
882
|
-
async function mROOM_send_message(input, ctx) {
|
|
883
|
-
readSupabaseEnv();
|
|
884
|
-
const thread_id = `privroom:${input.room_id}`;
|
|
885
|
-
ctx.log("debug", "mROOM_send_message", { thread_id });
|
|
886
|
-
const data = await invokeFunction(
|
|
887
|
-
"message-send",
|
|
888
|
-
{
|
|
889
|
-
space_id: "rooms",
|
|
890
|
-
thread_id,
|
|
891
|
-
encrypted_payload: packPlaintextPayload2(input.text, input.reply_to_id),
|
|
892
|
-
message_type: "text",
|
|
893
|
-
protocol_version: PROTOCOL_VERSION2,
|
|
894
|
-
reply_to_id: input.reply_to_id ?? null
|
|
895
|
-
}
|
|
896
|
-
);
|
|
897
|
-
if (!data?.message?.id) {
|
|
898
|
-
throw new Error("message-send returned no message id");
|
|
899
|
-
}
|
|
900
|
-
return {
|
|
901
|
-
message_id: data.message.id,
|
|
902
|
-
delivered_at: data.message.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
903
|
-
thread_id
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
async function mROOM_list_messages(input, ctx) {
|
|
907
|
-
readSupabaseEnv();
|
|
908
|
-
const thread_id = `privroom:${input.room_id}`;
|
|
909
|
-
ctx.log("debug", "mROOM_list_messages", { thread_id });
|
|
910
|
-
const data = await invokeFunction("message-list", {
|
|
911
|
-
space_id: "rooms",
|
|
912
|
-
thread_id,
|
|
913
|
-
limit: input.limit ?? 50,
|
|
914
|
-
cursor: input.cursor
|
|
915
|
-
});
|
|
916
|
-
return {
|
|
917
|
-
messages: (data?.messages ?? []).map((m) => ({
|
|
918
|
-
id: m.id,
|
|
919
|
-
sender_identity_id: m.sender_identity_id,
|
|
920
|
-
text: unpackPayload2(m.encrypted_payload).text,
|
|
921
|
-
timestamp: m.created_at
|
|
922
|
-
})),
|
|
923
|
-
next_cursor: data?.next_cursor ?? null
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
var mroomMessagesTools = [
|
|
927
|
-
{
|
|
928
|
-
name: "mROOM_send_message",
|
|
929
|
-
requires: "network",
|
|
930
|
-
description: "Send a text message into a private room. Authorisation: must be a member (or guest with a valid token). Alpha payload is plaintext base64; v0.2 wraps with Double Ratchet.",
|
|
931
|
-
inputSchema: mROOM_send_message_input,
|
|
932
|
-
handler: mROOM_send_message
|
|
933
|
-
},
|
|
934
|
-
{
|
|
935
|
-
name: "mROOM_list_messages",
|
|
936
|
-
requires: "network",
|
|
937
|
-
description: "List recent text messages in a private room. Cursor-paginated, newest first.",
|
|
938
|
-
inputSchema: mROOM_list_messages_input,
|
|
939
|
-
handler: mROOM_list_messages
|
|
940
|
-
}
|
|
941
|
-
];
|
|
942
|
-
|
|
943
|
-
// src/tools/mail.ts
|
|
944
|
-
import { z as z6 } from "zod";
|
|
945
|
-
var EmailAddress = z6.string().email().max(254).describe("RFC 5321 email address.");
|
|
946
|
-
var MessageId = z6.string().min(1).describe("Message id (UUID) from mAIL_send or inbox.");
|
|
947
|
-
var mAIL_send_input = z6.object({
|
|
948
|
-
to: z6.union([EmailAddress, z6.array(EmailAddress).min(1).max(50)]).describe(
|
|
949
|
-
"Recipient(s). Single address or array of up to 50."
|
|
950
|
-
),
|
|
951
|
-
subject: z6.string().min(1).max(998).describe("Email subject line. Max 998 chars (RFC 5322)."),
|
|
952
|
-
body_text: z6.string().max(1048576).optional().describe("Plain text body. Max 1 MB."),
|
|
953
|
-
body_html: z6.string().max(1048576).optional().describe("HTML body. Max 1 MB."),
|
|
954
|
-
cc: z6.array(EmailAddress).max(50).optional(),
|
|
955
|
-
bcc: z6.array(EmailAddress).max(50).optional(),
|
|
956
|
-
reply_to: EmailAddress.optional()
|
|
957
|
-
});
|
|
958
|
-
var mAIL_view_input = z6.object({
|
|
959
|
-
message_id: MessageId
|
|
960
|
-
});
|
|
961
|
-
async function mAIL_send(input, ctx) {
|
|
962
|
-
readSupabaseEnv();
|
|
963
|
-
if (!input.body_text && !input.body_html) {
|
|
964
|
-
throw new Error("mAIL_send requires at least one of body_text or body_html.");
|
|
965
|
-
}
|
|
966
|
-
ctx.log("debug", "mAIL_send invoking mp0st-send", { to: input.to });
|
|
967
|
-
return await invokeFunction("mp0st-send", input);
|
|
968
|
-
}
|
|
969
|
-
async function mAIL_view(input, ctx) {
|
|
970
|
-
readSupabaseEnv();
|
|
971
|
-
ctx.log("debug", "mAIL_view invoking mp0st-view", { message_id: input.message_id });
|
|
972
|
-
return await invokeFunction("mp0st-view", { message_id: input.message_id });
|
|
973
|
-
}
|
|
974
|
-
var mailTools = [
|
|
975
|
-
{
|
|
976
|
-
name: "mAIL_send",
|
|
977
|
-
requires: "network",
|
|
978
|
-
description: "Send an email from the user's mosadd address (<userId>@mosadd.com). Pass body_text or body_html (or both). Supports cc, bcc, reply_to.",
|
|
979
|
-
inputSchema: mAIL_send_input,
|
|
980
|
-
handler: mAIL_send
|
|
981
|
-
},
|
|
982
|
-
{
|
|
983
|
-
name: "mAIL_view",
|
|
984
|
-
requires: "network",
|
|
985
|
-
description: "Read the full body and metadata of an email by message_id.",
|
|
986
|
-
inputSchema: mAIL_view_input,
|
|
987
|
-
handler: mAIL_view
|
|
988
|
-
}
|
|
989
|
-
];
|
|
990
|
-
|
|
991
|
-
// src/tools/capabilities.ts
|
|
992
|
-
import { z as z7 } from "zod";
|
|
993
|
-
var CONTRACT_VERSION = "1.0.0";
|
|
994
|
-
var ALL_REQUIREMENTS = ["any", "radio", "network"];
|
|
995
|
-
function buildCapabilityManifest(tools) {
|
|
996
|
-
const entries = tools.map((t) => ({ name: t.name, requires: t.requires }));
|
|
997
|
-
const by_requirement = {
|
|
998
|
-
any: [],
|
|
999
|
-
radio: [],
|
|
1000
|
-
network: []
|
|
1001
|
-
};
|
|
1002
|
-
for (const e of entries) by_requirement[e.requires].push(e.name);
|
|
1003
|
-
return {
|
|
1004
|
-
contract_version: CONTRACT_VERSION,
|
|
1005
|
-
requirements: ALL_REQUIREMENTS,
|
|
1006
|
-
tools: entries,
|
|
1007
|
-
by_requirement
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
function makeCapabilitiesTool(channelTools2) {
|
|
1011
|
-
const tool = {
|
|
1012
|
-
name: "comms_capabilities",
|
|
1013
|
-
requires: "any",
|
|
1014
|
-
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.",
|
|
1015
|
-
inputSchema: z7.object({}),
|
|
1016
|
-
handler: async () => buildCapabilityManifest([...channelTools2, tool])
|
|
1017
|
-
};
|
|
1018
|
-
return tool;
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
// src/tools/index.ts
|
|
1022
|
-
var channelTools = [
|
|
1023
|
-
...mdmTools,
|
|
1024
|
-
...mircTools,
|
|
1025
|
-
...mircMembersTools,
|
|
1026
|
-
...mroomTools,
|
|
1027
|
-
...mroomMessagesTools,
|
|
1028
|
-
...mailTools
|
|
1029
|
-
// mtalkTools, mcallTools, mirlTools,
|
|
1030
|
-
// mmatrixTools, mdiscordTools, mtelegramTools, mslackTools, msignalTools,
|
|
1031
|
-
//
|
|
1032
|
-
// Each m* module registers its tools here as it ships.
|
|
1033
|
-
// RFC required to add a new m* module (see docs/rfcs/0001-module-naming.md).
|
|
1034
|
-
];
|
|
1035
|
-
var allTools = [
|
|
1036
|
-
...channelTools,
|
|
1037
|
-
// comms_capabilities: one-call discovery of every tool's `requires` flag,
|
|
1038
|
-
// so carrier-aware hosts (cymru-os) can gate the tool list by transport.
|
|
1039
|
-
makeCapabilitiesTool(channelTools)
|
|
1040
|
-
];
|
|
1041
|
-
|
|
1042
|
-
// src/server.ts
|
|
1043
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1044
|
-
|
|
1045
|
-
// src/providers/supabase-dm.ts
|
|
1046
|
-
var PROTOCOL_VERSION3 = "mosadd.chat.v1";
|
|
1047
|
-
var SupabaseDmProvider = class {
|
|
1048
|
-
cachedSelfId = null;
|
|
1049
|
-
async selfId() {
|
|
1050
|
-
if (this.cachedSelfId) return this.cachedSelfId;
|
|
1051
|
-
readSupabaseEnv();
|
|
1052
|
-
const sb = getSupabase();
|
|
1053
|
-
const { data: u, error: ue } = await sb.auth.getUser();
|
|
1054
|
-
if (ue || !u?.user) {
|
|
1055
|
-
throw new Error(
|
|
1056
|
-
"Unable to resolve current user. Ensure MOSADD_USER_JWT is set to a valid Supabase session token."
|
|
1057
|
-
);
|
|
1058
|
-
}
|
|
1059
|
-
const { data: identity, error } = await sb.from("identities").select("id").eq("user_id", u.user.id).maybeSingle();
|
|
1060
|
-
if (error || !identity) {
|
|
1061
|
-
throw new Error("Current user has no mosadd identity row. Sign in to mosadd.com first.");
|
|
1062
|
-
}
|
|
1063
|
-
this.cachedSelfId = identity.id;
|
|
1064
|
-
return this.cachedSelfId;
|
|
1065
|
-
}
|
|
1066
|
-
async send(args) {
|
|
1067
|
-
const encrypted_payload = Buffer.from(args.payload).toString("base64");
|
|
1068
|
-
const data = await invokeFunction("message-send", {
|
|
1069
|
-
space_id: "dm",
|
|
1070
|
-
thread_id: args.threadId,
|
|
1071
|
-
encrypted_payload,
|
|
1072
|
-
message_type: "text",
|
|
1073
|
-
protocol_version: PROTOCOL_VERSION3,
|
|
1074
|
-
recipient_account_id: args.to,
|
|
1075
|
-
reply_to_id: args.replyToId ?? null
|
|
1076
|
-
});
|
|
1077
|
-
if (!data?.message?.id) {
|
|
1078
|
-
throw new Error("message-send returned no message id");
|
|
1079
|
-
}
|
|
1080
|
-
return {
|
|
1081
|
-
id: data.message.id,
|
|
1082
|
-
deliveredAt: data.message.created_at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
async publishPrekeyBundle(bundle) {
|
|
1086
|
-
await invokeFunction("prekey-bundle-publish", {
|
|
1087
|
-
bundle: Buffer.from(bundle).toString("base64")
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
async fetchPrekeyBundle(peerId) {
|
|
1091
|
-
const data = await invokeFunction("prekey-bundle-fetch", {
|
|
1092
|
-
peer_id: peerId
|
|
1093
|
-
});
|
|
1094
|
-
if (!data?.bundle) return null;
|
|
1095
|
-
return new Uint8Array(Buffer.from(data.bundle, "base64"));
|
|
1096
|
-
}
|
|
1097
|
-
async list(args) {
|
|
1098
|
-
const data = await invokeFunction("message-list", {
|
|
1099
|
-
space_id: "dm",
|
|
1100
|
-
thread_id: args.threadId,
|
|
1101
|
-
limit: args.limit ?? 50,
|
|
1102
|
-
cursor: args.cursor
|
|
1103
|
-
});
|
|
1104
|
-
return {
|
|
1105
|
-
messages: (data?.messages ?? []).map((m) => ({
|
|
1106
|
-
id: m.id,
|
|
1107
|
-
senderId: m.sender_identity_id,
|
|
1108
|
-
payload: new Uint8Array(Buffer.from(m.encrypted_payload, "base64")),
|
|
1109
|
-
timestamp: m.created_at,
|
|
1110
|
-
threadId: m.thread_id
|
|
1111
|
-
})),
|
|
1112
|
-
nextCursor: data?.next_cursor ?? null
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
|
|
1117
|
-
// src/server.ts
|
|
1118
|
-
function defaultProviders(injected) {
|
|
1119
|
-
return {
|
|
1120
|
-
dm: injected?.dm ?? new SupabaseDmProvider(),
|
|
1121
|
-
keys: injected?.keys ?? new InMemoryMdmKeyStore()
|
|
1122
|
-
};
|
|
1123
|
-
}
|
|
1124
|
-
function createMosaddServer(options = {}) {
|
|
1125
|
-
const mode = options.mode ?? (options.apiKey ? "cloud" : "local");
|
|
1126
|
-
const hubUrl = options.hubUrl ?? "https://mcp.mosadd.com";
|
|
1127
|
-
const logLevel = options.logLevel ?? "info";
|
|
1128
|
-
const providers = defaultProviders(options.providers);
|
|
1129
|
-
const ctx = {
|
|
1130
|
-
options: { ...options, mode, hubUrl },
|
|
1131
|
-
providers,
|
|
1132
|
-
log: (level, msg, extra) => {
|
|
1133
|
-
if (shouldLog(level, logLevel)) {
|
|
1134
|
-
process.stderr.write(
|
|
1135
|
-
JSON.stringify({ level, msg, extra, ts: (/* @__PURE__ */ new Date()).toISOString() }) + "\n"
|
|
1136
|
-
);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
1140
|
-
const server = new McpServer(
|
|
1141
|
-
{
|
|
1142
|
-
name: "mosadd",
|
|
1143
|
-
version: "3.0.0-alpha.0"
|
|
1144
|
-
},
|
|
1145
|
-
{
|
|
1146
|
-
capabilities: {
|
|
1147
|
-
tools: {}
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
);
|
|
1151
|
-
for (const tool of allTools) {
|
|
1152
|
-
const shape = tool.inputSchema && typeof tool.inputSchema === "object" && "shape" in tool.inputSchema ? tool.inputSchema.shape : tool.inputSchema;
|
|
1153
|
-
server.tool(
|
|
1154
|
-
tool.name,
|
|
1155
|
-
tool.description,
|
|
1156
|
-
shape,
|
|
1157
|
-
async (input) => {
|
|
1158
|
-
const parsed = tool.inputSchema.parse(input);
|
|
1159
|
-
try {
|
|
1160
|
-
const result = await tool.handler(parsed, ctx);
|
|
1161
|
-
return {
|
|
1162
|
-
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
1163
|
-
};
|
|
1164
|
-
} catch (err) {
|
|
1165
|
-
ctx.log("error", `tool ${tool.name} failed`, { error: String(err) });
|
|
1166
|
-
return {
|
|
1167
|
-
isError: true,
|
|
1168
|
-
content: [
|
|
1169
|
-
{
|
|
1170
|
-
type: "text",
|
|
1171
|
-
text: JSON.stringify({
|
|
1172
|
-
error: err instanceof Error ? err.message : String(err),
|
|
1173
|
-
tool: tool.name
|
|
1174
|
-
})
|
|
1175
|
-
}
|
|
1176
|
-
]
|
|
1177
|
-
};
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
);
|
|
1181
|
-
}
|
|
1182
|
-
return server;
|
|
1183
|
-
}
|
|
1184
|
-
function shouldLog(level, threshold) {
|
|
1185
|
-
const order = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
1186
|
-
return (order[level] ?? 1) >= (order[threshold] ?? 1);
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
export {
|
|
1190
|
-
allTools,
|
|
1191
|
-
defaultProviders,
|
|
1192
|
-
createMosaddServer
|
|
1193
|
-
};
|