/ acp_adapter / auth.py
auth.py
1 """ACP auth helpers — detect the currently configured Hermes provider.""" 2 3 from __future__ import annotations 4 5 from typing import Optional 6 7 8 def detect_provider() -> Optional[str]: 9 """Resolve the active Hermes runtime provider, or None if unavailable.""" 10 try: 11 from hermes_cli.runtime_provider import resolve_runtime_provider 12 runtime = resolve_runtime_provider() 13 api_key = runtime.get("api_key") 14 provider = runtime.get("provider") 15 if isinstance(api_key, str) and api_key.strip() and isinstance(provider, str) and provider.strip(): 16 return provider.strip().lower() 17 except Exception: 18 return None 19 return None 20 21 22 def has_provider() -> bool: 23 """Return True if Hermes can resolve any runtime provider credentials.""" 24 return detect_provider() is not None