claudemesh-cli 1.34.0 → 1.34.2
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/entrypoints/mcp.js
CHANGED
|
@@ -81,7 +81,7 @@ __export(exports_urls, {
|
|
|
81
81
|
VERSION: () => VERSION,
|
|
82
82
|
URLS: () => URLS
|
|
83
83
|
});
|
|
84
|
-
var URLS, VERSION = "1.34.
|
|
84
|
+
var URLS, VERSION = "1.34.2", env;
|
|
85
85
|
var init_urls = __esm(() => {
|
|
86
86
|
URLS = {
|
|
87
87
|
BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
|
|
@@ -2643,8 +2643,9 @@ import {
|
|
|
2643
2643
|
ListResourcesRequestSchema,
|
|
2644
2644
|
ReadResourceRequestSchema
|
|
2645
2645
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
2646
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
2646
|
+
import { existsSync as existsSync2, appendFileSync } from "node:fs";
|
|
2647
2647
|
import { request as httpRequest } from "node:http";
|
|
2648
|
+
import { join as join3 } from "node:path";
|
|
2648
2649
|
async function daemonReady() {
|
|
2649
2650
|
for (let i = 0;i < DAEMON_BOOT_RETRIES; i++) {
|
|
2650
2651
|
if (existsSync2(DAEMON_PATHS.SOCK_FILE))
|
|
@@ -2766,7 +2767,14 @@ async function startMcpServer() {
|
|
|
2766
2767
|
const ok = await daemonReady();
|
|
2767
2768
|
if (!ok)
|
|
2768
2769
|
bailNoDaemon();
|
|
2769
|
-
const server = new Server({ name: "claudemesh", version: VERSION }, {
|
|
2770
|
+
const server = new Server({ name: "claudemesh", version: VERSION }, {
|
|
2771
|
+
capabilities: {
|
|
2772
|
+
tools: {},
|
|
2773
|
+
prompts: {},
|
|
2774
|
+
resources: {},
|
|
2775
|
+
experimental: { "claude/channel": {} }
|
|
2776
|
+
}
|
|
2777
|
+
});
|
|
2770
2778
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [] }));
|
|
2771
2779
|
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
2772
2780
|
try {
|
|
@@ -2882,7 +2890,17 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
|
|
|
2882
2890
|
return { contents: [{ uri, mimeType: "text/markdown", text: fm.join(`
|
|
2883
2891
|
`) + skill.instructions }] };
|
|
2884
2892
|
});
|
|
2893
|
+
const mcpLogPath = join3(DAEMON_PATHS.DAEMON_DIR, `mcp-${process.pid}.log`);
|
|
2894
|
+
const mcpLog = (msg, meta) => {
|
|
2895
|
+
const line = JSON.stringify({ ts: new Date().toISOString(), pid: process.pid, msg, ...meta }) + `
|
|
2896
|
+
`;
|
|
2897
|
+
try {
|
|
2898
|
+
appendFileSync(mcpLogPath, line);
|
|
2899
|
+
} catch {}
|
|
2900
|
+
};
|
|
2901
|
+
mcpLog("mcp_started", { version: VERSION });
|
|
2885
2902
|
const sub = subscribeEvents(async (ev) => {
|
|
2903
|
+
mcpLog("sse_event_received", { kind: ev.kind });
|
|
2886
2904
|
if (ev.kind === "message") {
|
|
2887
2905
|
const d = ev.data;
|
|
2888
2906
|
const fromName = String(d.sender_name ?? "unknown");
|
|
@@ -2912,7 +2930,9 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
|
|
|
2912
2930
|
}
|
|
2913
2931
|
}
|
|
2914
2932
|
});
|
|
2933
|
+
mcpLog("channel_emitted", { content_preview: content.slice(0, 80), mesh: String(d.mesh ?? "") });
|
|
2915
2934
|
} catch (err) {
|
|
2935
|
+
mcpLog("channel_emit_failed", { err: String(err) });
|
|
2916
2936
|
process.stderr.write(`[claudemesh-mcp] channel emit failed: ${err}
|
|
2917
2937
|
`);
|
|
2918
2938
|
}
|
|
@@ -2944,6 +2964,11 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
|
|
|
2944
2964
|
});
|
|
2945
2965
|
const transport = new StdioServerTransport;
|
|
2946
2966
|
await server.connect(transport);
|
|
2967
|
+
const WELCOME_DELAY_MS = 5000;
|
|
2968
|
+
const WELCOME_LOOKBACK_MS = 24 * 60 * 60 * 1000;
|
|
2969
|
+
setTimeout(() => {
|
|
2970
|
+
emitInboxWelcome(server, mcpLog, WELCOME_LOOKBACK_MS);
|
|
2971
|
+
}, WELCOME_DELAY_MS);
|
|
2947
2972
|
const keepalive = setInterval(() => {}, 1000);
|
|
2948
2973
|
const shutdown = () => {
|
|
2949
2974
|
clearInterval(keepalive);
|
|
@@ -2953,6 +2978,70 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
|
|
|
2953
2978
|
process.on("SIGTERM", shutdown);
|
|
2954
2979
|
process.on("SIGINT", shutdown);
|
|
2955
2980
|
}
|
|
2981
|
+
async function emitInboxWelcome(server, mcpLog, lookbackMs) {
|
|
2982
|
+
const sinceIso = new Date(Date.now() - lookbackMs).toISOString();
|
|
2983
|
+
const path = `/v1/inbox?since=${encodeURIComponent(sinceIso)}&limit=20`;
|
|
2984
|
+
let body;
|
|
2985
|
+
try {
|
|
2986
|
+
const res = await daemonGet(path);
|
|
2987
|
+
if (res.status !== 200) {
|
|
2988
|
+
mcpLog("welcome_skip", { reason: "ipc_status", status: res.status });
|
|
2989
|
+
return;
|
|
2990
|
+
}
|
|
2991
|
+
body = res.body;
|
|
2992
|
+
} catch (e) {
|
|
2993
|
+
mcpLog("welcome_skip", { reason: "ipc_threw", err: String(e) });
|
|
2994
|
+
return;
|
|
2995
|
+
}
|
|
2996
|
+
const items = Array.isArray(body.items) ? body.items : [];
|
|
2997
|
+
if (items.length === 0) {
|
|
2998
|
+
mcpLog("welcome_skip", { reason: "empty" });
|
|
2999
|
+
return;
|
|
3000
|
+
}
|
|
3001
|
+
const byMesh = new Map;
|
|
3002
|
+
for (const it of items) {
|
|
3003
|
+
const meshSlug = String(it.mesh ?? "");
|
|
3004
|
+
const arr = byMesh.get(meshSlug) ?? [];
|
|
3005
|
+
arr.push(it);
|
|
3006
|
+
byMesh.set(meshSlug, arr);
|
|
3007
|
+
}
|
|
3008
|
+
const preview = items.slice(0, 3).map((it) => {
|
|
3009
|
+
const sender = String(it.sender_name ?? "unknown");
|
|
3010
|
+
const senderPub = String(it.sender_pubkey ?? "").slice(0, 8);
|
|
3011
|
+
const meshSlug = String(it.mesh ?? "");
|
|
3012
|
+
const bodyText = (typeof it.body === "string" ? it.body : "(encrypted)").slice(0, 60);
|
|
3013
|
+
const ts = String(it.received_at ?? "");
|
|
3014
|
+
const time = ts ? new Date(ts).toLocaleTimeString() : "";
|
|
3015
|
+
const tag = sender !== senderPub ? `${sender} (${senderPub})` : senderPub;
|
|
3016
|
+
return ` ${tag} [${meshSlug}] ${time}: ${bodyText}`;
|
|
3017
|
+
}).join(`
|
|
3018
|
+
`);
|
|
3019
|
+
const remainder = items.length > 3 ? `
|
|
3020
|
+
…and ${items.length - 3} more` : "";
|
|
3021
|
+
const meshList = [...byMesh.keys()].filter(Boolean).join(", ");
|
|
3022
|
+
const header = `\uD83D\uDCE5 [welcome] ${items.length} message${items.length === 1 ? "" : "s"} in inbox from the last 24h${meshList ? ` (${meshList})` : ""}`;
|
|
3023
|
+
const footer = `
|
|
3024
|
+
Run \`claudemesh inbox\` for full content.`;
|
|
3025
|
+
const content = `${header}
|
|
3026
|
+
${preview}${remainder}${footer}`;
|
|
3027
|
+
try {
|
|
3028
|
+
await server.notification({
|
|
3029
|
+
method: "notifications/claude/channel",
|
|
3030
|
+
params: {
|
|
3031
|
+
content,
|
|
3032
|
+
meta: {
|
|
3033
|
+
kind: "welcome",
|
|
3034
|
+
unread_count: items.length,
|
|
3035
|
+
meshes: [...byMesh.keys()],
|
|
3036
|
+
latest_message_ids: items.slice(0, 10).map((it) => String(it.id ?? ""))
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
});
|
|
3040
|
+
mcpLog("welcome_emitted", { count: items.length, meshes: [...byMesh.keys()] });
|
|
3041
|
+
} catch (err) {
|
|
3042
|
+
mcpLog("welcome_emit_failed", { err: String(err) });
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
2956
3045
|
async function startServiceProxy(serviceName) {
|
|
2957
3046
|
const config = readConfig();
|
|
2958
3047
|
if (config.meshes.length === 0) {
|
|
@@ -3065,4 +3154,4 @@ startMcpServer().catch((err) => {
|
|
|
3065
3154
|
process.exit(1);
|
|
3066
3155
|
});
|
|
3067
3156
|
|
|
3068
|
-
//# debugId=
|
|
3157
|
+
//# debugId=BF4B7D5AF5C8B94C64756E2164756E21
|