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.
@@ -104,7 +104,7 @@ __export(exports_urls, {
104
104
  VERSION: () => VERSION,
105
105
  URLS: () => URLS
106
106
  });
107
- var URLS, VERSION = "1.34.0", env;
107
+ var URLS, VERSION = "1.34.2", env;
108
108
  var init_urls = __esm(() => {
109
109
  URLS = {
110
110
  BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
@@ -18147,8 +18147,9 @@ import {
18147
18147
  ListResourcesRequestSchema,
18148
18148
  ReadResourceRequestSchema
18149
18149
  } from "@modelcontextprotocol/sdk/types.js";
18150
- import { existsSync as existsSync28 } from "node:fs";
18150
+ import { existsSync as existsSync28, appendFileSync as appendFileSync2 } from "node:fs";
18151
18151
  import { request as httpRequest2 } from "node:http";
18152
+ import { join as join16 } from "node:path";
18152
18153
  async function daemonReady() {
18153
18154
  for (let i = 0;i < DAEMON_BOOT_RETRIES; i++) {
18154
18155
  if (existsSync28(DAEMON_PATHS.SOCK_FILE))
@@ -18270,7 +18271,14 @@ async function startMcpServer() {
18270
18271
  const ok = await daemonReady();
18271
18272
  if (!ok)
18272
18273
  bailNoDaemon();
18273
- const server = new Server({ name: "claudemesh", version: VERSION }, { capabilities: { tools: {}, prompts: {}, resources: {} } });
18274
+ const server = new Server({ name: "claudemesh", version: VERSION }, {
18275
+ capabilities: {
18276
+ tools: {},
18277
+ prompts: {},
18278
+ resources: {},
18279
+ experimental: { "claude/channel": {} }
18280
+ }
18281
+ });
18274
18282
  server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [] }));
18275
18283
  server.setRequestHandler(ListPromptsRequestSchema, async () => {
18276
18284
  try {
@@ -18386,7 +18394,17 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
18386
18394
  return { contents: [{ uri, mimeType: "text/markdown", text: fm.join(`
18387
18395
  `) + skill.instructions }] };
18388
18396
  });
18397
+ const mcpLogPath = join16(DAEMON_PATHS.DAEMON_DIR, `mcp-${process.pid}.log`);
18398
+ const mcpLog = (msg, meta) => {
18399
+ const line = JSON.stringify({ ts: new Date().toISOString(), pid: process.pid, msg, ...meta }) + `
18400
+ `;
18401
+ try {
18402
+ appendFileSync2(mcpLogPath, line);
18403
+ } catch {}
18404
+ };
18405
+ mcpLog("mcp_started", { version: VERSION });
18389
18406
  const sub = subscribeEvents(async (ev) => {
18407
+ mcpLog("sse_event_received", { kind: ev.kind });
18390
18408
  if (ev.kind === "message") {
18391
18409
  const d = ev.data;
18392
18410
  const fromName = String(d.sender_name ?? "unknown");
@@ -18416,7 +18434,9 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
18416
18434
  }
18417
18435
  }
18418
18436
  });
18437
+ mcpLog("channel_emitted", { content_preview: content.slice(0, 80), mesh: String(d.mesh ?? "") });
18419
18438
  } catch (err) {
18439
+ mcpLog("channel_emit_failed", { err: String(err) });
18420
18440
  process.stderr.write(`[claudemesh-mcp] channel emit failed: ${err}
18421
18441
  `);
18422
18442
  }
@@ -18448,6 +18468,11 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
18448
18468
  });
18449
18469
  const transport = new StdioServerTransport;
18450
18470
  await server.connect(transport);
18471
+ const WELCOME_DELAY_MS = 5000;
18472
+ const WELCOME_LOOKBACK_MS = 24 * 60 * 60 * 1000;
18473
+ setTimeout(() => {
18474
+ emitInboxWelcome(server, mcpLog, WELCOME_LOOKBACK_MS);
18475
+ }, WELCOME_DELAY_MS);
18451
18476
  const keepalive = setInterval(() => {}, 1000);
