The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(hermes_cli/web_routers): AST-neutral statement packing (actions/audio/memory_providers/config_env)
Teknium0cab29d3f474
diff --git a/hermes_cli/web_routers/actions.py b/hermes_cli/web_routers/actions.pyindex cd7c751236f..3276a7e3a74 100644--- a/hermes_cli/web_routers/actions.py+++ b/hermes_cli/web_routers/actions.py@@ -53,9 +53,7 @@ _ACTION_LOG_TAIL_MAX_BYTES = 256 * 1024_ACTION_LOG_TAIL_INITIAL_CHUNK_BYTES = 8 * 1024_ACTION_LOG_TAIL_MAX_CHUNK_BYTES = 64 * 1024-_UPDATE_ACTION_COMPLETED_RE = re.compile(- r"^=== hermes-update completed ([0-9a-f]{32}) ===$"-)+_UPDATE_ACTION_COMPLETED_RE = re.compile(r"^=== hermes-update completed ([0-9a-f]{32}) ===$")_MANAGED_EXTERNALLY_MESSAGE = ("Hermes updates are managed outside this dashboard in "@@ -158,11 +156,7 @@ async def restart_gateway(profile: Optional[str] = None):"""Kick off a ``hermes gateway restart`` in the background."""with http_failure("Failed to spawn gateway restart", 500, "Failed to restart gateway"):proc, _reused = _spawn_gateway_restart(profile)- return {- "ok": True,- "pid": proc.pid,- "name": "gateway-restart",- }+ return {"ok": True, "pid": proc.pid, "name": "gateway-restart"}@router.post("/api/gateway/drain")@@ -214,8 +208,7 @@ async def gateway_drain(request: Request):suppress_notification=bool((body or {}).get("suppress_notification", False)),)_log.info(- "Gateway drain BEGIN requested by %s (suppress_notification=%s)",- principal,+ "Gateway drain BEGIN requested by %s (suppress_notification=%s)", principal,payload["suppress_notification"],)return {@@ -287,19 +280,12 @@ async def update_hermes():action_id = secrets.token_hex(16)try:proc = _spawn_hermes_action(- ["update"],- "hermes-update",- env_overrides={"HERMES_ACTION_ID": action_id},+ ["update"], "hermes-update", env_overrides={"HERMES_ACTION_ID": action_id},)except Exception as exc:_log.exception("Failed to spawn hermes update")raise HTTPException(status_code=500, detail=f"Failed to start update: {exc}")- return {- "ok": True,- "pid": proc.pid,- "name": "hermes-update",- "action_id": action_id,- }+ return {"ok": True, "pid": proc.pid, "name": "hermes-update", "action_id": action_id}def _recent_upstream_commits(n: int = 20) -> List[Dict[str, Any]]:@@ -392,9 +378,7 @@ async def check_hermes_update(force: bool = False):payload["message"] = format_docker_update_message()return payloadif install_method == "apt":- payload["message"] = (- "Hermes is managed by Termux APT; run `pkg upgrade hermes-agent`."- )+ payload["message"] = "Hermes is managed by Termux APT; run `pkg upgrade hermes-agent`."return payload# banner.check_for_updates() handles git / nix-revision paths and cachesdiff --git a/hermes_cli/web_routers/audio.py b/hermes_cli/web_routers/audio.pyindex d27793f4045..31b4bdc44c9 100644--- a/hermes_cli/web_routers/audio.py+++ b/hermes_cli/web_routers/audio.py@@ -34,7 +34,6 @@ _ws_auth_ok = late("_ws_auth_ok")_ws_request_is_allowed = late("_ws_request_is_allowed")load_env = late("load_env")-_AUDIO_MIME_EXTENSIONS: Dict[str, str] = {"audio/aac": ".aac","audio/flac": ".flac",@@ -216,10 +215,7 @@ async def get_elevenlabs_voices(profile: Optional[str] = None):request = urllib.request.Request("https://api.elevenlabs.io/v1/voices",- headers={- "Accept": "application/json",- "xi-api-key": api_key,- },+ headers={"Accept": "application/json", "xi-api-key": api_key},)try:@@ -237,9 +233,7 @@ async def get_elevenlabs_voices(profile: Optional[str] = None):# most once until the error signature changes.if exc.code in (401, 403):if _voice_list_error_logged_once(f"http-{exc.code}"):- _log.info(- "ElevenLabs voices unavailable: %s — check ELEVENLABS_API_KEY", exc- )+ _log.info("ElevenLabs voices unavailable: %s — check ELEVENLABS_API_KEY", exc)return {"available": False, "voices": [], "error": "unauthorized"}if _voice_list_error_logged_once(f"http-{exc.code}"):_log.warning("ElevenLabs voice list failed: %s", exc)diff --git a/hermes_cli/web_routers/config_env.py b/hermes_cli/web_routers/config_env.pyindex 4996c9e0429..0d7e49b3675 100644--- a/hermes_cli/web_routers/config_env.py+++ b/hermes_cli/web_routers/config_env.py@@ -42,7 +42,6 @@ save_config = late("save_config")save_env_value = late("save_env_value")_CONFIG_MUTATION_LOCK = LateState("_CONFIG_MUTATION_LOCK")-# Simple rate limiter for the reveal endpoint_reveal_timestamps: List[float] = []_REVEAL_MAX_PER_WINDOW = 5diff --git a/hermes_cli/web_routers/memory_providers.py b/hermes_cli/web_routers/memory_providers.pyindex 7e6d016045a..b2029e12d1e 100644--- a/hermes_cli/web_routers/memory_providers.py+++ b/hermes_cli/web_routers/memory_providers.py@@ -46,7 +46,6 @@ save_env_value = late("save_env_value")_dependency_importable = late("_dependency_importable")load_env = late("load_env")-# Sentinel: remove this key so it falls back to the host or built-in default._UNSET: Any = object()@@ -491,12 +490,7 @@ def _install_memory_provider_setup(name: str) -> Dict[str, Any]:ok = all(result["status"] not in {"failed"} for result in results)statuses = {row["name"]: row for row in _discover_memory_provider_statuses()}- return {- "ok": ok,- "provider": name,- "results": results,- "status": statuses.get(name),- }+ return {"ok": ok, "provider": name, "results": results, "status": statuses.get(name)}def _public_memory_provider_field(field: Dict[str, Any], data: Dict[str, Any]) -> Dict[str, Any]: