From 1af44a13c05185f86cee87f88f40e336e6c725f1 Mon Sep 17 00:00:00 2001 From: jakubkrcmar Date: Sun, 12 Apr 2026 21:11:49 +0200 Subject: [PATCH] fix(model_picker): detect mapped-provider auth-store credentials --- hermes_cli/model_switch.py | 8 ++++++++ .../test_overlay_slug_resolution.py | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/hermes_cli/model_switch.py b/hermes_cli/model_switch.py index 5864ec5d8..bfbb7ccc3 100644 --- a/hermes_cli/model_switch.py +++ b/hermes_cli/model_switch.py @@ -990,6 +990,14 @@ def list_authenticated_providers( # Check if any env var is set has_creds = any(os.environ.get(ev) for ev in env_vars) + if not has_creds: + try: + from hermes_cli.auth import _load_auth_store + store = _load_auth_store() + if store and hermes_id in store.get("credential_pool", {}): + has_creds = True + except Exception: + pass if not has_creds: continue diff --git a/tests/hermes_cli/test_overlay_slug_resolution.py b/tests/hermes_cli/test_overlay_slug_resolution.py index ccd3748fb..c87c891f9 100644 --- a/tests/hermes_cli/test_overlay_slug_resolution.py +++ b/tests/hermes_cli/test_overlay_slug_resolution.py @@ -81,3 +81,22 @@ def test_kilo_overlay_uses_hermes_slug(): kilo_mdev = next((p for p in providers if p["slug"] == "kilo"), None) assert kilo_mdev is None, "kilo slug should not appear (resolved to kilocode)" + + + +def test_mapped_provider_credential_pool_visibility(monkeypatch): + """Mapped providers should appear when credentials live only in auth-store credential_pool.""" + monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {"google-ai-studio": {"env": ["GEMINI_API_KEY"]}}) + monkeypatch.setattr("agent.models_dev.PROVIDER_TO_MODELS_DEV", {"gemini": "google-ai-studio"}) + monkeypatch.setattr( + "hermes_cli.auth._load_auth_store", + lambda: {"providers": {}, "credential_pool": {"gemini": {"token": "fake"}}}, + ) + monkeypatch.delenv("GEMINI_API_KEY", raising=False) + + providers = list_authenticated_providers(current_provider="gemini") + + gemini = next((p for p in providers if p["slug"] == "gemini"), None) + assert gemini is not None, "gemini should appear when auth-store credential_pool has creds" + assert gemini["is_current"] is True + assert gemini["total_models"] > 0