diff --git a/hermes_control.py b/hermes_control.py index 0917ed6..8deb727 100644 --- a/hermes_control.py +++ b/hermes_control.py @@ -127,9 +127,34 @@ def agent_status() -> dict: return _cached("agent", _load) +def _parse_cron(text: str) -> list[dict]: + """`hermes cron list` parsen. Format pro Job (KEINE Rich-Tabelle): + + 7ac183295470 [active] + Name: Memory-Kurator + Schedule: 0 4 * * 0 + Next run: 2026-06-28T04:00:00+00:00 + Deliver: local + """ + jobs: list[dict] = [] + cur: dict | None = None + for ln in text.splitlines(): + m = re.match(r"\s*([0-9a-fA-F]{6,})\s+\[(\w+)\]\s*$", ln) + if m: + cur = {"id": m.group(1), "status": m.group(2)} + jobs.append(cur) + continue + if cur is not None: + kv = re.match(r"\s+([A-Za-z][\w ]*?):\s+(.+?)\s*$", ln) + if kv: + key = kv.group(1).strip().lower().replace(" ", "_") + cur[key] = kv.group(2).strip() + return jobs + + def cron_jobs() -> list[dict]: """Geplante Jobs (inkl. pausierter).""" - return _cached("cron", lambda: _parse_rich_table(_run_cli(["cron", "list", "--all"]))) # type: ignore[return-value] + return _cached("cron", lambda: _parse_cron(_run_cli(["cron", "list", "--all"]))) # type: ignore[return-value] def skills() -> list[dict]: