claudemesh-cli 1.34.7 → 1.34.9

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.
@@ -81,7 +81,7 @@ __export(exports_urls, {
81
81
  VERSION: () => VERSION,
82
82
  URLS: () => URLS
83
83
  });
84
- var URLS, VERSION = "1.34.7", env;
84
+ var URLS, VERSION = "1.34.9", env;
85
85
  var init_urls = __esm(() => {
86
86
  URLS = {
87
87
  BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
@@ -2728,6 +2728,32 @@ function daemonGet(path, opts = {}) {
2728
2728
  req.end();
2729
2729
  });
2730
2730
  }
2731
+ function daemonMarkSeen(ids, sessionToken) {
2732
+ return new Promise((resolve) => {
2733
+ if (ids.length === 0) {
2734
+ resolve();
2735
+ return;
2736
+ }
2737
+ const body = JSON.stringify({ ids });
2738
+ const headers = {
2739
+ "Content-Type": "application/json",
2740
+ "Content-Length": String(Buffer.byteLength(body))
2741
+ };
2742
+ if (sessionToken)
2743
+ headers.Authorization = `ClaudeMesh-Session ${sessionToken}`;
2744
+ const req = httpRequest({ socketPath: DAEMON_PATHS.SOCK_FILE, path: "/v1/inbox/seen", method: "POST", timeout: 3000, headers }, (res) => {
2745
+ res.on("data", () => {});
2746
+ res.on("end", () => resolve());
2747
+ });
2748
+ req.on("error", () => resolve());
2749
+ req.on("timeout", () => {
2750
+ req.destroy();
2751
+ resolve();
2752
+ });
2753
+ req.write(body);
2754
+ req.end();
2755
+ });
2756
+ }
2731
2757
  function subscribeEvents(onEvent) {
2732
2758
  let active = true;
2733
2759
  let req = null;
@@ -2940,6 +2966,8 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
2940
2966
  } catch {}
2941
2967
  };
2942
2968
  mcpLog("mcp_started", { version: VERSION });
2969
+ const { readSessionTokenFromEnv: readSessionTokenFromEnv2 } = await Promise.resolve().then(() => (init_token(), exports_token));
2970
+ const sessionTokenForSeen = readSessionTokenFromEnv2();
2943
2971
  const sub = subscribeEvents(async (ev) => {
2944
2972
  mcpLog("sse_event_received", { kind: ev.kind });
2945
2973
  if (ev.kind === "message") {
@@ -2972,6 +3000,10 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
2972
3000
  }
2973
3001
  });
2974
3002
  mcpLog("channel_emitted", { content_preview: content.slice(0, 80), mesh: String(d.mesh ?? "") });
3003
+ const inboxRowId = String(d.id ?? "");
3004
+ if (inboxRowId) {
3005
+ daemonMarkSeen([inboxRowId], sessionTokenForSeen).catch(() => {});
3006
+ }
2975
3007
  } catch (err) {
2976
3008
  mcpLog("channel_emit_failed", { err: String(err) });
2977
3009
  process.stderr.write(`[claudemesh-mcp] channel emit failed: ${err}
@@ -2980,11 +3012,23 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
2980
3012
  } else if (ev.kind === "peer_join" || ev.kind === "peer_leave" || ev.kind === "system") {
2981
3013
  const d = ev.data;
2982
3014
  const eventName = String(d.event ?? ev.kind);
3015
+ const renderPeerLine = (verb) => {
3016
+ const name = String(d.name ?? "unknown");
3017
+ const pubkey = String(d.pubkey ?? "");
3018
+ const pubkeyTag = pubkey ? ` (${pubkey.slice(0, 8)})` : "";
3019
+ const groups = Array.isArray(d.groups) ? d.groups : [];
3020
+ const groupNames = groups.map((g) => typeof g === "object" && g !== null && ("name" in g) ? String(g.name) : typeof g === "string" ? g : "").filter(Boolean);
3021
+ const groupsTag = groupNames.length > 0 ? ` [${groupNames.join(", ")}]` : "";
3022
+ const lastSeen = typeof d.lastSeenAt === "string" ? d.lastSeenAt : null;
3023
+ const summary = typeof d.summary === "string" && d.summary.trim() ? d.summary.trim() : null;
3024
+ const returningTail = lastSeen ? ` — last seen ${new Date(lastSeen).toLocaleTimeString()}${summary ? ` · "${summary.slice(0, 80)}"` : ""}` : "";
3025
+ return `[system] Peer "${name}"${pubkeyTag}${groupsTag} ${verb} the mesh${returningTail}`;
3026
+ };
2983
3027
  let content;
2984
3028
  if (ev.kind === "peer_join") {
2985
- content = `[system] Peer "${String(d.name ?? "unknown")}" joined the mesh`;
3029
+ content = renderPeerLine(eventName === "peer_returned" ? "returned to" : "joined");
2986
3030
  } else if (ev.kind === "peer_leave") {
2987
- content = `[system] Peer "${String(d.name ?? "unknown")}" left the mesh`;
3031
+ content = renderPeerLine("left");
2988
3032
  } else {
2989
3033
  content = `[system] ${eventName}: ${JSON.stringify(d).slice(0, 240)}`;
2990
3034
  }
@@ -2996,7 +3040,12 @@ ${mf.allowed_tools.map((t) => ` - ${t}`).join(`
2996
3040
  meta: {
2997
3041
  kind: "system",
2998
3042
  event: eventName,
2999
- mesh_slug: String(d.mesh ?? "")
3043
+ mesh_slug: String(d.mesh ?? ""),
3044
+ ...typeof d.name === "string" ? { peer_name: d.name } : {},
3045
+ ...typeof d.pubkey === "string" ? { peer_pubkey: d.pubkey } : {},
3046
+ ...Array.isArray(d.groups) ? { peer_groups: JSON.stringify(d.groups) } : {},
3047
+ ...typeof d.lastSeenAt === "string" ? { peer_last_seen_at: d.lastSeenAt } : {},
3048
+ ...typeof d.summary === "string" ? { peer_summary: d.summary } : {}
3000
3049
  }
3001
3050
  }
3002
3051
  });
