@mosadd/mcp 3.0.0-alpha.43 → 3.0.0-alpha.44
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
|
@@ -5,7 +5,22 @@ import {
|
|
|
5
5
|
|
|
6
6
|
// src/providers/supabase.ts
|
|
7
7
|
import { AsyncLocalStorage } from "async_hooks";
|
|
8
|
+
import { randomUUID } from "crypto";
|
|
9
|
+
import { hostname } from "os";
|
|
8
10
|
import { createClient } from "@supabase/supabase-js";
|
|
11
|
+
var cachedSessionId = null;
|
|
12
|
+
function sessionId() {
|
|
13
|
+
const perRequest = requestEnv.getStore();
|
|
14
|
+
if (perRequest) return perRequest.sessionKey ?? "";
|
|
15
|
+
if (cachedSessionId) return cachedSessionId;
|
|
16
|
+
let host = "mcp";
|
|
17
|
+
try {
|
|
18
|
+
host = (hostname() || "mcp").slice(0, 24);
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
cachedSessionId = `${host}:${randomUUID()}`;
|
|
22
|
+
return cachedSessionId;
|
|
23
|
+
}
|
|
9
24
|
var requestEnv = new AsyncLocalStorage();
|
|
10
25
|
function runWithSupabaseEnv(env, fn) {
|
|
11
26
|
return requestEnv.run(env, fn);
|
|
@@ -52,7 +67,16 @@ function getSupabase(env = readSupabaseEnv()) {
|
|
|
52
67
|
global: {
|
|
53
68
|
headers: {
|
|
54
69
|
...env.userJwt ? { Authorization: `Bearer ${env.userJwt}` } : {},
|
|
55
|
-
"x-mosadd-origin": "hub-gateway"
|
|
70
|
+
"x-mosadd-origin": "hub-gateway",
|
|
71
|
+
// Nagłówek tylko, gdy sesja MA tożsamość — puste "" (brama bez sessionKey) nie wysyła nic,
|
|
72
|
+
// więc serwerowy strażnik 409 nie widzi fałszywych roszczeń.
|
|
73
|
+
...sessionId() ? { "x-mosadd-session": sessionId() } : {}
|
|
74
|
+
// ⛔ KTÓRA TO SESJA (2026-08-27, „każdy generał co chwilę gubi mózg"). Wszyscy generałowie
|
|
75
|
+
// wpinają się kluczem hub TEGO SAMEGO właściciela, więc dla serwera ich wywołania były
|
|
76
|
+
// nieodróżnialne — a deklaracja linii (`comms_session_attach as_agent`) trzymała JEDEN
|
|
77
|
+
// wiersz na konto. Skutek: kto wpiął się ostatni, odbierał linię wszystkim pozostałym, a
|
|
78
|
+
// ich posty na kanałach zaczynały wracać z 403. Tożsamość sesji (stdio: per proces,
|
|
79
|
+
// brama: per klucz API) pozwala dziewięciu liniom na jednym koncie nie deptać sobie po piętach.
|
|
56
80
|
}
|
|
57
81
|
}
|
|
58
82
|
});
|
|
@@ -2553,7 +2577,7 @@ var actionTools = [
|
|
|
2553
2577
|
];
|
|
2554
2578
|
|
|
2555
2579
|
// src/tools/presence.ts
|
|
2556
|
-
import { hostname } from "os";
|
|
2580
|
+
import { hostname as hostname2 } from "os";
|
|
2557
2581
|
import { z as z17 } from "zod";
|
|
2558
2582
|
var BEAT_MS = 6e4;
|
|
2559
2583
|
var HOLD_SECONDS = 300;
|
|
@@ -2638,7 +2662,7 @@ async function comms_session_attach(input, ctx) {
|
|
|
2638
2662
|
const { error } = await sb.from("agent_bridge_heartbeat").delete().eq("identity_id", id);
|
|
2639
2663
|
if (error) throw new Error(`Could not release the line: ${error.message}`);
|
|
2640
2664
|
}
|
|
2641
|
-
await sb.from("mosadd_gateway_agent_binding").delete().eq("user_id", self.user_id);
|
|
2665
|
+
await sb.from("mosadd_gateway_agent_binding").delete().eq("user_id", self.user_id).eq("session_id", sessionId());
|
|
2642
2666
|
processBindings.delete(self.user_id);
|
|
2643
2667
|
ctx.log("info", "comms_session_attach: released", { identity_ids: [...toRelease] });
|
|
2644
2668
|
return {
|
|
@@ -2648,7 +2672,7 @@ async function comms_session_attach(input, ctx) {
|
|
|
2648
2672
|
note: "Line released (agent declaration cleared too). The 24/7 cloud stand-in answers from now on."
|
|
2649
2673
|
};
|
|
2650
2674
|
}
|
|
2651
|
-
const host = input.label?.trim() || `mcp:${
|
|
2675
|
+
const host = input.label?.trim() || `mcp:${hostname2()}`;
|
|
2652
2676
|
const mode = "mcp-session";
|
|
2653
2677
|
let lineId = self.id;
|
|
2654
2678
|
let speakingAs;
|
|
@@ -2664,6 +2688,13 @@ async function comms_session_attach(input, ctx) {
|
|
|
2664
2688
|
const { error: bindError } = await sb.from("mosadd_gateway_agent_binding").upsert(
|
|
2665
2689
|
{
|
|
2666
2690
|
user_id: self.user_id,
|
|
2691
|
+
// ⛔ CZYJA TO DEKLARACJA (2026-08-27). Wiersz jest nadal JEDEN na konto — pełna izolacja
|
|
2692
|
+
// wymaga, by żaden żywy klient nie zapisywał już przez ON CONFLICT (user_id), a takie
|
|
2693
|
+
// klienty jeszcze chodzą (próba zdjęcia tej unikalności zablokowała im wpinanie
|
|
2694
|
+
// całkowicie, więc została natychmiast cofnięta). Zapisany `session_id` pozwala jednak
|
|
2695
|
+
// bramie ROZPOZNAĆ, że deklarację przejęła inna sesja, i powiedzieć to wprost zamiast po
|
|
2696
|
+
// cichu podpisywać posty cudzą linią.
|
|
2697
|
+
session_id: sessionId(),
|
|
2667
2698
|
agent_identity_id: agent.id,
|
|
2668
2699
|
agent_address: agent.m0ssad_email,
|
|
2669
2700
|
bound_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2718,7 +2749,7 @@ async function autoBeatFromActivity(ctx) {
|
|
|
2718
2749
|
const now2 = Date.now();
|
|
2719
2750
|
if (now2 - (lastBindingCheck.get(self.user_id) ?? 0) >= BEAT_MS) {
|
|
2720
2751
|
lastBindingCheck.set(self.user_id, now2);
|
|
2721
|
-
const { data } = await getSupabase(env).from("mosadd_gateway_agent_binding").select("agent_identity_id, bound_at").eq("user_id", self.user_id).maybeSingle();
|
|
2752
|
+
const { data } = await getSupabase(env).from("mosadd_gateway_agent_binding").select("agent_identity_id, bound_at").eq("user_id", self.user_id).eq("session_id", sessionId()).maybeSingle();
|
|
2722
2753
|
if (data && Date.now() - new Date(data.bound_at).getTime() <= 24 * 60 * 60 * 1e3) {
|
|
2723
2754
|
lineId = data.agent_identity_id;
|
|
2724
2755
|
processBindings.set(self.user_id, lineId);
|
|
@@ -2730,7 +2761,7 @@ async function autoBeatFromActivity(ctx) {
|
|
|
2730
2761
|
const last = lastAutoBeat.get(lineId) ?? 0;
|
|
2731
2762
|
if (now - last < BEAT_MS) return;
|
|
2732
2763
|
lastAutoBeat.set(lineId, now);
|
|
2733
|
-
await beat(env, lineId, `mcp:auto (${
|
|
2764
|
+
await beat(env, lineId, `mcp:auto (${hostname2()})`, "mcp-activity");
|
|
2734
2765
|
} catch (e) {
|
|
2735
2766
|
ctx.log("debug", "autoBeatFromActivity skipped", { error: String(e) });
|
|
2736
2767
|
}
|
|
@@ -3196,7 +3227,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3196
3227
|
// package.json
|
|
3197
3228
|
var package_default = {
|
|
3198
3229
|
name: "@mosadd/mcp",
|
|
3199
|
-
version: "3.0.0-alpha.
|
|
3230
|
+
version: "3.0.0-alpha.44",
|
|
3200
3231
|
mcpName: "io.github.hei33enberg/mosadd-mcp",
|
|
3201
3232
|
description: "Model Context Protocol server for mosadd. Exposes 4 modules (mDM, mIRC, mURL, mAYL) and capabilities (mTALK, mRAG) plus comms agent-actions \u2014 84 tools \u2014 to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
|
|
3202
3233
|
homepage: "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
|
package/dist/index.d.ts
CHANGED
|
@@ -297,6 +297,8 @@ interface SupabaseEnv {
|
|
|
297
297
|
url: string;
|
|
298
298
|
anonKey: string;
|
|
299
299
|
userJwt?: string;
|
|
300
|
+
/** Stabilna tożsamość sesji dla bramy hostowanej (per klucz API) — patrz sessionId(). */
|
|
301
|
+
sessionKey?: string;
|
|
300
302
|
}
|
|
301
303
|
/** Run `fn` (and every tool call it triggers) with a per-request Supabase session. */
|
|
302
304
|
declare function runWithSupabaseEnv<T>(env: SupabaseEnv, fn: () => T): T;
|
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.44",
|
|
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 — 84 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",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@supabase/supabase-js": "^2.48.0",
|
|
40
40
|
"zod": "^4.3.6",
|
|
41
41
|
"@mosadd/crypto": "3.0.0-alpha.27",
|
|
42
|
-
"@mosadd/
|
|
42
|
+
"@mosadd/providers": "3.0.0-alpha.27",
|
|
43
43
|
"@mosadd/threat-engine": "3.0.0-alpha.28",
|
|
44
|
-
"@mosadd/
|
|
44
|
+
"@mosadd/protocol": "3.0.0-alpha.28"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"tsup": "^8.3.5",
|
|
@@ -162,10 +162,13 @@ describe("@mosadd/mcp — integration (real stdio)", () => {
|
|
|
162
162
|
clientInfo: { name: "vitest", version: "1.0" },
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
// mDM_send
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
165
|
+
// mDM_send to a nonexistent peer MUST fail — but as a normal `isError: true`
|
|
166
|
+
// content block, not a JSON-RPC error (that would crash the agent loop).
|
|
167
|
+
// The exact message depends on the machine: without credentials it's
|
|
168
|
+
// MissingSupabaseEnvError, with a logged-in `mosadd login` session the call
|
|
169
|
+
// reaches the real server and fails on the peer's missing prekey bundle.
|
|
170
|
+
// Both are the correct envelope; asserting one exact message made the test
|
|
171
|
+
// red on any machine with a live session (audyt 2026-08-27).
|
|
169
172
|
const resp = await client.send("tools/call", {
|
|
170
173
|
name: "mDM_send",
|
|
171
174
|
arguments: { to: "11111111-1111-1111-1111-111111111111", text: "hi" },
|
|
@@ -174,6 +177,6 @@ describe("@mosadd/mcp — integration (real stdio)", () => {
|
|
|
174
177
|
expect(resp.error).toBeUndefined(); // JSON-RPC level OK
|
|
175
178
|
const result = resp.result as { isError?: boolean; content?: Array<{ text?: string }> };
|
|
176
179
|
expect(result.isError).toBe(true);
|
|
177
|
-
expect(result.content?.[0]?.text).
|
|
180
|
+
expect(result.content?.[0]?.text ?? "").toMatch(/Missing|error/i);
|
|
178
181
|
});
|
|
179
182
|
});
|
|
@@ -25,6 +25,14 @@ import { loadSession, isSessionExpired } from "../config.js";
|
|
|
25
25
|
*/
|
|
26
26
|
let cachedSessionId: string | null = null;
|
|
27
27
|
export function sessionId(): string {
|
|
28
|
+
// ⛔ BRAMA HOSTOWANA ≠ PROCES (audyt 2026-08-27). Na mcp.mosadd.com jeden proces lambdy obsługuje
|
|
29
|
+
// WIELU najemców, a kolejne wywołania tej samej rozmowy potrafią trafić w RÓŻNE procesy — więc
|
|
30
|
+
// tożsamość per-proces byłaby tam jednocześnie wspólna (wyciek między najemcami) i niestała
|
|
31
|
+
// (fałszywe 409 przy każdym przełączeniu instancji). W kontekście bramy prawda żyje w ALS:
|
|
32
|
+
// brama wyznacza stabilny `sessionKey` per klucz API; brak klucza = puste "" (semantyka legacy,
|
|
33
|
+
// zero roszczeń per-sesja). Losowy identyfikator per-proces zostaje TYLKO dla stdio.
|
|
34
|
+
const perRequest = requestEnv.getStore();
|
|
35
|
+
if (perRequest) return perRequest.sessionKey ?? "";
|
|
28
36
|
if (cachedSessionId) return cachedSessionId;
|
|
29
37
|
let host = "mcp";
|
|
30
38
|
try { host = (hostname() || "mcp").slice(0, 24); } catch { /* bez nazwy hosta też działa */ }
|
|
@@ -36,6 +44,8 @@ export interface SupabaseEnv {
|
|
|
36
44
|
url: string;
|
|
37
45
|
anonKey: string;
|
|
38
46
|
userJwt?: string;
|
|
47
|
+
/** Stabilna tożsamość sesji dla bramy hostowanej (per klucz API) — patrz sessionId(). */
|
|
48
|
+
sessionKey?: string;
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
/**
|
|
@@ -114,13 +124,15 @@ export function getSupabase(env: SupabaseEnv = readSupabaseEnv()): SupabaseClien
|
|
|
114
124
|
headers: {
|
|
115
125
|
...(env.userJwt ? { Authorization: `Bearer ${env.userJwt}` } : {}),
|
|
116
126
|
"x-mosadd-origin": "hub-gateway",
|
|
127
|
+
// Nagłówek tylko, gdy sesja MA tożsamość — puste "" (brama bez sessionKey) nie wysyła nic,
|
|
128
|
+
// więc serwerowy strażnik 409 nie widzi fałszywych roszczeń.
|
|
129
|
+
...(sessionId() ? { "x-mosadd-session": sessionId() } : {}),
|
|
117
130
|
// ⛔ KTÓRA TO SESJA (2026-08-27, „każdy generał co chwilę gubi mózg"). Wszyscy generałowie
|
|
118
131
|
// wpinają się kluczem hub TEGO SAMEGO właściciela, więc dla serwera ich wywołania były
|
|
119
132
|
// nieodróżnialne — a deklaracja linii (`comms_session_attach as_agent`) trzymała JEDEN
|
|
120
133
|
// wiersz na konto. Skutek: kto wpiął się ostatni, odbierał linię wszystkim pozostałym, a
|
|
121
|
-
// ich posty na kanałach zaczynały wracać z 403.
|
|
122
|
-
//
|
|
123
|
-
"x-mosadd-session": sessionId(),
|
|
134
|
+
// ich posty na kanałach zaczynały wracać z 403. Tożsamość sesji (stdio: per proces,
|
|
135
|
+
// brama: per klucz API) pozwala dziewięciu liniom na jednym koncie nie deptać sobie po piętach.
|
|
124
136
|
},
|
|
125
137
|
},
|
|
126
138
|
});
|