The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(providers): pre-release profiles stay off discovery until signed in
Tekniumd0b2715a33f9
diff --git a/hermes_cli/auth_commands.py b/hermes_cli/auth_commands.pyindex ddf330f0af8..69ba2535be7 100644--- a/hermes_cli/auth_commands.py+++ b/hermes_cli/auth_commands.py@@ -33,8 +33,6 @@ _OAUTH_CAPABLE_PROVIDERS = {"anthropic", "nous", "openai-codex", "xai-oauth", "q_OAUTH_DEFAULT_PROVIDERS = _OAUTH_CAPABLE_PROVIDERS - {"openrouter"}# Providers whose sibling CLI login Hermes may borrow (``auth.adopt_external_logins``).EXTERNAL_LOGIN_PROVIDERS = {"anthropic", "openai-codex"}-# OAuth-only, but hidden: adding to the set above would advertise it in the interactive type prompt.-_OAUTH_ONLY_HIDDEN_PROVIDERS = {"solstice"}def _get_custom_provider_entries() -> list[dict]:@@ -83,13 +81,7 @@ def _resolve_custom_provider_input(raw: str) -> str | None:_PROVIDER_ALIASES = {"or": "openrouter", "open-router": "openrouter", "grok-oauth": "xai-oauth",- "xai-oauth": "xai-oauth", "x-ai-oauth": "xai-oauth", "xai-grok-oauth": "xai-oauth",- "solstice": "solstice",- "solstice-oauth": "solstice"}--# Pre-release OAuth providers kept OUT of PROVIDER_REGISTRY so they never surface in pickers,-# `hermes auth list`, or doctor. They remain addable by explicit name (see _is_known_provider).-_HIDDEN_OAUTH_PROVIDERS = {"solstice"}+ "xai-oauth": "xai-oauth", "x-ai-oauth": "xai-oauth", "xai-grok-oauth": "xai-oauth"}def _normalize_provider(provider: str) -> str:@@ -142,8 +134,7 @@ def _provider_base_url(provider: str) -> str:def _is_known_provider(provider: str, configured_provider: dict | None) -> bool:return (provider in PROVIDER_REGISTRY or provider == "openrouter"- or provider.startswith(CUSTOM_POOL_PREFIX) or provider in _HIDDEN_OAUTH_PROVIDERS- or configured_provider is not None)+ or provider.startswith(CUSTOM_POOL_PREFIX) or configured_provider is not None)def _unknown_provider_exit(provider: str) -> SystemExit:@@ -251,24 +242,6 @@ def _codex_pool_source(creds: dict) -> str:return SOURCE_MANUAL_DEVICE_CODE-def _solstice_login(args) -> dict:- """Run the Solstice PKCE loopback login and return its token bundle for the pool entry.-- The full OAuth handshake (NAS-brokered exchange, PKCE verifier, loopback callback) lives in- ``hermes_cli.solstice``; this only adapts its result to the ``_OAuthAddSpec`` shape.- """- from hermes_cli.solstice import SOLSTICE_INFERENCE_BASE_URL, _login_solstice-- _login_solstice(args, None)- state = auth_mod._load_provider_state(auth_mod._load_auth_store(), "solstice") or {}- tokens = state.get("tokens") if isinstance(state.get("tokens"), dict) else {}- return {- "access_token": str(tokens.get("access_token") or "").strip(),- "refresh_token": str(tokens.get("refresh_token") or "").strip(),- "base_url": SOLSTICE_INFERENCE_BASE_URL,- }--_OAUTH_ADD_SPECS: dict[str, _OAuthAddSpec] = {"anthropic": _OAuthAddSpec(login=_anthropic_oauth_login,@@ -319,13 +292,6 @@ _OAUTH_ADD_SPECS: dict[str, _OAuthAddSpec] = {source=f"{SOURCE_MANUAL}:openrouter_pkce",fields=lambda creds, provider: {"base_url": _provider_base_url(provider)},auth_type=AUTH_TYPE_API_KEY),- "solstice": _OAuthAddSpec(- login=_solstice_login,- token=lambda creds: creds["access_token"],- source=f"{SOURCE_MANUAL}:solstice_oauth",- fields=lambda creds, provider: {- "refresh_token": creds.get("refresh_token") or None,- "base_url": creds.get("base_url") or _provider_base_url(provider)}),}@@ -426,8 +392,7 @@ def auth_add_command(args) -> None:if requested_type == "api-key":requested_type = AUTH_TYPE_API_KEYelif not requested_type:- oauth_default = (provider in _OAUTH_DEFAULT_PROVIDERS- or provider in _OAUTH_ONLY_HIDDEN_PROVIDERS) and not is_custom+ oauth_default = provider in _OAUTH_DEFAULT_PROVIDERS and not is_customrequested_type = AUTH_TYPE_OAUTH if oauth_default else AUTH_TYPE_API_KEYpool = load_pool(provider)@@ -829,7 +794,8 @@ def _interactive_auth() -> None:def _pick_provider(prompt: str = "Provider") -> str:"""Prompt for a provider name with auto-complete hints."""- known = sorted(set(list(PROVIDER_REGISTRY.keys()) + ["openrouter"]))+ from providers import unlisted_provider_names+ known = sorted((set(PROVIDER_REGISTRY) - unlisted_provider_names()) | {"openrouter"})custom_display = [entry["name"] for entry in _get_custom_provider_entries()]print(f"\nKnown providers: {', '.join(known)}")if custom_display:diff --git a/hermes_cli/inventory.py b/hermes_cli/inventory.pyindex ff0dd526d98..34cbd278773 100644--- a/hermes_cli/inventory.py+++ b/hermes_cli/inventory.py@@ -692,13 +692,14 @@ def _append_unconfigured_rows("""Empty setup skeletons for canonical providers missing from ``rows`` — except the *current* one:if config.yaml still points at it but credentials are gone, keep a row carrying the saved model soGUI pickers don't silently snap to another provider."""- from hermes_cli.models import CANONICAL_PROVIDERS, _model_requires_account_discovery+ from hermes_cli.models import _model_requires_account_discovery+ from hermes_cli.models_catalog_static import listed_canonical_providersseen = {r["slug"].lower() for r in rows}cur = (ctx.current_provider or "").lower()cur_model = str(ctx.current_model or "").strip()extras: list[dict] = []- for entry in CANONICAL_PROVIDERS:+ for entry in listed_canonical_providers():if entry.slug.lower() in seen:continueif current_only and entry.slug.lower() != cur:diff --git a/hermes_cli/main_provider_setup.py b/hermes_cli/main_provider_setup.pyindex 0e11a5943bc..ac866614227 100644--- a/hermes_cli/main_provider_setup.py+++ b/hermes_cli/main_provider_setup.py@@ -895,8 +895,9 @@ def _build_provider_picker_rows(config: dict, active: str, provider_labels: dictrows have ``members == []``; saved custom providers and trailing actions stay flat. Honors``model_catalog.excluded_providers`` (slug or alias, case-insensitive) like the gateway/TUI."""from hermes_cli.models import CANONICAL_PROVIDERS, _PROVIDER_ALIASES- from hermes_cli.models_catalog_static import group_providers, provider_group_for_slug+ from hermes_cli.models_catalog_static import group_providers, listed_canonical_providers, provider_group_for_slugcanonical_descs = {p.slug: p.tui_desc for p in CANONICAL_PROVIDERS}+ listed = listed_canonical_providers()_cli_excluded = {str(p).strip().lower()for p in (config.get("model_catalog", {}) or {}).get("excluded_providers") or []@@ -906,9 +907,9 @@ def _build_provider_picker_rows(config: dict, active: str, provider_labels: dict_names_for: dict[str, set[str]] = {_p.slug: {_p.slug.lower()} for _p in CANONICAL_PROVIDERS}for _alias, _canon in _PROVIDER_ALIASES.items():_names_for.setdefault(_canon, {_canon.lower()}).add(_alias.lower())- _visible_slugs = [p.slug for p in CANONICAL_PROVIDERS if not _names_for.get(p.slug, {p.slug.lower()}) & _cli_excluded]+ _visible_slugs = [p.slug for p in listed if not _names_for.get(p.slug, {p.slug.lower()}) & _cli_excluded]else:- _visible_slugs = [p.slug for p in CANONICAL_PROVIDERS]+ _visible_slugs = [p.slug for p in listed]# The active provider's group when grouped, otherwise the active slug itself.active_group = provider_group_for_slug(active) if active else ""diff --git a/hermes_cli/models.py b/hermes_cli/models.pyindex 914e322913b..9439070d23e 100644--- a/hermes_cli/models.py+++ b/hermes_cli/models.py@@ -832,8 +832,8 @@ def _provider_has_credentials(pid: str) -> bool:def list_available_providers() -> list[dict[str, str]]:- """``{id, label, aliases, authenticated}`` for every provider usable with ``provider:model``,- derived from :data:`CANONICAL_PROVIDERS` (shared with ``hermes model`` and ``/model``)."""+ """``{id, label, aliases, authenticated}`` per listed provider (shared with ``hermes model`` / ``/model``)."""+ from hermes_cli.models_catalog_static import listed_canonical_providersaliases_for: dict[str, list[str]] = {}for alias, canonical in _PROVIDER_ALIASES.items():aliases_for.setdefault(canonical, []).append(alias)@@ -843,7 +843,7 @@ def list_available_providers() -> list[dict[str, str]]:"label": _PROVIDER_LABELS.get(pid, pid),"aliases": aliases_for.get(pid, []),"authenticated": _provider_has_credentials(pid)}- for pid in [p.slug for p in CANONICAL_PROVIDERS] + ["custom"]]+ for pid in [p.slug for p in listed_canonical_providers()] + ["custom"]]def parse_model_input(@@ -1620,25 +1620,6 @@ def _azure_foundry_catalog(normalized: str, force_refresh: bool) -> Optional[lisreturn None-def _solstice_catalog(normalized: str, force_refresh: bool) -> Optional[list[str]]:- """Curated picker list for Solstice (per-user-quota).-- The ``:generateContentPerUserQuota`` endpoint has no public model catalog to probe — a- per-user token gets 403 ACCESS_TOKEN_SCOPE_INSUFFICIENT from ``/v1alpha/models`` — so the- profile's VERIFIED ``fallback_models`` is the only safe source. Returns None when the- profile is unavailable so the generic path still runs.- """- from providers import get_provider_profile-- try:- profile = get_provider_profile("solstice")- except Exception:- return None- if profile is not None and profile.fallback_models:- return list(profile.fallback_models)- return list(_PROVIDER_MODELS.get("solstice", [])) or None--# Per-provider catalog sources tried before the generic profile fetch. A fetcher returning None# falls through to the profile/curated path; a list is returned as-is (even empty)._PROVIDER_CATALOG_FETCHERS: dict[str, Any] = {@@ -1659,9 +1640,7 @@ _PROVIDER_CATALOG_FETCHERS: dict[str, Any] = {"openai-api": _openai_catalog,"custom": _custom_catalog,"bedrock": _bedrock_catalog,- "azure-foundry": _azure_foundry_catalog,- # No live catalog: OAuth-only per-user-quota provider; curated verified ids only.- "solstice": _solstice_catalog}+ "azure-foundry": _azure_foundry_catalog}# ``-free`` slugs the relay still LISTS but no longer serves: the Go-only twin (``ox-alpha-free``)diff --git a/hermes_cli/models_catalog_static.py b/hermes_cli/models_catalog_static.pyindex 20eaba28062..1f1e41c805f 100644--- a/hermes_cli/models_catalog_static.py+++ b/hermes_cli/models_catalog_static.py@@ -375,7 +375,11 @@ _canonical_slugs = {p.slug for p in CANONICAL_PROVIDERS}def _plugin_provider_enters_picker(pp) -> bool:- """Picker admission for a plugin model-provider profile: any slug without a built-in row."""+ """Picker admission for a plugin model-provider profile: any slug without a built-in row.++ Every profile is admitted, hidden (pre-release) ones included: ``CANONICAL_PROVIDERS`` is also+ the typed-path registry (``provider:model`` parsing, labels), so a signed-in user must still be+ able to name one. The pickers that list rows filter with ``providers.provider_listed``."""return pp.name not in _canonical_slugs@@ -411,6 +415,14 @@ _PROVIDER_LABELS["custom"] = "Custom endpoint" # special case: not a named provsync_plugin_provider_catalog()+def listed_canonical_providers() -> list[ProviderEntry]:+ """``CANONICAL_PROVIDERS`` minus pre-release profiles the user has not opted into: what a provider+ LIST offers. Typed paths (``provider:model``, labels, ``--provider``) keep the full table."""+ from providers import unlisted_provider_names+ hidden = unlisted_provider_names()+ return [p for p in CANONICAL_PROVIDERS if p.slug not in hidden]++# ---------------------------------------------------------------------------# Provider groups — DISPLAY ONLY. Vendors with several slugs (global API, China API, OAuth plan,# ...) fold under one top-level row in the INTERACTIVE PICKERS (``hermes model``, setup wizard,diff --git a/hermes_cli/provider_catalog.py b/hermes_cli/provider_catalog.pyindex 07b29bd931a..7d79e7ee00a 100644--- a/hermes_cli/provider_catalog.py+++ b/hermes_cli/provider_catalog.py@@ -67,7 +67,7 @@ def provider_catalog() -> list[ProviderDescriptor]:"""One descriptor per provider in the ``hermes model`` universe (:data:`CANONICAL_PROVIDERS`,auto-extended by provider plugins). Auth/env from ``PROVIDER_REGISTRY``; display metadata from``ProviderProfile`` with canonical/env fallbacks so profile-less providers still resolve."""- from hermes_cli.models import CANONICAL_PROVIDERS+ from hermes_cli.models_catalog_static import listed_canonical_providersPROVIDER_REGISTRY = _safe_import("hermes_cli.auth", "PROVIDER_REGISTRY", {})OPTIONAL_ENV_VARS = _safe_import("hermes_cli.config", "OPTIONAL_ENV_VARS", {})# Overlays carry auth_type for providers with no registry/profile entry — notably the ``moa``@@ -79,7 +79,7 @@ def provider_catalog() -> list[ProviderDescriptor]:except Exception:profiles = {}out: list[ProviderDescriptor] = []- for order, entry in enumerate(CANONICAL_PROVIDERS):+ for order, entry in enumerate(listed_canonical_providers()):slug = entry.slugcfg = PROVIDER_REGISTRY.get(slug)prof = profiles.get(slug)diff --git a/providers/__init__.py b/providers/__init__.pyindex adf08df58b4..694086e8e58 100644--- a/providers/__init__.py+++ b/providers/__init__.py@@ -271,80 +271,27 @@ def list_providers() -> list[ProviderProfile]:_PROVIDER_LIST_CACHE = cacheresult = [p for p in _PROVIDER_LIST_CACHE if p.name not in layer.registry]result.extend({id(p): p for p in layer.registry.values()}.values())- # Hidden profiles are excluded unless their enable gate / credential check- # surfaces them; the filter runs per call so a gate flip needs no cache reset.- if any(getattr(p, "hidden", False) for p in result):- result = [p for p in result- if not getattr(p, "hidden", False) or _hidden_provider_enabled(p.name)]return result-def _hidden_provider_enabled(name: str) -> bool:- """Return True when a hidden provider should be surfaced after all.+def unlisted_provider_names() -> set[str]:+ """Registered profiles that discovery surfaces (provider pickers, setup lists, the accounts tab)+ must not offer: pre-release ones the user has not opted into.- A hidden provider stays hidden unless something explicitly enables it.- The default enable predicate is credential presence: if any of the- provider's ``env_vars`` resolves to a usable value in the environment- (or ``~/.hermes/.env``), the provider is considered enabled. Providers- can register a richer predicate via ``register_hidden_provider_gate``.-- This mirrors the house "feature registers when configured" pattern- (relay_url / proxy_url): absence = invisible + inert, presence = active.- """- try:- gate = _HIDDEN_GATES.get(name)- if gate is not None:- return bool(gate())- except Exception:- logger.debug("hidden gate %s raised; treating as disabled", name, exc_info=True)- return False-- profile = _REGISTRY.get(name)- if profile is None:- return False- try:- from hermes_cli.auth import has_usable_secret-- for var in profile.env_vars or ():- if var and has_usable_secret(_resolve_env_var(var)):- return True- except Exception:- logger.debug(- "hidden env check for %s failed; staying hidden", name, exc_info=True- )- return False---def _resolve_env_var(var: str) -> str:- """Resolve an env var using the canonical Hermes credential resolver.-- ``get_env_value_prefer_dotenv`` prefers ``~/.hermes/.env`` (honoring the- documented ``export VAR=`` forms) then falls back to ``os.environ`` — so- hidden-provider enable checks read the same source a user is told to- configure.+ Resolution never consults this: an unlisted profile still resolves, authenticates and serves+ turns by name. A raising ``listed()`` counts as unlisted, because a broken gate must never+ advertise a dark launch."""- try:- from hermes_cli.config import get_env_value_prefer_dotenv-- return get_env_value_prefer_dotenv(var) or ""- except Exception:- import os-- return os.getenv(var, "")---_HIDDEN_GATES: dict[str, Any] = {}---def register_hidden_provider_gate(name: str, predicate) -> None:- """Register a callable predicate that decides when *name* is surfaced.+ hidden: set[str] = set()+ for profile in list_providers():+ try:+ if not profile.listed():+ hidden.add(profile.name)+ except Exception:+ logger.debug("provider %s listed() raised; hiding it", profile.name, exc_info=True)+ hidden.add(profile.name)+ return hidden- ``predicate`` takes no args and returns a truthy value when the hidden- provider should appear in ``list_providers()`` output. Useful when- credential presence isn't the right signal (e.g. a config flag or a- combination of settings). Overrides the default env-var check.- """- _HIDDEN_GATES[name] = predicatedef _home_layer(*, force_stamp_check: bool = False) -> _HomeLayer:"""The layer for the home bound right now, importing plugin dirs it has not seen yet."""diff --git a/providers/base.py b/providers/base.pyindex 1d495baa9e8..9183cf3074e 100644--- a/providers/base.py+++ b/providers/base.py@@ -52,12 +52,10 @@ class ProviderProfile:description: str = "" # e.g. "GMI Cloud (multi-model direct API)" — picker subtitlesignup_url: str = "" # e.g. "https://www.gmicloud.ai/" — shown during setup- # True when the provider is pre-release / not for public listing.- # list_providers() excludes hidden profiles unless the provider's own- # enable predicate passes (see providers/__init__._hidden_provider_enabled).- # The provider still resolves by name via get_provider_profile() when the- # user configures it explicitly — hiding is about *discovery surfaces*- # (picker, setup, auth lists), not about blocking direct config.+ # True when the provider is pre-release / not for public listing. Discovery surfaces (provider+ # pickers, the setup provider list, the dashboard accounts tab) skip it unless ``listed()``+ # says otherwise; resolution by name is untouched, so an explicit ``model.provider`` /+ # ``hermes auth add <name>`` keeps working.hidden: bool = False# ── Auth & endpoints ─────────────────────────────────────@@ -313,6 +311,18 @@ class ProviderProfile:"""return None+ def listed(self) -> bool:+ """Whether discovery surfaces may offer this provider.++ Every non-``hidden`` profile is listed. A ``hidden`` (pre-release) one surfaces once the user+ opted in by name (``hermes auth add <name>`` put a row in its credential pool), so the+ pickers can then offer it. Reads auth.json only: it runs on every picker build.+ """+ if not self.hidden:+ return True+ from hermes_cli.auth import read_credential_pool # lazy: providers/ must not import hermes_cli at load+ return bool(read_credential_pool(self.name))+def create_client(self, **client_kwargs: Any) -> Any | None:"""Return a provider-specific client, or ``None`` for the standard one.diff --git a/tests/hermes_cli/test_inventory.py b/tests/hermes_cli/test_inventory.pyindex 348bdfe7e0c..3d2674d0250 100644--- a/tests/hermes_cli/test_inventory.py+++ b/tests/hermes_cli/test_inventory.py@@ -178,14 +178,16 @@ def test_include_unconfigured_appends_canonical_skeletons():with _list_auth_returning(rows):payload = build_models_payload(ctx, include_unconfigured=True)# All canonical providers other than openrouter should appear as- # skeleton rows. MoA is virtual/opt-in and excluded from unconfigured.- from hermes_cli.models import CANONICAL_PROVIDERS+ # skeleton rows. MoA is virtual/opt-in and excluded from unconfigured;+ # so is a pre-release provider the user has not signed into.+ from hermes_cli.models_catalog_static import listed_canonical_providersseen_slugs = {r["slug"] for r in payload["providers"]}- for entry in CANONICAL_PROVIDERS:+ for entry in listed_canonical_providers():if entry.slug == "moa":continue # virtual; only shown when explicitly configuredassert entry.slug in seen_slugs, f"missing {entry.slug}"+ assert "solstice" not in seen_slugs# Skeletons have empty models and source='canonical'.skeletons = [r for r in payload["providers"]if r.get("source") == "canonical"]@@ -442,9 +444,11 @@ def test_canonical_order_with_unconfigured_preserves_full_universe():# First row: first canonical provider in declaration order.assert slugs[0] == CANONICAL_PROVIDERS[0].slug# Custom row trails all visible canonical rows. MoA is virtual/opt-in- # so it is excluded from the unconfigured skeleton set.+ # so it is excluded from the unconfigured skeleton set, and so is an+ # unlisted pre-release provider.+ from hermes_cli.models_catalog_static import listed_canonical_providersvisible_canonical_count = sum(- 1 for e in CANONICAL_PROVIDERS if e.slug != "moa"+ 1 for e in listed_canonical_providers() if e.slug != "moa")assert slugs.index("custom:Ollama") >= visible_canonical_count