@mosadd/mcp 3.0.0-alpha.40 → 3.0.0-alpha.41
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 +1 -1
- package/dist/{chunk-7ZAAJ52G.js → chunk-SS6UVKSB.js} +41 -3
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/server.ts +6 -0
- package/src/tools/presence.ts +69 -3
package/dist/bin/mcp.js
CHANGED
|
@@ -2574,11 +2574,16 @@ async function resolveSelf(env) {
|
|
|
2574
2574
|
"Unable to resolve the current account. Set MOSADD_API_KEY (hub key) or MOSADD_USER_JWT, or run `mosadd login`."
|
|
2575
2575
|
);
|
|
2576
2576
|
}
|
|
2577
|
-
const { data, error } = await sb.from("identities").select("id, display_name").eq("user_id", u.user.id).maybeSingle();
|
|
2577
|
+
const { data, error } = await sb.from("identities").select("id, display_name, kind").eq("user_id", u.user.id).maybeSingle();
|
|
2578
2578
|
if (error || !data) {
|
|
2579
2579
|
throw new Error("This account has no mosadd identity row yet \u2014 sign in to mosadd.com once to create it.");
|
|
2580
2580
|
}
|
|
2581
|
-
return {
|
|
2581
|
+
return {
|
|
2582
|
+
id: data.id,
|
|
2583
|
+
display_name: data.display_name ?? null,
|
|
2584
|
+
user_id: u.user.id,
|
|
2585
|
+
kind: data.kind ?? null
|
|
2586
|
+
};
|
|
2582
2587
|
}
|
|
2583
2588
|
async function resolveOwnedAgentLine(env, ownerUserId, ref) {
|
|
2584
2589
|
const value = ref.trim();
|
|
@@ -2698,6 +2703,38 @@ var presenceTools = [
|
|
|
2698
2703
|
handler: comms_session_attach
|
|
2699
2704
|
}
|
|
2700
2705
|
];
|
|
2706
|
+
var lastAutoBeat = /* @__PURE__ */ new Map();
|
|
2707
|
+
var lastBindingCheck = /* @__PURE__ */ new Map();
|
|
2708
|
+
async function autoBeatFromActivity(ctx) {
|
|
2709
|
+
try {
|
|
2710
|
+
const env = readSupabaseEnv();
|
|
2711
|
+
const self = await resolveSelf(env);
|
|
2712
|
+
let lineId = null;
|
|
2713
|
+
if (self.kind === "agent") {
|
|
2714
|
+
lineId = self.id;
|
|
2715
|
+
} else if (processBindings.has(self.user_id)) {
|
|
2716
|
+
lineId = processBindings.get(self.user_id);
|
|
2717
|
+
} else {
|
|
2718
|
+
const now2 = Date.now();
|
|
2719
|
+
if (now2 - (lastBindingCheck.get(self.user_id) ?? 0) >= BEAT_MS) {
|
|
2720
|
+
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();
|
|
2722
|
+
if (data && Date.now() - new Date(data.bound_at).getTime() <= 24 * 60 * 60 * 1e3) {
|
|
2723
|
+
lineId = data.agent_identity_id;
|
|
2724
|
+
processBindings.set(self.user_id, lineId);
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
if (!lineId) return;
|
|
2729
|
+
const now = Date.now();
|
|
2730
|
+
const last = lastAutoBeat.get(lineId) ?? 0;
|
|
2731
|
+
if (now - last < BEAT_MS) return;
|
|
2732
|
+
lastAutoBeat.set(lineId, now);
|
|
2733
|
+
await beat(env, lineId, `mcp:auto (${hostname()})`, "mcp-activity");
|
|
2734
|
+
} catch (e) {
|
|
2735
|
+
ctx.log("debug", "autoBeatFromActivity skipped", { error: String(e) });
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2701
2738
|
|
|
2702
2739
|
// src/tools/embed.ts
|
|
2703
2740
|
import { z as z18 } from "zod";
|
|
@@ -3159,7 +3196,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3159
3196
|
// package.json
|
|
3160
3197
|
var package_default = {
|
|
3161
3198
|
name: "@mosadd/mcp",
|
|
3162
|
-
version: "3.0.0-alpha.
|
|
3199
|
+
version: "3.0.0-alpha.41",
|
|
3163
3200
|
mcpName: "io.github.hei33enberg/mosadd-mcp",
|
|
3164
3201
|
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).",
|
|
3165
3202
|
homepage: "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
|
|
@@ -3419,6 +3456,7 @@ function createMosaddServer(options = {}) {
|
|
|
3419
3456
|
const parsed = tool.inputSchema.parse(input);
|
|
3420
3457
|
try {
|
|
3421
3458
|
const result = await tool.handler(parsed, ctx);
|
|
3459
|
+
void autoBeatFromActivity(ctx);
|
|
3422
3460
|
const rich = result;
|
|
3423
3461
|
if (rich && Array.isArray(rich.mcpContent)) {
|
|
3424
3462
|
return { content: rich.mcpContent };
|
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.41",
|
|
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",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"zod": "^4.3.6",
|
|
41
41
|
"@mosadd/providers": "3.0.0-alpha.27",
|
|
42
42
|
"@mosadd/crypto": "3.0.0-alpha.27",
|
|
43
|
-
"@mosadd/
|
|
44
|
-
"@mosadd/
|
|
43
|
+
"@mosadd/threat-engine": "3.0.0-alpha.28",
|
|
44
|
+
"@mosadd/protocol": "3.0.0-alpha.28"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"tsup": "^8.3.5",
|
package/src/server.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
6
|
import { allTools } from "./tools/index.js";
|
|
7
|
+
import { autoBeatFromActivity } from "./tools/presence.js";
|
|
7
8
|
import { PKG_VERSION } from "./version.js";
|
|
8
9
|
import { SupabaseDmProvider } from "./providers/supabase-dm.js";
|
|
9
10
|
import { SupabaseVoiceProvider } from "./providers/supabase-voice.js";
|
|
@@ -103,6 +104,11 @@ export function createMosaddServer(options: MosaddServerOptions = {}) {
|
|
|
103
104
|
const parsed = tool.inputSchema.parse(input);
|
|
104
105
|
try {
|
|
105
106
|
const result = await tool.handler(parsed as never, ctx);
|
|
107
|
+
// AUTO-PAROWANIE (08-26): a LIVE session that is actually WORKING holds its line —
|
|
108
|
+
// the founder spent a week talking to cloud stand-ins because models never
|
|
109
|
+
// remembered the attach handshake. Fire-and-forget, throttled inside, never blocks
|
|
110
|
+
// the tool's own response; see autoBeatFromActivity for which line gets the beat.
|
|
111
|
+
void autoBeatFromActivity(ctx);
|
|
106
112
|
// A tool may return rich MCP content (e.g. an image frame from
|
|
107
113
|
// comms_action_frame_get) via `mcpContent`; pass it through verbatim.
|
|
108
114
|
const rich = result as { mcpContent?: unknown[] } | null;
|
package/src/tools/presence.ts
CHANGED
|
@@ -104,7 +104,7 @@ async function beat(env: SupabaseEnv, identityId: string, host: string, mode: st
|
|
|
104
104
|
*/
|
|
105
105
|
async function resolveSelf(
|
|
106
106
|
env: SupabaseEnv,
|
|
107
|
-
): Promise<{ id: string; display_name: string | null; user_id: string }> {
|
|
107
|
+
): Promise<{ id: string; display_name: string | null; user_id: string; kind: string | null }> {
|
|
108
108
|
const sb = getSupabase(env);
|
|
109
109
|
const { data: u, error: ue } = await sb.auth.getUser();
|
|
110
110
|
if (ue || !u?.user) {
|
|
@@ -114,13 +114,18 @@ async function resolveSelf(
|
|
|
114
114
|
}
|
|
115
115
|
const { data, error } = await sb
|
|
116
116
|
.from("identities")
|
|
117
|
-
.select("id, display_name")
|
|
117
|
+
.select("id, display_name, kind")
|
|
118
118
|
.eq("user_id", u.user.id)
|
|
119
119
|
.maybeSingle();
|
|
120
120
|
if (error || !data) {
|
|
121
121
|
throw new Error("This account has no mosadd identity row yet — sign in to mosadd.com once to create it.");
|
|
122
122
|
}
|
|
123
|
-
return {
|
|
123
|
+
return {
|
|
124
|
+
id: data.id as string,
|
|
125
|
+
display_name: (data.display_name as string | null) ?? null,
|
|
126
|
+
user_id: u.user.id,
|
|
127
|
+
kind: (data.kind as string | null) ?? null,
|
|
128
|
+
};
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
/**
|
|
@@ -325,9 +330,70 @@ export const presenceTools: MosaddTool[] = [
|
|
|
325
330
|
},
|
|
326
331
|
];
|
|
327
332
|
|
|
333
|
+
/**
|
|
334
|
+
* AUTO-PAROWANIE (2026-08-26, rozkaz Króla po tygodniu „żywa sesja Dyspozytora nie jest
|
|
335
|
+
* podpięta"): the founder kept talking to cloud stand-ins because LIVE sessions never
|
|
336
|
+
* remembered to call comms_session_attach. A model cannot be relied on to remember a
|
|
337
|
+
* handshake — so the handshake stops being the model's job: the server calls THIS after
|
|
338
|
+
* every successful tool call. Any session that is actually DOING something on an agent
|
|
339
|
+
* line thereby holds that line, and the stand-in defers, with zero cooperation from the
|
|
340
|
+
* model.
|
|
341
|
+
*
|
|
342
|
+
* Which line gets the beat:
|
|
343
|
+
* · key's identity kind='agent' → its own line (the dispatcher's own key working = paired);
|
|
344
|
+
* · kind='human' WITH an as_agent declaration (processBindings, i.e. made by THIS
|
|
345
|
+
* process) → the declared agent's line;
|
|
346
|
+
* · kind='human' without a declaration → NOTHING. Guessing which of the owner's nine
|
|
347
|
+
* lines a session speaks for would be a new identity bug, and auto-claiming the
|
|
348
|
+
* OWNER's line would silence his own stand-in every time any tool runs.
|
|
349
|
+
*
|
|
350
|
+
* Throttled to one DB write per identity per BEAT_MS; failures are swallowed — presence
|
|
351
|
+
* is best-effort and must never break the tool call it rides on. Fire-and-forget by the
|
|
352
|
+
* caller (void), so it adds zero latency to the tool's own response.
|
|
353
|
+
*/
|
|
354
|
+
const lastAutoBeat = new Map<string, number>();
|
|
355
|
+
const lastBindingCheck = new Map<string, number>();
|
|
356
|
+
export async function autoBeatFromActivity(ctx: MosaddToolContext): Promise<void> {
|
|
357
|
+
try {
|
|
358
|
+
const env = readSupabaseEnv();
|
|
359
|
+
const self = await resolveSelf(env);
|
|
360
|
+
let lineId: string | null = null;
|
|
361
|
+
if (self.kind === "agent") {
|
|
362
|
+
lineId = self.id;
|
|
363
|
+
} else if (processBindings.has(self.user_id)) {
|
|
364
|
+
lineId = processBindings.get(self.user_id)!;
|
|
365
|
+
} else {
|
|
366
|
+
// Hosted gateway is serverless: a declaration made in ANOTHER invocation lives only in
|
|
367
|
+
// the DB. One throttled read per user per BEAT_MS keeps the cost of that honest.
|
|
368
|
+
const now = Date.now();
|
|
369
|
+
if (now - (lastBindingCheck.get(self.user_id) ?? 0) >= BEAT_MS) {
|
|
370
|
+
lastBindingCheck.set(self.user_id, now);
|
|
371
|
+
const { data } = await getSupabase(env)
|
|
372
|
+
.from("mosadd_gateway_agent_binding")
|
|
373
|
+
.select("agent_identity_id, bound_at")
|
|
374
|
+
.eq("user_id", self.user_id)
|
|
375
|
+
.maybeSingle();
|
|
376
|
+
if (data && Date.now() - new Date(data.bound_at as string).getTime() <= 24 * 60 * 60 * 1000) {
|
|
377
|
+
lineId = data.agent_identity_id as string;
|
|
378
|
+
processBindings.set(self.user_id, lineId);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (!lineId) return;
|
|
383
|
+
const now = Date.now();
|
|
384
|
+
const last = lastAutoBeat.get(lineId) ?? 0;
|
|
385
|
+
if (now - last < BEAT_MS) return;
|
|
386
|
+
lastAutoBeat.set(lineId, now);
|
|
387
|
+
await beat(env, lineId, `mcp:auto (${hostname()})`, "mcp-activity");
|
|
388
|
+
} catch (e) {
|
|
389
|
+
ctx.log("debug", "autoBeatFromActivity skipped", { error: String(e) });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
328
393
|
/** Test-only: stop every keep-alive so a suite does not leak timers between cases. */
|
|
329
394
|
export function __clearAttachmentsForTest(): void {
|
|
330
395
|
for (const a of attachments.values()) clearInterval(a.timer);
|
|
331
396
|
attachments.clear();
|
|
332
397
|
processBindings.clear();
|
|
398
|
+
lastAutoBeat.clear();
|
|
333
399
|
}
|