refactor(heartbeat): config-driven checks, channel delivery, remove hardcoded values

Heartbeat system overhaul:
- Fix email/calendar checks to parse JSON output correctly
- Add per-check cooldowns and quiet hours config
- Send findings to Discord channel instead of just logging
- Auto-reindex KB when stale files detected
- Claude CLI called only if HEARTBEAT.md has extra instructions
- All settings configurable via config.json heartbeat section

Move hardcoded values to config.json:
- allowed_tools list (claude_session.py)
- Ollama URL/model (memory_search.py now reads ollama.url from config)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MoltBot Service
2026-02-14 23:46:04 +00:00
parent ad31b25af3
commit 9c1f9f94e7
6 changed files with 588 additions and 141 deletions

View File

@@ -87,12 +87,15 @@ def main():
from src.heartbeat import run_heartbeat
interval_min = hb_config.get("interval_minutes", 30)
hb_channel = hb_config.get("channel", "echo-core")
async def _heartbeat_tick() -> None:
"""Run heartbeat and log result."""
"""Run heartbeat and send findings to channel."""
try:
result = await asyncio.to_thread(run_heartbeat)
result = await asyncio.to_thread(run_heartbeat, config)
logger.info("Heartbeat: %s", result)
if result != "HEARTBEAT_OK":
await _send_to_channel(hb_channel, result)
except Exception as exc:
logger.error("Heartbeat failed: %s", exc)
@@ -105,7 +108,8 @@ def main():
max_instances=1,
)
logger.info(
"Heartbeat registered (every %d min)", interval_min
"Heartbeat registered (every %d min, channel: %s)",
interval_min, hb_channel,
)
# Telegram bot (optional — only if telegram_token exists)