openclaw-matrix-multiaccounts/src
Roshan Singh 91c870a0c4 fix(cron): wait for heartbeat to complete when wakeMode is "now"
Fixes #652

When cron jobs with sessionTarget:"main" have wakeMode:"now",
they were being marked as completed immediately without waiting for the
agent to actually process the system event.

The issue was that requestHeartbeatNow() is fire-and-forget and
doesn't wait for the heartbeat to complete. The job would finish
with durationMs: 0 before the agent had a chance to run.

This fix:
- Adds runHeartbeatOnce to CronServiceDeps
- Wires it up in gateway/server.ts to load config and pass runtime
- Modifies executeJob() to call runHeartbeatOnce when wakeMode:"now"
- Waits for heartbeat to complete and maps status to cron result:
  * "ran" → "ok"
  * "skipped" → "skipped"
  * "failed" → "error"
- Falls back to old behavior for wakeMode:"next-heartbeat" or if
  runHeartbeatOnce is not available (backward compatibility)

Benefits:
- Jobs now have accurate durationMs reflecting actual processing time
- Jobs are correctly marked with "error" status if heartbeat fails
- Prevents race condition where job completes before agent runs

[AI-assisted] - Generated with z.ai GLM-4.7
[Tested: Lightly tested - Logic validated with test scenarios, code quality checks passed, integration testing requires live Clawdbot instance]
2026-01-10 18:31:35 +01:00
..
agents fix(opencode-zen): keep legacy aliases + rationale (#669) (thanks @magimetal) 2026-01-10 18:25:43 +01:00
auto-reply fix: telegram draft chunking defaults (#667) (thanks @rubyrunsstuff) 2026-01-10 18:30:06 +01:00
browser feat: auto-start sandbox browser 2026-01-10 02:06:21 +00:00
canvas-host Tests: stabilize file watchers 2026-01-09 11:06:39 +01:00
cli fix(pairing): accept positional provider args 2026-01-10 16:36:43 +01:00
commands feat: wizard model picker (#611, thanks @jonasjancarik) 2026-01-10 16:32:59 +00:00
config fix: telegram draft chunking defaults (#667) (thanks @rubyrunsstuff) 2026-01-10 18:30:06 +01:00
cron fix(cron): wait for heartbeat to complete when wakeMode is "now" 2026-01-10 18:31:35 +01:00
daemon feat(cli): colorize gateway health + daemon output 2026-01-10 03:01:27 +01:00
discord Discord: include forwarded message snapshots 2026-01-10 18:23:30 +01:00
docs docs(commands): document /usage slash command 2026-01-09 17:18:01 +01:00
gateway fix(cron): wait for heartbeat to complete when wakeMode is "now" 2026-01-10 18:31:35 +01:00
hooks fix(ci): stabilize windows tests 2026-01-08 03:54:35 +00:00
imessage feat(agent): add human-like delay between block replies 2026-01-10 17:12:50 +01:00
infra fix: use resolveStateDir() for node-pairing and voicewake storage 2026-01-10 17:55:30 +01:00
logging test: update google-shared expectations 2026-01-09 03:04:16 +01:00
macos fix: bundle node runtime for mac app 2026-01-10 15:28:37 +01:00
markdown fix: make forced block chunking fence-safe 2026-01-09 21:52:47 +00:00
media fix: relax fetch typing for Bun 2026-01-10 04:01:06 +01:00
msteams feat(agent): add human-like delay between block replies 2026-01-10 17:12:50 +01:00
pairing fix(pairing): accept positional provider args 2026-01-10 16:36:43 +01:00
process chore: rename project to clawdbot 2026-01-04 14:38:51 +00:00
providers fix(gateway): harden agent provider routing 2026-01-09 23:00:36 +01:00
routing refactor: normalize main session key handling 2026-01-09 22:30:15 +01:00
sessions fix: centralize verbose overrides and tool stream gating 2026-01-10 00:52:24 +01:00
signal feat(agent): add human-like delay between block replies 2026-01-10 17:12:50 +01:00
slack feat(agent): add human-like delay between block replies 2026-01-10 17:12:50 +01:00
telegram fix: telegram draft chunking defaults (#667) (thanks @rubyrunsstuff) 2026-01-10 18:30:06 +01:00
terminal feat(cli): improve gateway status output 2026-01-09 09:27:42 +01:00
tui feat: improve tui status output 2026-01-10 04:07:15 +01:00
types feat: add slack multi-account routing 2026-01-08 08:49:16 +01:00
utils refactor: unify inline directives and media fetch 2026-01-10 03:01:04 +01:00
web fix(auto-reply): RawBody commands + locked session updates (#643) 2026-01-10 17:32:31 +01:00
whatsapp refactor: centralize WhatsApp target normalization 2026-01-10 02:39:52 +01:00
wizard fix: skip model picker when auth choice preset 2026-01-10 16:32:59 +00:00
entry.ts feat(cli): improve gateway status output 2026-01-09 09:27:42 +01:00
globals.test.ts chore: format to 2-space and bump changelog 2025-11-26 00:53:53 +01:00
globals.ts feat: refresh CLI output styling and progress 2026-01-08 05:20:39 +01:00
index.test.ts fix: preserve whatsapp group JIDs 2025-12-23 03:05:59 +01:00
index.ts refactor: centralize unhandled rejection setup 2026-01-07 20:59:49 +00:00
logger.test.ts style: format tests and helpers 2026-01-04 14:57:57 +00:00
logger.ts fix(logging): decouple file logs from console verbose 2026-01-03 12:32:14 +00:00
logging.ts fix: avoid Windows runner unicode crash (#567) 2026-01-09 15:19:49 +01:00
polls.test.ts feat: unify poll support 2026-01-06 04:51:05 +00:00
polls.ts feat: unify poll support 2026-01-06 04:51:05 +00:00
provider-web.barrel.test.ts build: add local node bin to restart script PATH 2025-12-07 19:01:14 +01:00
provider-web.ts feat: unify gateway heartbeat 2025-12-26 02:35:40 +01:00
runtime.ts chore: format to 2-space and bump changelog 2025-11-26 00:53:53 +01:00
utils.test.ts refactor: centralize WhatsApp target normalization 2026-01-10 02:39:52 +01:00
utils.ts refactor: centralize WhatsApp target normalization 2026-01-10 02:39:52 +01:00
version.ts chore: rename project to clawdbot 2026-01-04 14:38:51 +00:00