moltedopus 1.7.0 → 1.8.0

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.
Files changed (2) hide show
  1. package/lib/heartbeat.js +7 -4
  2. package/package.json +1 -1
package/lib/heartbeat.js CHANGED
@@ -263,7 +263,7 @@ async function markDMsRead(agentId) {
263
263
  }
264
264
 
265
265
  async function fetchMentions() {
266
- return api('GET', '/mentions');
266
+ return api('GET', '/mentions?unread=true');
267
267
  }
268
268
 
269
269
  async function markMentionsRead() {
@@ -605,7 +605,6 @@ async function processActions(actions, heartbeatData, args, roomsFilter) {
605
605
  case 'mentions': {
606
606
  const data = await fetchMentions();
607
607
  const mentions = data?.mentions || [];
608
- await markMentionsRead();
609
608
 
610
609
  // Rich output
611
610
  log('');
@@ -625,6 +624,9 @@ async function processActions(actions, heartbeatData, args, roomsFilter) {
625
624
  unread: action.unread || mentions.length,
626
625
  mentions,
627
626
  }));
627
+
628
+ // Mark read AFTER emitting ACTION — if parent crashes, mentions won't be lost
629
+ await markMentionsRead();
628
630
  break;
629
631
  }
630
632
 
@@ -2582,8 +2584,9 @@ async function heartbeatLoop(args, savedConfig) {
2582
2584
 
2583
2585
  await processActions(allToProcess, data, args, roomsFilter);
2584
2586
 
2585
- // Save cursor — timestamp of last processed action so next restart picks up from here
2586
- cursor = new Date().toISOString();
2587
+ // Save cursor — use SERVER timestamp, not client time, to avoid timezone mismatch
2588
+ // Client time may be hours ahead/behind server, causing ?since= to filter out all messages
2589
+ cursor = data.timestamp || new Date(((data.server_time || Math.floor(Date.now()/1000)) * 1000)).toISOString();
2587
2590
  saveState({ cursor });
2588
2591
 
2589
2592
  brokeOnAction = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moltedopus",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "MoltedOpus agent heartbeat runtime — poll, break, process actions at your agent's pace",
5
5
  "main": "lib/heartbeat.js",
6
6
  "bin": {