From 7a0544ab57a13dc3e9819d606eae6f7466e5e498 Mon Sep 17 00:00:00 2001 From: Himess Date: Fri, 6 Mar 2026 16:52:17 +0300 Subject: [PATCH] fix: three small inconsistencies across cron, gateway, and daytona 1. cron/jobs.py: respect HERMES_HOME env var for job storage path. scheduler.py already uses os.getenv("HERMES_HOME", ...) but jobs.py hardcodes Path.home() / ".hermes", causing path mismatch when HERMES_HOME is set. 2. gateway/run.py: add Platform.HOMEASSISTANT to default_toolset_map and platform_config_key. The adapter and hermes-homeassistant toolset both exist but the mapping dicts omit it, so HomeAssistant events silently fall back to the Telegram toolset. 3. tools/environments/daytona.py: use time.monotonic() for deadline instead of float subtraction. All other backends (docker, ssh, singularity, local) use monotonic clock for timeout tracking. The accumulator pattern (deadline -= 0.2) drifts because t.join(0.2) + interrupt checks take longer than 0.2s per iteration. --- cron/jobs.py | 2 +- gateway/run.py | 2 ++ tools/environments/daytona.py | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cron/jobs.py b/cron/jobs.py index 6b9fd2754..117ccbde3 100644 --- a/cron/jobs.py +++ b/cron/jobs.py @@ -24,7 +24,7 @@ except ImportError: # Configuration # ============================================================================= -HERMES_DIR = Path.home() / ".hermes" +HERMES_DIR = Path(os.getenv("HERMES_HOME", Path.home() / ".hermes")) CRON_DIR = HERMES_DIR / "cron" JOBS_FILE = CRON_DIR / "jobs.json" OUTPUT_DIR = CRON_DIR / "output" diff --git a/gateway/run.py b/gateway/run.py index 59f74b39b..d70d24463 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -1811,6 +1811,7 @@ class GatewayRunner: Platform.DISCORD: "hermes-discord", Platform.WHATSAPP: "hermes-whatsapp", Platform.SLACK: "hermes-slack", + Platform.HOMEASSISTANT: "hermes-homeassistant", } # Try to load platform_toolsets from config @@ -1832,6 +1833,7 @@ class GatewayRunner: Platform.DISCORD: "discord", Platform.WHATSAPP: "whatsapp", Platform.SLACK: "slack", + Platform.HOMEASSISTANT: "homeassistant", }.get(source.platform, "telegram") # Use config override if present (list of toolsets), otherwise hardcoded default diff --git a/tools/environments/daytona.py b/tools/environments/daytona.py index c8df198c1..11efa7c08 100644 --- a/tools/environments/daytona.py +++ b/tools/environments/daytona.py @@ -6,6 +6,7 @@ and resumed on next creation, preserving the filesystem across sessions. """ import logging +import time import math import shlex import threading @@ -142,10 +143,9 @@ class DaytonaEnvironment(BaseEnvironment): t = threading.Thread(target=_run, daemon=True) t.start() # Wait for timeout + generous buffer for network/SDK overhead - deadline = timeout + 10 + deadline = time.monotonic() + timeout + 10 while t.is_alive(): t.join(timeout=0.2) - deadline -= 0.2 if is_interrupted(): with self._lock: try: @@ -156,7 +156,7 @@ class DaytonaEnvironment(BaseEnvironment): "output": "[Command interrupted - Daytona sandbox stopped]", "returncode": 130, } - if deadline <= 0: + if time.monotonic() > deadline: # Shell timeout didn't fire and SDK is hung — force stop with self._lock: try: