@mosadd/mcp 3.0.0-alpha.51 → 3.0.0-alpha.52
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/dist/bin/mcp.js
CHANGED
|
@@ -2189,17 +2189,37 @@ import { z as z12 } from "zod";
|
|
|
2189
2189
|
|
|
2190
2190
|
// src/providers/blob-upload.ts
|
|
2191
2191
|
function defaultBucket(kind) {
|
|
2192
|
-
return kind === "file" ? "
|
|
2192
|
+
return kind === "file" ? "chat-files" : "voice-messages";
|
|
2193
|
+
}
|
|
2194
|
+
function jwtSub(jwt) {
|
|
2195
|
+
const part = jwt.split(".")[1];
|
|
2196
|
+
if (!part) return null;
|
|
2197
|
+
try {
|
|
2198
|
+
const json = JSON.parse(Buffer.from(part.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8"));
|
|
2199
|
+
return typeof json?.sub === "string" && json.sub ? json.sub : null;
|
|
2200
|
+
} catch {
|
|
2201
|
+
return null;
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
function ownerFolder(userJwt) {
|
|
2205
|
+
const sub = userJwt ? jwtSub(userJwt) : null;
|
|
2206
|
+
if (!sub) {
|
|
2207
|
+
throw new Error(
|
|
2208
|
+
"blob upload refused: no user id in the session JWT \u2014 bucket policy requires foldername[1] = auth.uid(); run `mosadd login` (or set MOSADD_USER_JWT) and retry"
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
return sub;
|
|
2193
2212
|
}
|
|
2194
2213
|
function randomId2() {
|
|
2195
2214
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
2196
2215
|
}
|
|
2197
2216
|
async function uploadBlob(args) {
|
|
2198
|
-
readSupabaseEnv();
|
|
2217
|
+
const env = readSupabaseEnv();
|
|
2199
2218
|
const sb = getSupabase();
|
|
2200
2219
|
const bucket = args.bucket ?? defaultBucket(args.kind);
|
|
2201
2220
|
const ext = args.filename?.split(".").pop() ?? mimeExt(args.mime);
|
|
2202
|
-
const
|
|
2221
|
+
const folder = args.prefix ? args.prefix.replace(/[^a-zA-Z0-9._/-]/g, "-").replace(/^\/+|\/+$/g, "") : "";
|
|
2222
|
+
const path = [ownerFolder(env.userJwt), folder, `${randomId2()}${ext ? "." + ext : ""}`].filter(Boolean).join("/");
|
|
2203
2223
|
const { error } = await sb.storage.from(bucket).upload(path, args.bytes, {
|
|
2204
2224
|
contentType: args.mime,
|
|
2205
2225
|
upsert: false
|
|
@@ -3483,7 +3503,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3483
3503
|
// package.json
|
|
3484
3504
|
var package_default = {
|
|
3485
3505
|
name: "@mosadd/mcp",
|
|
3486
|
-
version: "3.0.0-alpha.
|
|
3506
|
+
version: "3.0.0-alpha.52",
|
|
3487
3507
|
mcpName: "io.github.hei33enberg/mosadd-mcp",
|
|
3488
3508
|
description: "Model Context Protocol server for mosadd. Exposes 4 modules (mDM, mIRC, mURL, mAYL) and capabilities (mTALK, mRAG) plus comms agent-actions \u2014 85 tools \u2014 to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
|
|
3489
3509
|
homepage: "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosadd/mcp",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.52",
|
|
4
4
|
"mcpName": "io.github.hei33enberg/mosadd-mcp",
|
|
5
5
|
"description": "Model Context Protocol server for mosadd. Exposes 4 modules (mDM, mIRC, mURL, mAYL) and capabilities (mTALK, mRAG) plus comms agent-actions — 85 tools — to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
|
|
6
6
|
"homepage": "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LANA PLIKOW — ŻYWA, NIE DOPISANA Z PAMIĘCI (16.09).
|
|
3
|
+
*
|
|
4
|
+
* Zmierzone PRZED poprawką, na żywym MCP (mcp.mosadd.com), 1 KB text/plain:
|
|
5
|
+
* mDM_send_file → "blob upload to file-blobs/dm-…/….txt failed: Bucket not found"
|
|
6
|
+
* mDM_send_voice → "blob upload to voice-blobs/dm-…/….webm failed: Bucket not found"
|
|
7
|
+
* Buckety `file-blobs` i `voice-blobs` NIE ISTNIEJĄ w projekcie — lista bucketów
|
|
8
|
+
* (16.09) to: secure_vault, brand_assets, chat-files, gemstone-models, voice-messages,
|
|
9
|
+
* chat-attachments, odyssey-media, raydio-media, voice-samples, mayl-attachments,
|
|
10
|
+
* rag-uploads, ptt-recordings, avatars, downloads, orb-media, founder-archive, krol-wrzutki.
|
|
11
|
+
*
|
|
12
|
+
* Dwa zamki, każdy pilnuje jednej połowy kontraktu z polityką RLS:
|
|
13
|
+
* 1. bucket, który istnieje I przyjmie ten JWT (chat-files / voice-messages);
|
|
14
|
+
* 2. ścieżka z `auth.uid()` jako PIERWSZYM segmentem, bo obie polityki INSERT
|
|
15
|
+
* sprawdzają dokładnie `(storage.foldername(name))[1] = auth.uid()`.
|
|
16
|
+
* Ścieżka bez segmentu użytkownika to wysyłka, która ZAWSZE padnie — i padnie
|
|
17
|
+
* komunikatem, który nie mówi dlaczego.
|
|
18
|
+
*/
|
|
19
|
+
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
20
|
+
|
|
21
|
+
const SUB = "05261c7d-f34a-4fb2-a0e0-0f85149eb0ce";
|
|
22
|
+
const THREAD = "dm-dbe85c4e-ec79-4e9a-a55d-7274e0e3296e-4cd1894d-b878-4fe4-b221-084419f7d225";
|
|
23
|
+
|
|
24
|
+
function jwt(sub: string | null): string {
|
|
25
|
+
const b64 = (o: unknown) => Buffer.from(JSON.stringify(o)).toString("base64url");
|
|
26
|
+
return `${b64({ alg: "HS256", typ: "JWT" })}.${b64(sub ? { sub, role: "authenticated" } : { role: "authenticated" })}.sig`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Co dokładnie poszło do magazynu — jedno miejsce prawdy dla obu zamków. */
|
|
30
|
+
let lastCall: { bucket: string; path: string; mime: string } | null = null;
|
|
31
|
+
let userJwt: string | undefined = jwt(SUB);
|
|
32
|
+
|
|
33
|
+
vi.mock("../providers/supabase.js", () => ({
|
|
34
|
+
readSupabaseEnv: () => ({ url: "https://x.supabase.co", anonKey: "anon", userJwt }),
|
|
35
|
+
getSupabase: () => ({
|
|
36
|
+
storage: {
|
|
37
|
+
from: (bucket: string) => ({
|
|
38
|
+
upload: async (path: string, _bytes: Uint8Array, opts: { contentType: string }) => {
|
|
39
|
+
lastCall = { bucket, path, mime: opts.contentType };
|
|
40
|
+
return { error: null };
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
const { uploadBlob, decodeBase64Body } = await import("../providers/blob-upload.js");
|
|
48
|
+
|
|
49
|
+
beforeEach(() => { lastCall = null; userJwt = jwt(SUB); });
|
|
50
|
+
|
|
51
|
+
describe("blob-upload — bucket i ścieżka, które polityka RLS naprawdę przyjmie", () => {
|
|
52
|
+
it("plik idzie do chat-files, a ścieżka zaczyna się od auth.uid()", async () => {
|
|
53
|
+
const desc = await uploadBlob({
|
|
54
|
+
kind: "file",
|
|
55
|
+
bytes: new Uint8Array([1, 2, 3]),
|
|
56
|
+
mime: "text/plain",
|
|
57
|
+
prefix: THREAD,
|
|
58
|
+
filename: "lana-plikow-test.txt",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(lastCall!.bucket).toBe("chat-files");
|
|
62
|
+
expect(desc.bucket).toBe("chat-files");
|
|
63
|
+
const [uid, thread, file] = lastCall!.path.split("/");
|
|
64
|
+
expect(uid).toBe(SUB); // ← to sprawdza polityka INSERT
|
|
65
|
+
expect(thread).toBe(THREAD);
|
|
66
|
+
expect(file).toMatch(/^[0-9a-f-]{36}\.txt$/);
|
|
67
|
+
expect(desc.path).toBe(lastCall!.path);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("głos idzie do voice-messages (nie do nieistniejącego voice-blobs)", async () => {
|
|
71
|
+
const desc = await uploadBlob({ kind: "voice", bytes: new Uint8Array([1]), mime: "audio/webm", prefix: THREAD });
|
|
72
|
+
expect(lastCall!.bucket).toBe("voice-messages");
|
|
73
|
+
expect(desc.bucket).toBe("voice-messages");
|
|
74
|
+
expect(lastCall!.path.split("/")[0]).toBe(SUB);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("ptt też ląduje w buckecie, który istnieje i ma politykę INSERT", async () => {
|
|
78
|
+
await uploadBlob({ kind: "ptt", bytes: new Uint8Array([1]), mime: "audio/ogg", prefix: "chat-abc" });
|
|
79
|
+
expect(lastCall!.bucket).toBe("voice-messages");
|
|
80
|
+
expect(lastCall!.path).toMatch(new RegExp(`^${SUB}/chat-abc/[0-9a-f-]{36}\\.ogg$`));
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("bez JWT użytkownika upload jest ODRZUCONY, zanim poleci bajt", async () => {
|
|
84
|
+
userJwt = undefined;
|
|
85
|
+
await expect(uploadBlob({ kind: "file", bytes: new Uint8Array([1]), mime: "text/plain" }))
|
|
86
|
+
.rejects.toThrow(/auth\.uid\(\)/);
|
|
87
|
+
expect(lastCall).toBeNull(); // nic nie poszło do magazynu
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("ścieżka z pamięci przechodzi przez ten sam dekoder base64 (kontrakt narzędzi)", () => {
|
|
91
|
+
expect(new TextDecoder().decode(decodeBase64Body("VEVTVCAxNg=="))).toBe("TEST 16");
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -12,8 +12,11 @@
|
|
|
12
12
|
* STATUS: scaffold. The Storage upload path below is real (supabase-js
|
|
13
13
|
* `storage.from(bucket).upload`), but two things are TODO and gated on the
|
|
14
14
|
* Lane A / CTO backend contract:
|
|
15
|
-
* -
|
|
16
|
-
*
|
|
15
|
+
* - DONE 2026-09-16: bucket names + write policy CONFIRMED against the live
|
|
16
|
+
* project (see defaultBucket()/ownerFolder()). The old defaults
|
|
17
|
+
* ('file-blobs', 'voice-blobs') did not exist in the project, so EVERY
|
|
18
|
+
* file/voice send from MCP died with `Bucket not found` — reproduced on
|
|
19
|
+
* mDM_send_file, mIRC_send_file and mDM_send_voice before the fix.
|
|
17
20
|
* - TODO(Lane A): mDM voice is CLIENT-ENCRYPTED — the bytes must be sealed
|
|
18
21
|
* (per-recipient, via @mosadd/crypto) before upload and `key_ref` must point
|
|
19
22
|
* at the wrapped content key. Today this helper uploads the bytes as-is and
|
|
@@ -54,8 +57,48 @@ export interface UploadBlobArgs {
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
function defaultBucket(kind: AttachmentKind): string {
|
|
57
|
-
//
|
|
58
|
-
|
|
60
|
+
// ⛔ TYLKO BUCKETY, KTÓRE ISTNIEJĄ I PRZYJMĄ TEN JWT (potwierdzone na żywym
|
|
61
|
+
// projekcie rooffhgbxafyjcwmwpsy, 16.09):
|
|
62
|
+
// chat-files → bucket istnieje (limit 100 MB). INSERT policy
|
|
63
|
+
// "Users upload chat files": (storage.foldername(name))[1] = auth.uid()
|
|
64
|
+
// SELECT policy dopuszcza też członka wątku: is_thread_member(auth.uid(), foldername[2])
|
|
65
|
+
// voice-messages → bucket istnieje. INSERT policy
|
|
66
|
+
// "Users can upload voice messages": foldername(name)[1] = auth.uid()
|
|
67
|
+
// Poprzednie domyślne ('file-blobs' dla file, 'voice-blobs' dla voice/ptt) NIE
|
|
68
|
+
// ISTNIEJĄ w projekcie — stąd "Bucket not found" na mDM_send_file, mIRC_send_file
|
|
69
|
+
// i mDM_send_voice. Nazwy są tu jednym źródłem prawdy: gdy bucket zniknie,
|
|
70
|
+
// zawodzi JAWNIE, a nie po cichu ląduje w innym miejscu.
|
|
71
|
+
return kind === "file" ? "chat-files" : "voice-messages";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** `sub` z JWT tej sesji, czyli `auth.uid()` — PIERWSZY segment ścieżki.
|
|
75
|
+
*
|
|
76
|
+
* ⛔ NIE OZDOBA I NIE OPCJA. Jedyny segment, który sprawdzają polityki INSERT obu
|
|
77
|
+
* bucketów: `(storage.foldername(name))[1] = auth.uid()`. Ścieżka bez segmentu
|
|
78
|
+
* użytkownika (`<thread>/<uuid>.ext`, jak było) przechodzi upload do momentu,
|
|
79
|
+
* w którym baza odrzuca wiersz — czyli wysyłka pliku jest ZAWSZE martwa, i to
|
|
80
|
+
* komunikatem, który nie mówi dlaczego. Ta sama konwencja co w aplikacji:
|
|
81
|
+
* `apps/web/src/lib/ircApi.ts: uploadChatFile()` → `<user.id>/<thread>/<ts>_<nazwa>`.
|
|
82
|
+
*/
|
|
83
|
+
function jwtSub(jwt: string): string | null {
|
|
84
|
+
const part = jwt.split(".")[1];
|
|
85
|
+
if (!part) return null;
|
|
86
|
+
try {
|
|
87
|
+
const json = JSON.parse(Buffer.from(part.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8"));
|
|
88
|
+
return typeof json?.sub === "string" && json.sub ? json.sub : null;
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function ownerFolder(userJwt: string | undefined): string {
|
|
95
|
+
const sub = userJwt ? jwtSub(userJwt) : null;
|
|
96
|
+
if (!sub) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
"blob upload refused: no user id in the session JWT — bucket policy requires foldername[1] = auth.uid(); run `mosadd login` (or set MOSADD_USER_JWT) and retry",
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return sub;
|
|
59
102
|
}
|
|
60
103
|
|
|
61
104
|
function randomId(): string {
|
|
@@ -68,11 +111,14 @@ function randomId(): string {
|
|
|
68
111
|
* in `message-send`'s `attachments[]`.
|
|
69
112
|
*/
|
|
70
113
|
export async function uploadBlob(args: UploadBlobArgs): Promise<AttachmentDescriptor> {
|
|
71
|
-
readSupabaseEnv();
|
|
114
|
+
const env = readSupabaseEnv();
|
|
72
115
|
const sb = getSupabase();
|
|
73
116
|
const bucket = args.bucket ?? defaultBucket(args.kind);
|
|
74
117
|
const ext = args.filename?.split(".").pop() ?? mimeExt(args.mime);
|
|
75
|
-
|
|
118
|
+
// ⛔ KOLEJNOŚĆ SEGMENTÓW JEST CZĘŚCIĄ KONTRAKTU Z POLITYKĄ: <auth.uid()>/<wątek>/<uuid>.<ext>.
|
|
119
|
+
const folder = args.prefix ? args.prefix.replace(/[^a-zA-Z0-9._/-]/g, "-").replace(/^\/+|\/+$/g, "") : "";
|
|
120
|
+
const path = [ownerFolder(env.userJwt), folder, `${randomId()}${ext ? "." + ext : ""}`]
|
|
121
|
+
.filter(Boolean).join("/");
|
|
76
122
|
|
|
77
123
|
const { error } = await sb.storage.from(bucket).upload(path, args.bytes, {
|
|
78
124
|
contentType: args.mime,
|