@@ -3071,8 +3120,7 @@ async function emitMeshWelcome(server, mcpLog) {
3071
3120
  } catch (e) {
3072
3121
  mcpLog("welcome_peers_lookup_failed", { err: String(e) });
3073
3122
  }
3074
- const sinceIso = new Date(Date.now() - 86400000).toISOString();
3075
- const inboxPath = selfMeshSlug ? `/v1/inbox?mesh=${encodeURIComponent(selfMeshSlug)}&since=${encodeURIComponent(sinceIso)}&limit=20` : `/v1/inbox?since=${encodeURIComponent(sinceIso)}&limit=20`;
3123
+ const inboxPath = selfMeshSlug ? `/v1/inbox?mesh=${encodeURIComponent(selfMeshSlug)}&unread_only=true&mark_seen=false&limit=50` : `/v1/inbox?unread_only=true&mark_seen=false&limit=50`;
3076
3124
  let inboxItems = [];
3077
3125
  try {
3078
3126
  const { status, body } = await daemonGet(inboxPath, { sessionToken });
@@ -3096,9 +3144,9 @@ async function emitMeshWelcome(server, mcpLog) {
3096
3144
  lines.push(`\uD83D\uDC65 Peer list unavailable (daemon query failed).`);
3097
3145
  }
3098
3146
  if (inboxItems.length === 0) {
3099
- lines.push(`\uD83D\uDCE5 Inbox is empty (last 24h).`);
3147
+ lines.push(`\uD83D\uDCE5 No unread messages.`);
3100
3148
  } else {
3101
- lines.push(`\uD83D\uDCE5 ${inboxItems.length} message${inboxItems.length === 1 ? "" : "s"} in inbox (last 24h):`);
3149
+ lines.push(`\uD83D\uDCE5 ${inboxItems.length} unread message${inboxItems.length === 1 ? "" : "s"}:`);
3102
3150
  for (const it of inboxItems.slice(0, 3)) {
3103
3151
  const sender = String(it.sender_name ?? "unknown");
3104
3152
  const senderPub = String(it.sender_pubkey ?? "").slice(0, 8);
@@ -3137,6 +3185,12 @@ async function emitMeshWelcome(server, mcpLog) {
3137
3185
  peer_count: peerCount,
3138
3186
  unread_count: inboxItems.length
3139
3187
  });
3188
+ if (inboxItems.length > 0) {
3189
+ const ids = inboxItems.map((it) => String(it.id ?? "")).filter(Boolean);
3190
+ if (ids.length > 0) {
3191
+ daemonMarkSeen(ids, sessionToken).catch(() => {});
3192
+ }
3193
+ }
3140
3194
  } catch (err) {
3141
3195
  mcpLog("welcome_emit_failed", { err: String(err) });
3142
3196
  }
@@ -3253,4 +3307,4 @@ startMcpServer().catch((err) => {
3253
3307
  process.exit(1);
3254
3308
  });
3255
3309
 
3256
- //# debugId=E3C9A185DCECC45864756E2164756E21
3310
+ //# debugId=A1C0C58B936C52DF64756E2164756E21