The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(hermes_cli/web_routers): AST-neutral bracket packing (oauth/memory_providers/config_env/actions/audio)
Teknium9912d34a3fa4
diff --git a/hermes_cli/web_routers/actions.py b/hermes_cli/web_routers/actions.pyindex 01b28805a50..cd7c751236f 100644--- a/hermes_cli/web_routers/actions.py+++ b/hermes_cli/web_routers/actions.py@@ -184,9 +184,7 @@ async def gateway_drain(request: Request):force-override is ``POST /api/gateway/restart``, which supersedes a drain."""from gateway.drain_control import (- clear_drain_request,- drain_requested,- write_drain_request,+ clear_drain_request, drain_requested, write_drain_request,)try:@@ -263,8 +261,7 @@ async def update_hermes():# Shared admission gate: marker-first, then the docker/nix/apt heuristics —# one decision with the CLI paths.from hermes_cli.update_contract import (- evaluate_update_admission,- record_refusal_receipt,+ evaluate_update_admission, record_refusal_receipt,)refusal = evaluate_update_admission(_project_root())@@ -552,7 +549,6 @@ async def get_update_receipt():receipt = _read_latest_receipt()if not receipt:raise HTTPException(- status_code=404,- detail="No update receipt found (no `hermes update` run recorded).",+ status_code=404, detail="No update receipt found (no `hermes update` run recorded).",)return {"receipt": receipt, "summary": _latest_update_receipt_summary()}diff --git a/hermes_cli/web_routers/audio.py b/hermes_cli/web_routers/audio.pyindex 1041cabb00b..d27793f4045 100644--- a/hermes_cli/web_routers/audio.py+++ b/hermes_cli/web_routers/audio.py@@ -119,8 +119,7 @@ async def transcribe_audio_upload(try:with http_failure("Desktop voice transcription failed", 500, "Transcription failed"):with tempfile.NamedTemporaryFile(- prefix="hermes-desktop-voice-",- suffix=_audio_extension_for_mime(mime_type),+ prefix="hermes-desktop-voice-", suffix=_audio_extension_for_mime(mime_type),delete=False,) as tmp:tmp.write(audio_bytes)@@ -296,8 +295,7 @@ async def speak_text(payload: TTSSpeakRequest, profile: Optional[str] = None):if not result.get("success"):raise HTTPException(- status_code=400,- detail=result.get("error") or "Speech synthesis failed",+ status_code=400, detail=result.get("error") or "Speech synthesis failed",)file_path = result.get("file_path")diff --git a/hermes_cli/web_routers/config_env.py b/hermes_cli/web_routers/config_env.pyindex ac0522003fd..1cc926329d3 100644--- a/hermes_cli/web_routers/config_env.py+++ b/hermes_cli/web_routers/config_env.py@@ -210,20 +210,15 @@ def _catalog_provider_env_metadata() -> dict:for aws_var in ("AWS_REGION", "AWS_PROFILE"):existing = meta.get(aws_var, {})meta[aws_var] = _provider_card(- d,- existing.get("description") or f"{d.label} ({aws_var})",- existing.get("url"),- is_password=False,- advanced=existing.get("advanced", True),+ d, existing.get("description") or f"{d.label} ({aws_var})", existing.get("url"),+ is_password=False, advanced=existing.get("advanced", True),)if d.auth_type == "vertex":existing = meta.get("VERTEX_CREDENTIALS_PATH", {})meta["VERTEX_CREDENTIALS_PATH"] = _provider_card(d,existing.get("description") or f"{d.label} — service account JSON path (or use ADC)",- existing.get("url"),- is_password=False,- advanced=existing.get("advanced", True),+ existing.get("url"), is_password=False, advanced=existing.get("advanced", True),)return metadiff --git a/hermes_cli/web_routers/memory_providers.py b/hermes_cli/web_routers/memory_providers.pyindex 364e15243ae..05cebdd0665 100644--- a/hermes_cli/web_routers/memory_providers.py+++ b/hermes_cli/web_routers/memory_providers.py@@ -294,13 +294,8 @@ def _write_provider_honcho(provider: ProviderConfigSchema, values: Dict[str, strdef _command_result(- *,- kind: str,- name: str,- status: str,- command: str = "",- completed: Optional[subprocess.CompletedProcess] = None,- error: Optional[str] = None,+ *, kind: str, name: str, status: str, command: str = "",+ completed: Optional[subprocess.CompletedProcess] = None, error: Optional[str] = None,) -> Dict[str, Any]:return {"kind": kind,@@ -428,9 +423,7 @@ def _install_memory_provider_pip_dependencies(dependencies: List[str]) -> List[Dstatus="installed" if outcome.ok else "failed",command=outcome.command,completed=subprocess.CompletedProcess(- args=outcome.command,- returncode=0 if outcome.ok else 1,- stdout=outcome.stdout,+ args=outcome.command, returncode=0 if outcome.ok else 1, stdout=outcome.stdout,stderr=outcome.stderr,),)@@ -472,11 +465,9 @@ def _install_memory_provider_external_dependencies(results.append(_command_result(- kind="external_install",- name=name,+ kind="external_install", name=name,status="installed" if install.returncode == 0 else "failed",- command=install_cmd,- completed=install,+ command=install_cmd, completed=install,))@@ -605,9 +596,7 @@ def _save_memory_provider_native_config(name: str, provider: Any, values: Dict[sdef _write_memory_provider_config_values(- name: str,- provider: Any,- values: Dict[str, Any],+ name: str, provider: Any, values: Dict[str, Any],) -> None:existing = _read_memory_provider_existing_values(name)fields = _normalize_memory_provider_schema(name, provider)diff --git a/hermes_cli/web_routers/oauth.py b/hermes_cli/web_routers/oauth.pyindex d7ca891fc94..405f4d8e1dc 100644--- a/hermes_cli/web_routers/oauth.py+++ b/hermes_cli/web_routers/oauth.py@@ -84,9 +84,7 @@ def _codex_device_code_start_error(resp: Any) -> str:def _new_oauth_session(- provider_id: str,- flow: str,- profile: Optional[str] = None,+ provider_id: str, flow: str, profile: Optional[str] = None,) -> tuple[str, Dict[str, Any]]:"""Create + register a new OAuth session, return (session_id, session_dict)."""sid = secrets.token_urlsafe(16)@@ -368,12 +366,9 @@ async def _start_nous_device_code(profile: Optional[str]) -> Dict[str, Any]:device_data, effective_scope = await asyncio.get_running_loop().run_in_executor(None, _do_nous_device_request)sid, sess = _new_oauth_session("nous", "device_code", profile=profile)sess.update(- device_code=str(device_data["device_code"]),- interval=int(device_data["interval"]),- expires_at=time.time() + int(device_data["expires_in"]),- portal_base_url=portal_base_url,- client_id=client_id,- scope=effective_scope,+ device_code=str(device_data["device_code"]), interval=int(device_data["interval"]),+ expires_at=time.time() + int(device_data["expires_in"]), portal_base_url=portal_base_url,+ client_id=client_id, scope=effective_scope,)_start_poller(_nous_poller, sid)return {@@ -440,12 +435,8 @@ async def _start_minimax_device_code(profile: Optional[str]) -> Dict[str, Any]:interval_raw = device_data.get("interval")sess.update(interval_ms=int(interval_raw) if interval_raw is not None else None,- user_code=str(device_data["user_code"]),- code_verifier=verifier,- state=state,- portal_base_url=portal_base_url,- client_id=MINIMAX_OAUTH_CLIENT_ID,- region="global",+ user_code=str(device_data["user_code"]), code_verifier=verifier, state=state,+ portal_base_url=portal_base_url, client_id=MINIMAX_OAUTH_CLIENT_ID, region="global",)# `expired_in` is overloaded — a unix-ms timestamp OR seconds-from-now.# Mirror the heuristic in _minimax_poll_token; keep the raw value for the@@ -481,8 +472,7 @@ async def _start_xai_device_code(profile: Optional[str]) -> Dict[str, Any]:device_data = await asyncio.get_running_loop().run_in_executor(None, _do_xai_device_request)sid, sess = _new_oauth_session("xai-oauth", "device_code", profile=profile)sess.update(- device_code=str(device_data["device_code"]),- interval=int(device_data["interval"]),+ device_code=str(device_data["device_code"]), interval=int(device_data["interval"]),expires_at=time.time() + int(device_data["expires_in"]),)_start_poller(_xai_device_poller, sid)@@ -505,8 +495,7 @@ _DEVICE_CODE_STARTERS = {async def _start_device_code_flow(- provider_id: str,- profile: Optional[str] = None,+ provider_id: str, profile: Optional[str] = None,) -> Dict[str, Any]:"""Initiate a device-code flow (Nous, OpenAI Codex, MiniMax, or xAI).@@ -640,9 +629,7 @@ def _reject_if_not_disconnectable(provider: Dict[str, Any], status: Dict[str, An@router.delete("/api/providers/oauth/{provider_id}")async def disconnect_oauth_provider(- provider_id: str,- request: Request,- profile: Optional[str] = None,+ provider_id: str, request: Request, profile: Optional[str] = None,):"""Disconnect an OAuth provider. Token-protected (matches /env/reveal)."""_require_token(request)@@ -732,9 +719,7 @@ def _validate_oauth_profile(profile: Optional[str]) -> None:@router.post("/api/providers/oauth/{provider_id}/start")async def start_oauth_login(- provider_id: str,- request: Request,- profile: Optional[str] = None,+ provider_id: str, request: Request, profile: Optional[str] = None,):"""Initiate an OAuth login flow. Token-protected."""_require_token(request)@@ -761,10 +746,7 @@ async def start_oauth_login(@router.post("/api/providers/oauth/{provider_id}/submit")async def submit_oauth_code(- provider_id: str,- body: OAuthSubmitBody,- request: Request,- profile: Optional[str] = None,+ provider_id: str, body: OAuthSubmitBody, request: Request, profile: Optional[str] = None,):"""Submit the auth code for PKCE flows. Token-protected."""_require_token(request)@@ -773,9 +755,7 @@ async def submit_oauth_code(@router.get("/api/providers/oauth/{provider_id}/poll/{session_id}")async def poll_oauth_session(- provider_id: str,- session_id: str,- profile: Optional[str] = None,+ provider_id: str, session_id: str, profile: Optional[str] = None,):"""Poll a session's status (no auth — read-only state). One endpoint servesevery device-code flow: all report progress via the worker-updated ``status``."""@@ -799,9 +779,7 @@ async def poll_oauth_session(@router.delete("/api/providers/oauth/sessions/{session_id}")async def cancel_oauth_session(- session_id: str,- request: Request,- profile: Optional[str] = None,+ session_id: str, request: Request, profile: Optional[str] = None,):"""Cancel a pending OAuth session. Token-protected.