The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(oauth): Qwen OAuth status card shows the token expiry
alt-glitch57d7a15c2810
diff --git a/hermes_cli/web_routers/oauth.py b/hermes_cli/web_routers/oauth.pyindex ba2b0b63bf9..da500c2eba2 100644--- a/hermes_cli/web_routers/oauth.py+++ b/hermes_cli/web_routers/oauth.py@@ -12,6 +12,7 @@ import secretsimport sysimport threadingimport time+from datetime import datetime, timezonefrom typing import Any, Callable, Dict, Optionalfrom fastapi import APIRouter, HTTPException, Request@@ -328,6 +329,11 @@ def _status_card(return card+def _epoch_ms_to_iso(value: Any) -> Optional[str]:+ """Epoch ms (Qwen CLI ``expiry_date``) -> the aware ISO string the other cards send."""+ return datetime.fromtimestamp(value / 1000, tz=timezone.utc).isoformat() if value else None++# Hand-written status cards per provider id: (hauth getter name, raw -> card).# Providers absent here fall through to the slug-driven ``get_auth_status``.# nous: refresh-free local snapshot so listing providers never performs an OAuth@@ -343,8 +349,8 @@ _PROVIDER_STATUS: Dict[str, tuple[str, Callable[[dict], dict]]] = {_truncate_token(r.get("api_key")), None, False, r.get("last_refresh"),)),"qwen-oauth": ("get_qwen_auth_status", lambda r: _status_card(- r, "qwen_cli", r.get("auth_store_path") or "Qwen CLI",- _truncate_token(r.get("access_token")), r.get("expires_at"), bool(r.get("has_refresh_token")),+ r, "qwen_cli", r.get("auth_file") or "Qwen CLI",+ _truncate_token(r.get("api_key")), _epoch_ms_to_iso(r.get("expires_at_ms")), bool(r.get("has_refresh_token")),)),"minimax-oauth": ("get_minimax_oauth_auth_status", lambda r: _status_card(r, "minimax_oauth", f"MiniMax ({r.get('region', 'global')})", None, r.get("expires_at"), True,diff --git a/tests/hermes_cli/test_web_oauth_dispatch.py b/tests/hermes_cli/test_web_oauth_dispatch.pyindex 36f800d5033..ad7191cab60 100644--- a/tests/hermes_cli/test_web_oauth_dispatch.py+++ b/tests/hermes_cli/test_web_oauth_dispatch.py@@ -704,5 +704,27 @@ def test_status_falls_through_to_generic_dispatcher_for_catalog_only_provider():assert out["has_refresh_token"] is True+def test_qwen_status_card_carries_the_getter_expiry_token_and_auth_file():+ """The Qwen card reads the keys get_qwen_auth_status actually returns."""+ from datetime import datetime++ expires_at_ms = 1_790_541_000_123+ qwen_status = {+ "logged_in": True, "auth_file": "/home/u/.qwen/oauth_creds.json", "source": "qwen-cli",+ "api_key": "qwen-access-token-secret-xyz", "expires_at_ms": expires_at_ms,+ }+ with patch("hermes_cli.auth.get_qwen_auth_status", return_value=qwen_status):+ out = _rt_oauth._resolve_provider_status("qwen-oauth", None)++ assert out["logged_in"] is True+ # Same wire shape as the other cards: an ISO string with an offset, same instant.+ assert isinstance(out["expires_at"], str)+ expires_at = datetime.fromisoformat(out["expires_at"])+ assert expires_at.tzinfo is not None+ assert round(expires_at.timestamp() * 1000) == expires_at_ms+ assert out["source_label"] == "/home/u/.qwen/oauth_creds.json"+ assert out["token_preview"] and "qwen-access-token-secret-xyz" not in out["token_preview"]++