moltedopus 1.5.1 → 1.5.2

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 +8 -7
  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.5.0';
58
+ const VERSION = '1.5.2';
59
59
 
60
60
  // ============================================================
61
61
  // IMPORTS (zero dependencies — Node.js built-ins only)
@@ -200,11 +200,12 @@ async function api(method, endpoint, body = null) {
200
200
  try { data = JSON.parse(text); } catch { data = { raw: text }; }
201
201
 
202
202
  if (res.status === 429) {
203
- const wait = data.retry_after || 10;
203
+ const wait = data.retry_after || 5;
204
204
  const recInterval = data.recommended_interval || 0;
205
205
  log(`RATE LIMITED: ${data.message || data.error || 'Too fast'}. Waiting ${wait}s...`);
206
206
  await sleep(wait * 1000);
207
- return { _rate_limited: true, _recommended_interval: recInterval };
207
+ // Return recommended interval caller should ADOPT it (not just increase)
208
+ return { _rate_limited: true, _recommended_interval: recInterval, _already_waited: true };
208
209
  }
209
210
  if (res.status === 401) {
210
211
  log(`AUTH ERROR: ${data.error || 'Invalid or expired token'}`);
@@ -2105,12 +2106,12 @@ async function heartbeatLoop(args, savedConfig) {
2105
2106
  continue;
2106
2107
  }
2107
2108
  if (data._rate_limited) {
2108
- // Adopt server-recommended interval if provided
2109
- if (data._recommended_interval && data._recommended_interval * 1000 > interval) {
2109
+ // ALWAYS adopt server-recommended interval (fix: don't only increase, also decrease)
2110
+ if (data._recommended_interval && data._recommended_interval > 0) {
2110
2111
  interval = data._recommended_interval * 1000;
2111
2112
  }
2112
- // Wait full interval before retrying (retry_after sleep already happened in apiCall)
2113
- await sleep(interval);
2113
+ // Already waited retry_after in api() just continue to next cycle
2114
+ // (the normal sleep at bottom of loop handles the interval)
2114
2115
  continue;
2115
2116
  }
2116
2117
  retries = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moltedopus",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
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": {