claudemesh-cli 1.34.10 → 1.34.11

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.10", env;
107
+ var URLS, VERSION = "1.34.11", env;
108
108
  var init_urls = __esm(() => {
109
109
  URLS = {
110
110
  BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
@@ -9615,6 +9615,11 @@ function migrateInbox(db) {
9615
9615
  db.exec(`ALTER TABLE inbox ADD COLUMN seen_at INTEGER`);
9616
9616
  db.exec(`CREATE INDEX IF NOT EXISTS inbox_seen_at ON inbox(seen_at)`);
9617
9617
  }
9618
+ if (!cols.some((c) => c.name === "recipient_pubkey")) {
9619
+ db.exec(`ALTER TABLE inbox ADD COLUMN recipient_pubkey TEXT`);
9620
+ db.exec(`ALTER TABLE inbox ADD COLUMN recipient_kind TEXT`);
9621
+ db.exec(`CREATE INDEX IF NOT EXISTS inbox_recipient ON inbox(recipient_pubkey)`);
9622
+ }
9618
9623
  }
9619
9624
  function insertIfNew(db, row) {
9620
9625
  const before = db.prepare(`SELECT id FROM inbox WHERE client_message_id = ?`).get(row.client_message_id);
@@ -9623,10 +9628,11 @@ function insertIfNew(db, row) {
9623
9628
  db.prepare(`
9624
9629
  INSERT INTO inbox (
9625
9630
  id, client_message_id, broker_message_id, mesh, topic,
9626
- sender_pubkey, sender_name, body, meta, received_at, reply_to_id
9627
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
9631
+ sender_pubkey, sender_name, body, meta, received_at, reply_to_id,
9632
+ recipient_pubkey, recipient_kind
9633
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
9628
9634
  ON CONFLICT(client_message_id) DO NOTHING
9629
- `).run(row.id, row.client_message_id, row.broker_message_id, row.mesh, row.topic, row.sender_pubkey, row.sender_name, row.body, row.meta, row.received_at, row.reply_to_id);
9635
+ `).run(row.id, row.client_message_id, row.broker_message_id, row.mesh, row.topic, row.sender_pubkey, row.sender_name, row.body, row.meta, row.received_at, row.reply_to_id, row.recipient_pubkey, row.recipient_kind);
9630
9636
  const after = db.prepare(`SELECT id FROM inbox WHERE client_message_id = ?`).get(row.client_message_id);
9631
9637
  return after?.id === row.id ? row.id : null;
9632
9638
  }
@@ -9652,9 +9658,19 @@ function listInbox(db, p) {
9652
9658
  if (p.unreadOnly === true) {
9653
9659
  where.push("seen_at IS NULL");
9654
9660
  }
9661
+ if (p.recipientPubkey) {
9662
+ const ors = ["recipient_pubkey IS NULL", "recipient_pubkey = ?"];
9663
+ args.push(p.recipientPubkey);
9664
+ if (p.recipientMemberPubkey) {
9665
+ ors.push("recipient_pubkey = ?");
9666
+ args.push(p.recipientMemberPubkey);
9667
+ }
9668
+ where.push(`(${ors.join(" OR ")})`);
9669
+ }
9655
9670
  const sql = `
9656
9671
  SELECT id, client_message_id, broker_message_id, mesh, topic,
9657
- sender_pubkey, sender_name, body, meta, received_at, reply_to_id, seen_at
9672
+ sender_pubkey, sender_name, body, meta, received_at, reply_to_id, seen_at,
9673
+ recipient_pubkey, recipient_kind
9658
9674
  FROM inbox
9659
9675
  ${where.length ? "WHERE " + where.join(" AND ") : ""}
9660
9676
  ORDER BY received_at DESC
@@ -10471,12 +10487,17 @@ function makeHandler(opts) {
10471
10487
  const meshFilter = meshFromCtx(url.searchParams.get("mesh")) ?? undefined;
10472
10488
  const unreadOnly = url.searchParams.get("unread_only") === "true";
10473
10489
  const markSeen = url.searchParams.get("mark_seen") !== "false";
10490
+ const recipientPubkey = session?.presence?.sessionPubkey;
10491
+ const meshCfgForRecipient = session?.mesh ? opts.meshConfigs?.get(session.mesh) : undefined;
10492
+ const recipientMemberPubkey = meshCfgForRecipient?.pubkey;
10474
10493
  const rows = listInbox(opts.inboxDb, {
10475
10494
  since: Number.isFinite(since) ? since : undefined,
10476
10495
  topic,
10477
10496
  fromPubkey,
10478
10497
  ...meshFilter ? { mesh: meshFilter } : {},
10479
10498
  unreadOnly,
10499
+ ...recipientPubkey ? { recipientPubkey } : {},
10500
+ ...recipientMemberPubkey ? { recipientMemberPubkey } : {},
10480
10501
  limit: Number.isFinite(limit ?? NaN) ? limit : undefined
10481
10502
  });
10482
10503
  let flippedCount = 0;
@@ -10498,7 +10519,9 @@ function makeHandler(opts) {
10498
10519
  body: r.body,
10499
10520
  received_at: new Date(r.received_at).toISOString(),
10500
10521
  reply_to_id: r.reply_to_id,
10501
- seen_at: r.seen_at ? new Date(r.seen_at).toISOString() : null
10522
+ seen_at: r.seen_at ? new Date(r.seen_at).toISOString() : null,
10523
+ recipient_pubkey: r.recipient_pubkey,
10524
+ recipient_kind: r.recipient_kind
10502
10525
  })),
10503
10526
  marked_seen: flippedCount
10504
10527
  });
@@ -11874,7 +11897,9 @@ async function handleBrokerPush(msg, ctx) {
11874
11897
  body,
11875
11898
  meta: createdAt ? JSON.stringify({ created_at: createdAt }) : null,
11876
11899
  received_at: Date.now(),
11877
- reply_to_id: replyToId
11900
+ reply_to_id: replyToId,
11901
+ recipient_pubkey: ctx.recipientPubkey ?? null,
11902
+ recipient_kind: ctx.recipientKind ?? null
11878
11903
  });
11879
11904
  ctx.ackClientMessage?.(clientMessageId, brokerMessageId);
11880
11905
  if (!inserted)
@@ -21129,4 +21154,4 @@ main().catch((err) => {
21129
21154
  process.exit(EXIT.INTERNAL_ERROR);
21130
21155
  });
21131
21156
 
21132
- //# debugId=80324EA6AC54078664756E2164756E21
21157
+ //# debugId=3D8CCE13DCC94B5264756E2164756E21