perf(cli): check local auth.json/config before slow provider registry sweep
_has_any_provider_configured() probed every api_key provider (gh subprocess for copilot alone takes 5s; full sweep ~18s) before consulting auth.json and config.yaml, which are instant local reads. Desktop setup.status calls blocked past the UI's timeout, causing the connect/disconnect boot loop. Reorder so cheap local checks run first. Same semantics, ~35x faster here.
This commit is contained in:
parent
5c078b987e
commit
dbafb59227
|
|
@ -1013,16 +1013,9 @@ def _has_any_provider_configured() -> bool:
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
# Check provider-specific auth fallbacks (for example, Copilot via gh auth).
|
||||
try:
|
||||
for provider_id, pconfig in PROVIDER_REGISTRY.items():
|
||||
if pconfig.auth_type != "api_key":
|
||||
continue
|
||||
status = get_auth_status(provider_id)
|
||||
if status.get("logged_in"):
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
# Cheap local checks first: auth.json and config.yaml are on-disk lookups,
|
||||
# while the PROVIDER_REGISTRY sweep below spawns subprocesses (gh) and can
|
||||
# take 15-20s — long enough that desktop setup.status calls time out.
|
||||
|
||||
# Check for Nous Portal OAuth credentials
|
||||
auth_file = get_hermes_home() / "auth.json"
|
||||
|
|
@ -1050,6 +1043,17 @@ def _has_any_provider_configured() -> bool:
|
|||
if cfg_provider or cfg_base_url or cfg_api_key:
|
||||
return True
|
||||
|
||||
# Check provider-specific auth fallbacks (for example, Copilot via gh auth).
|
||||
try:
|
||||
for provider_id, pconfig in PROVIDER_REGISTRY.items():
|
||||
if pconfig.auth_type != "api_key":
|
||||
continue
|
||||
status = get_auth_status(provider_id)
|
||||
if status.get("logged_in"):
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Check for Claude Code OAuth credentials (~/.claude/.credentials.json)
|
||||
# Only count these if Hermes has been explicitly configured — Claude Code
|
||||
# being installed doesn't mean the user wants Hermes to use their tokens.
|
||||
|
|
|
|||
Loading…
Reference in New Issue