18452
18477
  const shutdown = () => {
18453
18478
  clearInterval(keepalive);
@@ -18457,6 +18482,70 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
18457
18482
  process.on("SIGTERM", shutdown);
18458
18483
  process.on("SIGINT", shutdown);
18459
18484
  }
18485
+ async function emitInboxWelcome(server, mcpLog, lookbackMs) {
18486
+ const sinceIso = new Date(Date.now() - lookbackMs).toISOString();
18487
+ const path2 = `/v1/inbox?since=${encodeURIComponent(sinceIso)}&limit=20`;
18488
+ let body;
18489
+ try {
18490
+ const res = await daemonGet(path2);
18491
+ if (res.status !== 200) {
18492
+ mcpLog("welcome_skip", { reason: "ipc_status", status: res.status });
18493
+ return;
18494
+ }
18495
+ body = res.body;
18496
+ } catch (e) {
18497
+ mcpLog("welcome_skip", { reason: "ipc_threw", err: String(e) });
18498
+ return;
18499
+ }
18500
+ const items = Array.isArray(body.items) ? body.items : [];
18501
+ if (items.length === 0) {
18502
+ mcpLog("welcome_skip", { reason: "empty" });
18503
+ return;
18504
+ }
18505
+ const byMesh = new Map;
18506
+ for (const it of items) {
18507
+ const meshSlug = String(it.mesh ?? "");
18508
+ const arr = byMesh.get(meshSlug) ?? [];
18509
+ arr.push(it);
18510
+ byMesh.set(meshSlug, arr);
18511
+ }
18512
+ const preview = items.slice(0, 3).map((it) => {
18513
+ const sender = String(it.sender_name ?? "unknown");
18514
+ const senderPub = String(it.sender_pubkey ?? "").slice(0, 8);
18515
+ const meshSlug = String(it.mesh ?? "");
18516
+ const bodyText = (typeof it.body === "string" ? it.body : "(encrypted)").slice(0, 60);
18517
+ const ts = String(it.received_at ?? "");
18518
+ const time = ts ? new Date(ts).toLocaleTimeString() : "";
18519
+ const tag = sender !== senderPub ? `${sender} (${senderPub})` : senderPub;
18520
+ return ` ${tag} [${meshSlug}] ${time}: ${bodyText}`;
18521
+ }).join(`
18522
+ `);
18523
+ const remainder = items.length > 3 ? `
18524
+ …and ${items.length - 3} more` : "";
18525
+ const meshList = [...byMesh.keys()].filter(Boolean).join(", ");
18526
+ const header = `\uD83D\uDCE5 [welcome] ${items.length} message${items.length === 1 ? "" : "s"} in inbox from the last 24h${meshList ? ` (${meshList})` : ""}`;
18527
+ const footer = `
18528
+ Run \`claudemesh inbox\` for full content.`;
18529
+ const content = `${header}
18530
+ ${preview}${remainder}${footer}`;
18531
+ try {
18532
+ await server.notification({
18533
+ method: "notifications/claude/channel",
18534
+ params: {
18535
+ content,
18536
+ meta: {
18537
+ kind: "welcome",
18538
+ unread_count: items.length,
18539
+ meshes: [...byMesh.keys()],
18540
+ latest_message_ids: items.slice(0, 10).map((it) => String(it.id ?? ""))
18541
+ }
18542
+ }
18543
+ });
18544
+ mcpLog("welcome_emitted", { count: items.length, meshes: [...byMesh.keys()] });
18545
+ } catch (err) {
18546
+ mcpLog("welcome_emit_failed", { err: String(err) });
18547
+ }
18548
+ }
18460
18549
  async function startServiceProxy(serviceName) {
18461
18550
  const config = readConfig();
18462
18551
  if (config.meshes.length === 0) {
@@ -20493,4 +20582,4 @@ main().catch((err) => {
20493
20582
  process.exit(EXIT.INTERNAL_ERROR);
20494
20583
  });
20495
20584
 
20496
- //# debugId=55E9142D00D4EE3764756E2164756E21
20585
+ //# debugId=FD137608913AB26764756E2164756E21