Skip to content

Task scheduler and heartbeat for autonomous operation - #2

Merged
melvincarvalho merged 1 commit into
mainfrom
issue-1-scheduler-heartbeat
Jun 10, 2026
Merged

melvincarvalho merged 1 commit into
mainfrom
issue-1-scheduler-heartbeat

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

Closes #1

What

Phase 1 of openclaw parity — completes the half-built schedule_task loop and adds the heartbeat that turns jsclaw agents from reactive into autonomous. All zero-dependency, pure JS ESM.

New modules

Module Purpose
src/cron.js 5-field cron parser: lists, ranges, steps, named months/days, standard dom/dow OR semantics
src/task-store.js JSON file persistence with atomic writes + per-group current_tasks.json snapshots (makes the list_tasks MCP tool work); createTaskIpcHandler wires the four task MCP tools into the store with main-vs-group authorization
src/task-scheduler.js Polls due tasks, executes via consumer-provided runner, no double-firing, reschedules cron/interval, completes one-shots
src/heartbeat.js Wakes each group's agent on an interval with its HEARTBEAT.md tasks; HEARTBEAT_OK replies suppressed; quiet hours (handles midnight crossing); triggerNow()

Verified

  • 20 cron assertions: ranges, steps, named days, first-of-month, dom/dow OR rule, Feb 29 → 2028
  • Integration test: store persistence across instances, snapshot writing, IPC authorization (non-main denied cross-group cancel), once-task runs exactly once then completes, interval task repeats, HEARTBEAT_OK suppression, alert delivery, quiet hours

Version bumped to 0.0.2.

Completes the schedule_task MCP loop and adds openclaw-style heartbeat:

- src/cron.js: zero-dep 5-field cron parser (lists, ranges, steps,
  named months/days, dom/dow OR semantics, leap-year aware)
- src/task-store.js: JSON file-backed task persistence with atomic
  writes; writes current_tasks.json snapshots into group folders so
  the list_tasks MCP tool works inside containers; createTaskIpcHandler
  wires schedule/pause/resume/cancel_task IPC into the store with
  main-vs-group authorization
- src/task-scheduler.js: polls due tasks, runs them concurrently
  without double-firing, reschedules (cron/interval) or completes (once)
- src/heartbeat.js: periodic wake reading HEARTBEAT.md per group,
  HEARTBEAT_OK suppression, quiet hours (midnight-crossing), triggerNow

Config: schedulerPollInterval (60s), heartbeatInterval (30min) +
JSCLAW_SCHEDULER_POLL_INTERVAL / JSCLAW_HEARTBEAT_INTERVAL env vars.

Bumps version to 0.0.2.

Closes #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add task scheduler and heartbeat for autonomous operation

1 participant