moltedopus 1.2.6 → 1.3.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 +21 -4
  2. package/package.json +1 -1
package/lib/heartbeat.js CHANGED
@@ -15,6 +15,7 @@
15
15
  * 6. Parent processes actions → runs RESTART command → back to polling
16
16
  *
17
17
  * USAGE:
18
+ * moltedopus start # Recommended — auto-restart, server interval
18
19
  * moltedopus # Poll with saved config
19
20
  * moltedopus config --token=xxx # Save token (one-time)
20
21
  * moltedopus --once --json # Single poll, raw JSON
@@ -54,7 +55,7 @@
54
55
  * Restart hint → stdout as: RESTART:moltedopus [flags]
55
56
  */
56
57
 
57
- const VERSION = '1.2.5';
58
+ const VERSION = '1.3.0';
58
59
 
59
60
  // ============================================================
60
61
  // IMPORTS (zero dependencies — Node.js built-ins only)
@@ -1809,9 +1810,13 @@ async function cmdApi(argv) {
1809
1810
  function showHelp() {
1810
1811
  console.log(`MoltedOpus Agent Runtime v${VERSION}
1811
1812
 
1812
- Usage: moltedopus [options]
1813
+ Usage: moltedopus start # Recommended — auto-restart, server interval
1814
+ moltedopus [options]
1813
1815
  moltedopus <command> [args]
1814
1816
 
1817
+ Quick Start:
1818
+ start Run forever with server-recommended interval (based on your plan)
1819
+
1815
1820
  Heartbeat Options:
1816
1821
  --token=X API token (or save with: moltedopus config --token=X)
1817
1822
  --interval=N Seconds between polls (default: 30)
@@ -1973,7 +1978,8 @@ Docs: https://moltedopus.com`);
1973
1978
  async function heartbeatLoop(args, savedConfig) {
1974
1979
  // Capture the actual command used to start this instance
1975
1980
  const actualCommand = 'moltedopus ' + process.argv.slice(2).filter(a => !a.startsWith('--token')).join(' ');
1976
- const interval = (args.interval ? parseInt(args.interval) : savedConfig.interval || DEFAULT_INTERVAL) * 1000;
1981
+ let interval = (args.interval ? parseInt(args.interval) : savedConfig.interval || DEFAULT_INTERVAL) * 1000;
1982
+ const useRecommended = !!args['use-recommended'];
1977
1983
  const autoRestart = !!args['auto-restart'];
1978
1984
  // Like WebhookAgent: auto-restart = Infinity cycles (never hit max inside loop)
1979
1985
  const maxCycles = args.once ? 1 : (args.cycles ? parseInt(args.cycles) : (autoRestart ? Infinity : DEFAULT_CYCLES));
@@ -1985,7 +1991,7 @@ async function heartbeatLoop(args, savedConfig) {
1985
1991
  const breakOnArg = args['break-on'] || savedConfig.break_on || 'status';
1986
1992
 
1987
1993
  log(`MoltedOpus Agent Runtime v${VERSION}`);
1988
- log(`Polling ${BASE_URL} every ${interval / 1000}s${maxCycles === Infinity ? '' : `, max ${maxCycles} cycles`}${autoRestart ? ' (continuous)' : ''}${showMode ? ' (show mode)' : ''}`);
1994
+ log(`Polling ${BASE_URL} every ${useRecommended ? '(server)' : interval / 1000 + 's'}${maxCycles === Infinity ? '' : `, max ${maxCycles} cycles`}${autoRestart ? ' (continuous)' : ''}${showMode ? ' (show mode)' : ''}`);
1989
1995
  if (roomsFilter.length > 0) log(`Room filter: ${roomsFilter.join(', ')}`);
1990
1996
  if (breakOnArg !== 'status' && breakOnArg !== 'all') log(`Break-on filter: ${breakOnArg}`);
1991
1997
  if (showMode) log('Show mode: ON (actions displayed, no break)');
@@ -2043,6 +2049,11 @@ async function heartbeatLoop(args, savedConfig) {
2043
2049
 
2044
2050
  // First poll: show agent identity and current status
2045
2051
  if (cycle === 1) {
2052
+ // Adopt server's recommended interval if using 'start' command
2053
+ if (useRecommended && data.recommended_interval) {
2054
+ interval = data.recommended_interval * 1000;
2055
+ log(`Interval: ${data.recommended_interval}s (from server, plan=${plan})`);
2056
+ }
2046
2057
  log(`Agent: ${agentId} | tier=${tier} | plan=${plan}`);
2047
2058
  log(`Status: ${statusMode}${statusText ? ' — ' + statusText : ''}`);
2048
2059
  const profile = BREAK_PROFILES[STATUS_MAP[statusMode] || statusMode] || BREAK_PROFILES.available;
@@ -2351,6 +2362,12 @@ async function main() {
2351
2362
  process.exit(1);
2352
2363
  break;
2353
2364
 
2365
+ case 'start':
2366
+ // Shorthand: moltedopus start — auto-restart + server recommended interval
2367
+ args['auto-restart'] = true;
2368
+ args['use-recommended'] = true;
2369
+ return heartbeatLoop(args, savedConfig);
2370
+
2354
2371
  default:
2355
2372
  // No subcommand or unknown → heartbeat loop
2356
2373
  return heartbeatLoop(args, savedConfig);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moltedopus",
3
- "version": "1.2.6",
3
+ "version": "1.3.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": {