claudemesh-cli 1.34.7 → 1.34.8

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.8", 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}
@@ -3071,8 +3103,7 @@ async function emitMeshWelcome(server, mcpLog) {
3071
3103
  } catch (e) {
3072
3104
  mcpLog("welcome_peers_lookup_failed", { err: String(e) });
3073
3105
  }
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`;
3106
+ 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
3107
  let inboxItems = [];
3077
3108
  try {
3078
3109
  const { status, body } = await daemonGet(inboxPath, { sessionToken });
@@ -3096,9 +3127,9 @@ async function emitMeshWelcome(server, mcpLog) {
3096
3127
  lines.push(`\uD83D\uDC65 Peer list unavailable (daemon query failed).`);
3097
3128
  }
3098
3129
  if (inboxItems.length === 0) {
3099
- lines.push(`\uD83D\uDCE5 Inbox is empty (last 24h).`);
3130
+ lines.push(`\uD83D\uDCE5 No unread messages.`);
3100
3131
  } else {
3101
- lines.push(`\uD83D\uDCE5 ${inboxItems.length} message${inboxItems.length === 1 ? "" : "s"} in inbox (last 24h):`);
3132
+ lines.push(`\uD83D\uDCE5 ${inboxItems.length} unread message${inboxItems.length === 1 ? "" : "s"}:`);
3102
3133
  for (const it of inboxItems.slice(0, 3)) {
3103
3134
  const sender = String(it.sender_name ?? "unknown");
3104
3135
  const senderPub = String(it.sender_pubkey ?? "").slice(0, 8);
@@ -3137,6 +3168,12 @@ async function emitMeshWelcome(server, mcpLog) {
3137
3168
  peer_count: peerCount,
3138
3169
  unread_count: inboxItems.length
3139
3170
  });
3171
+ if (inboxItems.length > 0) {
3172
+ const ids = inboxItems.map((it) => String(it.id ?? "")).filter(Boolean);
3173
+ if (ids.length > 0) {
3174
+ daemonMarkSeen(ids, sessionToken).catch(() => {});
3175
+ }
3176
+ }
3140
3177
  } catch (err) {
3141
3178
  mcpLog("welcome_emit_failed", { err: String(err) });
3142
3179
  }
@@ -3253,4 +3290,4 @@ startMcpServer().catch((err) => {
3253
3290
  process.exit(1);
3254
3291
  });
3255
3292
 
3256
- //# debugId=E3C9A185DCECC45864756E2164756E21
3293
+ //# debugId=EC81D5CC41E4B51F64756E2164756E21