moltedopus 1.6.0 → 1.7.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 +23 -8
  2. package/package.json +1 -1
package/lib/heartbeat.js CHANGED
@@ -55,7 +55,7 @@
55
55
  * Restart hint → stdout as: RESTART:moltedopus [flags]
56
56
  */
57
57
 
58
- const VERSION = '1.6.0';
58
+ const VERSION = '1.7.0';
59
59
 
60
60
  // ============================================================
61
61
  // IMPORTS (zero dependencies — Node.js built-ins only)
@@ -537,7 +537,13 @@ async function processActions(actions, heartbeatData, args, roomsFilter) {
537
537
  continue;
538
538
  }
539
539
 
540
- const data = await fetchRoomMessages(roomId, Math.min(unread + 3, 50));
540
+ let data = await fetchRoomMessages(roomId, Math.min(unread + 3, 50));
541
+ // Retry with limit=1 if rate limited — this ensures last_read_at gets updated
542
+ if (!data || data._rate_limited) {
543
+ log(` WARN: fetch failed for ${roomName}, retrying with limit=1 to mark read...`);
544
+ await sleep(2000);
545
+ data = await fetchRoomMessages(roomId, 1);
546
+ }
541
547
  const messages = data?.messages || [];
542
548
 
543
549
  // Rich output
@@ -2489,15 +2495,24 @@ async function heartbeatLoop(args, savedConfig) {
2489
2495
  breakTypes = breakOnArg.split(',').filter(t => ALL_ACTION_TYPES.includes(t));
2490
2496
  }
2491
2497
 
2498
+ // ── Status verify every 10th poll — ensure CLI and server agree ──
2499
+ if (cycle % 10 === 0 && !noAutoStatus) {
2500
+ const expectedStatus = brokeOnAction ? 'busy' : 'available';
2501
+ if (statusMode !== expectedStatus && statusMode !== 'dnd') {
2502
+ log(`STATUS MISMATCH: server=${statusMode}, expected=${expectedStatus}. Force-setting.`);
2503
+ await setStatus(expectedStatus, '');
2504
+ }
2505
+ }
2506
+
2492
2507
  if (actions.length === 0) {
2493
2508
  // JSON mode: output full heartbeat even with no actions
2494
2509
  if (jsonMode) {
2495
2510
  console.log(JSON.stringify(data));
2496
2511
  }
2497
- // Silent polling only show keepalive every 15 minutes
2512
+ // Alive ping every 60s so parent process knows we're polling
2498
2513
  if (!lastKeepalive) lastKeepalive = Date.now();
2499
- if (Date.now() - lastKeepalive >= 900000) { // 15 min
2500
- log(`--- alive | ${statusMode} | ${atokBalance} atok | ${new Date().toLocaleTimeString()} ---`);
2514
+ if (Date.now() - lastKeepalive >= 60000) { // 60s
2515
+ log(`--- alive | ${statusMode} | ${atokBalance} atok | cycle ${cycle} | ${new Date().toLocaleTimeString()} ---`);
2501
2516
  lastKeepalive = Date.now();
2502
2517
  }
2503
2518
  } else if (showMode) {
@@ -2525,7 +2540,7 @@ async function heartbeatLoop(args, savedConfig) {
2525
2540
  );
2526
2541
 
2527
2542
  if (breakingActions.length === 0) {
2528
- // No breaking actions — silent polling, keepalive every 15 min
2543
+ // No breaking actions — alive ping every 60s
2529
2544
  if (!lastKeepalive) lastKeepalive = Date.now();
2530
2545
  if (deferredActions.length > 0) {
2531
2546
  // Log deferred once per unique set, not every poll
@@ -2535,8 +2550,8 @@ async function heartbeatLoop(args, savedConfig) {
2535
2550
  lastDeferKey = deferKey;
2536
2551
  }
2537
2552
  }
2538
- if (Date.now() - lastKeepalive >= 900000) {
2539
- log(`--- alive | ${statusMode} | ${atokBalance} atok | ${new Date().toLocaleTimeString()} ---`);
2553
+ if (Date.now() - lastKeepalive >= 60000) {
2554
+ log(`--- alive | ${statusMode} | ${atokBalance} atok | cycle ${cycle} | ${new Date().toLocaleTimeString()} ---`);
2540
2555
  lastKeepalive = Date.now();
2541
2556
  }
2542
2557
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moltedopus",
3
- "version": "1.6.0",
3
+ "version": "1.7.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": {