The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(providers): plugin profiles place themselves in the static provider tables
Teknium5ea416472df7
diff --git a/agent/models_dev.py b/agent/models_dev.pyindex 721d27d14de..1a7801e1cfb 100644--- a/agent/models_dev.py+++ b/agent/models_dev.py@@ -114,7 +114,7 @@ PROVIDER_TO_MODELS_DEV: dict[str, str] = {"moonshot": "kimi-for-coding", "stepfun": "stepfun","kimi-coding-cn": "kimi-for-coding", "minimax": "minimax","minimax-oauth": "minimax", "minimax-cn": "minimax-cn", "deepseek": "deepseek",- "alibaba": "alibaba", "qwen-oauth": "alibaba", "copilot": "github-copilot",+ "alibaba": "alibaba", "qwen-oauth": "alibaba","ai-gateway": "vercel", "opencode-zen": "opencode","opencode-go": "opencode-go","kilocode": "kilo", "fireworks": "fireworks-ai",@@ -133,6 +133,27 @@ PROVIDER_TO_MODELS_DEV: dict[str, str] = {_MODELS_DEV_TO_PROVIDER: Optional[dict[str, list[str]]] = None+def _profile_models_dev_ids() -> dict[str, str]:+ """``{name: models_dev_id}`` declared by registered provider profiles the static map lacks.+ Read at lookup time (never merged into ``PROVIDER_TO_MODELS_DEV``)."""+ from providers import list_providers+ return {p.name: p.models_dev_id for p in list_providers()+ if p.models_dev_id and p.name not in PROVIDER_TO_MODELS_DEV}+++def models_dev_provider_map() -> dict[str, str]:+ """Hermes provider id → models.dev id: ``PROVIDER_TO_MODELS_DEV``, then profile ``models_dev_id``s."""+ return {**PROVIDER_TO_MODELS_DEV, **_profile_models_dev_ids()}+++def models_dev_id_for(provider: str) -> Optional[str]:+ """models.dev id for an exact Hermes provider id (static map first, then its profile), or None."""+ key = (provider or "").strip()+ if not key or key in PROVIDER_TO_MODELS_DEV:+ return PROVIDER_TO_MODELS_DEV.get(key)+ return _profile_models_dev_ids().get(key)++def _models_dev_to_hermes_ids(mdev_id: str) -> list[str]:"""Return the Hermes provider ids that map to *mdev_id* (may be [])."""global _MODELS_DEV_TO_PROVIDER@@ -140,7 +161,8 @@ def _models_dev_to_hermes_ids(mdev_id: str) -> list[str]:_MODELS_DEV_TO_PROVIDER = {}for hermes_id, mapped in PROVIDER_TO_MODELS_DEV.items():_MODELS_DEV_TO_PROVIDER.setdefault(mapped, []).append(hermes_id)- return _MODELS_DEV_TO_PROVIDER.get(mdev_id, [])+ profile_ids = [name for name, mapped in _profile_models_dev_ids().items() if mapped == mdev_id]+ return [*_MODELS_DEV_TO_PROVIDER.get(mdev_id, []), *profile_ids]def _dict_or_empty(value: Any) -> dict[str, Any]:@@ -155,7 +177,7 @@ def _configured_catalog_provider(name = (provider or "").strip()if name.lower().startswith("custom:"):name = name[len("custom:"):]- if not name or name in PROVIDER_TO_MODELS_DEV:+ if not name or models_dev_id_for(name) is not None:return Noneprovider_config = (_cfg_get("providers", name, default=None, config=config)@@ -181,11 +203,11 @@ def _models_dev_id("""models.dev provider id for a Hermes provider id, or None. A custom provider reaches thecatalog only through its configured ``catalog_provider`` alias (#112649)."""key = (provider or "").strip()- mdev_id = PROVIDER_TO_MODELS_DEV.get(key)+ mdev_id = models_dev_id_for(key)if mdev_id is None:alias = _configured_catalog_provider(key, config=config)- mdev_id = PROVIDER_TO_MODELS_DEV.get(alias, alias) if alias else None- if mdev_id is not None and mdev_id not in PROVIDER_TO_MODELS_DEV.values() \+ mdev_id = (models_dev_id_for(alias) or alias) if alias else None+ if mdev_id is not None and mdev_id not in models_dev_provider_map().values() \and mdev_id not in fetch_models_dev(allow_network=False):# A mistyped alias must not leak into ModelInfo.provider_id; the row stays on its own slug.if (key, alias) not in _UNKNOWN_CATALOG_PROVIDER_WARNED:@@ -676,7 +698,7 @@ def _provider_override_section(provider: str, *, config: Optional[dict[str, Any]if not overrides or not provider_key:return None# Forward (Hermes → models.dev id) and reverse (caller passed a models.dev id, config keyed by Hermes id) aliases.- candidates = [provider_key, PROVIDER_TO_MODELS_DEV.get(provider_key), *_models_dev_to_hermes_ids(provider_key)]+ candidates = [provider_key, models_dev_id_for(provider_key), *_models_dev_to_hermes_ids(provider_key)]return next((section for section in (overrides.get(key) if key else None for key in candidates) if isinstance(section, dict)), None)diff --git a/hermes_cli/inventory.py b/hermes_cli/inventory.pyindex 274a2213936..d7d17649a08 100644--- a/hermes_cli/inventory.py+++ b/hermes_cli/inventory.py@@ -772,7 +772,7 @@ def _anthropic_oauth_credentials_present() -> bool:def _filter_explicit_provider_rows(rows: list[dict], ctx: ConfigContext) -> list[dict]:"""Keep only rows backed by explicit user configuration — ``list_authenticated_providers`` also- discovers ambient credentials (e.g. GitHub CLI -> Copilot) Desktop chat pickers must not show."""+ discovers ambient credentials (e.g. another CLI's login token) Desktop chat pickers must not show."""from hermes_cli.auth import is_provider_explicitly_configuredcurrent_slug = str(ctx.current_provider or "").strip().lower()@@ -789,7 +789,7 @@ def _filter_explicit_provider_rows(rows: list[dict], ctx: ConfigContext) -> list# wrote an enabled preset into RAW config (the DEFAULT_CONFIG preset must not show MoA).return _raw_config_has_enabled_moa_preset()return (- # Anthropic OAuth (device flow / Claude Code) and external-process CLIs (copilot-acp) are+ # Anthropic OAuth (device flow / Claude Code) and external-process CLIs (ACP agents) are# deliberate sign-ins that leave no trace in config/env; keep the rows discovery accepted.(slug == "anthropic" and _anthropic_oauth_credentials_present())or _external_process_signed_in(slug)diff --git a/hermes_cli/model_cost_guard.py b/hermes_cli/model_cost_guard.pyindex 1b65dd00341..ee52adb9954 100644--- a/hermes_cli/model_cost_guard.py+++ b/hermes_cli/model_cost_guard.py@@ -6,7 +6,7 @@ from dataclasses import dataclassfrom decimal import Decimal, InvalidOperationfrom typing import Optional-from agent.models_dev import ModelInfo, PROVIDER_TO_MODELS_DEV+from agent.models_dev import ModelInfo, models_dev_id_forINPUT_COST_WARNING_THRESHOLD = Decimal(20)@@ -47,7 +47,7 @@ def _pricing_from_model_info(def _known_models_dev_provider(provider: Optional[str]) -> Optional[str]:normalized = (provider or "").strip().lower()- return PROVIDER_TO_MODELS_DEV.get(normalized) if normalized else None+ return models_dev_id_for(normalized) if normalized else Nonedef _can_trust_model_info_pricing(diff --git a/hermes_cli/model_switch_providers.py b/hermes_cli/model_switch_providers.pyindex ac3356231cd..725758a73d8 100644--- a/hermes_cli/model_switch_providers.py+++ b/hermes_cli/model_switch_providers.py@@ -272,11 +272,11 @@ def _iter_builtin_candidates(models_dev_data: dict, excluded: set, seen: set):silently switch a user onto an endpoint they may have no key for), aliases of another canonicalprofile ("kimi" -> "kimi-coding"), non-api_key auth types (section 2 handles them) andunroutable providers. PROVIDER_REGISTRY env var names win over models.dev's."""- from agent.models_dev import PROVIDER_TO_MODELS_DEV+ from agent.models_dev import models_dev_provider_mapfrom hermes_cli.auth import PROVIDER_REGISTRY, is_runtime_provider_routablefrom hermes_cli.models import _AGGREGATOR_PROVIDERSfrom hermes_cli.providers import ALIASES- for hermes_id, mdev_id in PROVIDER_TO_MODELS_DEV.items():+ for hermes_id, mdev_id in models_dev_provider_map().items():alias_target = ALIASES.get(hermes_id)if alias_target and alias_target != hermes_id and alias_target in _AGGREGATOR_PROVIDERS:continue@@ -659,9 +659,9 @@ def _collect_authed_provider_slugs(Env vars are read through the per-profile secret scope. AWS SDK providers are skipped(heavier detection)."""from hermes_cli.model_switch import _scoped_key_env- from agent.models_dev import PROVIDER_TO_MODELS_DEV+ from agent.models_dev import models_dev_provider_mapfrom hermes_cli.auth import PROVIDER_REGISTRY- from hermes_cli.providers import HERMES_OVERLAYS+ from hermes_cli.providers import hermes_overlaysfrom hermes_cli.models import CANONICAL_PROVIDERSexcluded_set = {str(p).strip().lower() for p in excluded if p}slugs: list[str] = []@@ -675,8 +675,8 @@ def _collect_authed_provider_slugs(if _any_env(env_vars, _scoped_key_env) or _raw_pool_usable(hermes_id):_emit(hermes_id, hermes_id)- mdev_to_hermes = {v: k for k, v in PROVIDER_TO_MODELS_DEV.items()}- for pid, overlay in HERMES_OVERLAYS.items():+ mdev_to_hermes = {v: k for k, v in models_dev_provider_map().items()}+ for pid, overlay in hermes_overlays().items():hermes_slug = mdev_to_hermes.get(pid, pid)if _skip(seen, excluded_set, pid, hermes_slug) or overlay.auth_type == "aws_sdk":continue@@ -871,8 +871,8 @@ def _overlay_has_creds(b: _PickerBuild, pid: str, hermes_slug: str, overlay) ->else:from hermes_cli.model_switch import _scoped_key_envhas_creds = _overlay_has_env_creds(pid, hermes_slug, overlay, _scoped_key_env)- # External-process providers (copilot-acp) hold no key/token/pool entry by design — the- # spawned ACP subprocess brings its own auth. "Configured" means the executable resolves.+ # External-process providers (ACP CLIs) hold no key/token/pool entry by design — the+ # spawned subprocess brings its own auth. "Configured" means the executable resolves.# "Configured" means the executable resolves, which is exactly what get_auth_status() reports for them;# without this branch the has_creds filter below unconditionally hides the provider from every picker# (#63662).@@ -909,21 +909,20 @@ def _overlay_has_creds(b: _PickerBuild, pid: str, hermes_slug: str, overlay) ->def _lap_overlay_rows(b: _PickerBuild, data: dict, user_providers: dict) -> None:- """Section 2: Hermes-only providers (nous, openai-codex, copilot, opencode-go, ...)."""- from agent.models_dev import PROVIDER_TO_MODELS_DEV+ """Section 2: Hermes-only providers (nous, openai-codex, opencode-go, plugin overlays, ...)."""+ from agent.models_dev import models_dev_provider_mapfrom hermes_cli.model_switch import _declared_model_ids- from hermes_cli.providers import HERMES_OVERLAYS+ from hermes_cli.providers import hermes_overlays- # HERMES_OVERLAYS keys may be models.dev IDs ("github-copilot") while config.yaml uses- # Hermes IDs ("copilot").- mdev_to_hermes = {v: k for k, v in PROVIDER_TO_MODELS_DEV.items()}- for pid, overlay in HERMES_OVERLAYS.items():+ # Overlay keys may be models.dev IDs while config.yaml uses Hermes IDs.+ mdev_to_hermes = {v: k for k, v in models_dev_provider_map().items()}+ for pid, overlay in hermes_overlays().items():hermes_slug = mdev_to_hermes.get(pid, pid)if _skip(b.seen_slugs, b.excluded, pid, hermes_slug):continueif not _overlay_has_creds(b, pid, hermes_slug, overlay):continue- if hermes_slug in {"openai-codex", "copilot", "copilot-acp"}:+ if hermes_slug == "openai-codex":# Live OAuth-backed discovery so Pro-only Codex slugs not in the static catalog# appear; falls back to curated when unreachable (or not yet cached on the read path).model_ids = _live_or_curated_ids(hermes_slug, b.curated, merge_models_dev=False,@@ -973,7 +972,7 @@ def _lap_canonical_rows(b: _PickerBuild) -> None:_is_aws_sdk(cp_config) and _has_aws_sdk_creds_for_listing(cp.slug, b.current_provider))if not has_creds and cp_config is not None and cp_config.auth_type == "external_process":# Subprocess-backed providers own their auth; the binary resolving is the credential- # evidence for listing (same gate as the copilot-acp overlay row and hermes auth status).+ # evidence for listing (same gate as the section-2 overlay rows and hermes auth status).try:from hermes_cli.auth import get_external_process_provider_statushas_creds = bool(get_external_process_provider_status(cp.slug).get("configured"))@@ -1274,7 +1273,7 @@ def list_authenticated_providers(user_providers = stringify_provider_map(user_providers)data = fetch_models_dev()- # A single excluded entry like ``copilot`` hides the provider under every key it surfaces+ # A single excluded entry like ``kimi-coding`` hides the provider under every key it surfaces# as (hermes_id / mdev_id / canonical slug).b = _PickerBuild(current_provider=current_provider, current_base_url=current_base_url, current_model=current_model,diff --git a/hermes_cli/models_catalog_static.py b/hermes_cli/models_catalog_static.pyindex 821e04ce84a..59b312510c9 100644--- a/hermes_cli/models_catalog_static.py+++ b/hermes_cli/models_catalog_static.py@@ -343,8 +343,6 @@ CANONICAL_PROVIDERS: list[ProviderEntry] = [ProviderEntry(*row) for row in (("tencent-tokenhub", "Tencent TokenHub", "Tencent TokenHub (Hy4 preview via tokenhub.tencentmaas.com)"),("tencent-tokenplan", "Tencent TokenPlan", "Tencent TokenPlan (Hy4 preview via api.lkeap.cloud.tencent.com, Anthropic Messages)"),("nvidia", "NVIDIA NIM", "NVIDIA NIM (Nemotron models via build.nvidia.com or local NIM)"),- ("copilot", "GitHub Copilot", "GitHub Copilot (Uses GITHUB_TOKEN or gh auth token)"),- ("copilot-acp", "GitHub Copilot ACP", "GitHub Copilot ACP (Spawns copilot --acp --stdio)"),("huggingface", "Hugging Face", "Hugging Face Inference Providers"),("gemini", "Google AI Studio", "Google AI Studio (Native Gemini API)"),("vertex", "Google Vertex AI", "Google Vertex AI (Gemini via GCP; OAuth2 service account or ADC, GCP billing/quotas)"),@@ -397,28 +395,51 @@ def sync_plugin_provider_catalog() -> int:plugin whose own imports pull ``hermes_cli.models`` in mid-``_discover_providers()``, or aprofile registered later at runtime, would otherwise never reach the picker, ``hermes model``,``/model`` or the Desktop ``model.options`` list until restart — the catalog twin of the auth- registry window (#102123). Idempotent by slug; built-in rows are never rewritten.+ registry window (#102123). Idempotent by slug; built-in rows are never rewritten. A row lands+ after its ``picker_after`` slug when that row exists, else at the end."""try:from providers import list_providers- profiles = list_providers()+ pending = [pp for pp in list_providers() if _plugin_provider_enters_picker(pp)]except Exception:return 0added = 0- for pp in profiles:- if not _plugin_provider_enters_picker(pp):- continue- label = pp.display_name or pp.name- CANONICAL_PROVIDERS.append(ProviderEntry(pp.name, label, pp.description or f"{label} (direct API)"))- _canonical_slugs.add(pp.name)- _PROVIDER_LABELS[pp.name] = label- added += 1+ while pending:+ # Rows anchored on a still-pending row wait for it, so a chain keeps its declared order.+ names = {pp.name for pp in pending}+ ready = [pp for pp in pending if pp.picker_after not in names] or pending+ for pp in ready:+ _admit_plugin_provider(pp)+ added += 1+ pending = [pp for pp in pending if pp not in ready]return added+def _admit_plugin_provider(pp) -> None:+ """Add one plugin profile to the picker tables: row (at ``picker_after``), label, group,+ catalog aliases and the aggregator set."""+ label = pp.display_name or pp.name+ entry = ProviderEntry(pp.name, label, pp.description or f"{label} (direct API)")+ slugs = [p.slug for p in CANONICAL_PROVIDERS]+ anchor = pp.picker_after+ CANONICAL_PROVIDERS.insert(slugs.index(anchor) + 1 if anchor in slugs else len(slugs), entry)+ _canonical_slugs.add(pp.name)+ _PROVIDER_LABELS[pp.name] = label+ if pp.picker_group:+ gid, group_label, group_desc = pp.picker_group+ members = PROVIDER_GROUPS.setdefault(gid, (group_label, group_desc, []))[2]+ if pp.name not in members:+ members.append(pp.name)+ _SLUG_TO_GROUP[pp.name] = gid+ if pp.catalog_aliases:+ for alias in pp.aliases:+ _PROVIDER_ALIASES.setdefault(alias, pp.name)+ if pp.aggregator:+ _AGGREGATOR_PROVIDERS.add(pp.name)++_PROVIDER_LABELS: dict[str, str] = {p.slug: p.label for p in CANONICAL_PROVIDERS}_PROVIDER_LABELS["custom"] = "Custom endpoint" # special case: not a named provider-sync_plugin_provider_catalog()def listed_canonical_providers() -> list[ProviderEntry]:@@ -447,7 +468,6 @@ PROVIDER_GROUPS: dict[str, tuple[str, str, list[str]]] = {"openai": ("OpenAI", "ChatGPT/Codex subscription or direct OpenAI API", ["openai-codex", "openai-api"]),"qwen": ("Qwen", "Qwen Cloud / DashScope, Coding Plan, Token Plan & Qwen CLI OAuth", ["alibaba", "alibaba-cn", "alibaba-coding-plan", "alibaba-coding-plan-cn", "alibaba-token-plan", "alibaba-token-plan-cn", "qwen-oauth"]),"opencode": ("OpenCode", "Zen pay-as-you-go or Go subscription", ["opencode-zen", "opencode-go"]),- "copilot": ("GitHub Copilot", "GitHub token API or copilot --acp process", ["copilot", "copilot-acp"]),"tencent": ("Tencent Hy", "Hy4 / Hy3 via TokenHub & TokenPlan", ["tencent-tokenhub", "tencent-tokenplan"]),}@@ -500,9 +520,7 @@ def group_providers(slugs):_PROVIDER_ALIASES = dict((- ("glm", "zai"), ("z-ai", "zai"), ("z.ai", "zai"), ("zhipu", "zai"), ("github", "copilot"),- ("github-copilot", "copilot"), ("github-models", "copilot"), ("github-model", "copilot"),- ("github-copilot-acp", "copilot-acp"), ("copilot-acp-agent", "copilot-acp"), ("google", "gemini"),+ ("glm", "zai"), ("z-ai", "zai"), ("z.ai", "zai"), ("zhipu", "zai"), ("google", "gemini"),("google-gemini", "gemini"), ("google-ai-studio", "gemini"), ("google-vertex", "vertex"), ("vertex-ai", "vertex"),("gcp-vertex", "vertex"), ("vertexai", "vertex"), ("kimi", "kimi-coding"), ("moonshot", "kimi-coding"),("kimi-cn", "kimi-coding-cn"), ("moonshot-cn", "kimi-coding-cn"), ("step", "stepfun"),@@ -564,7 +582,9 @@ _PROVIDER_RETIRED_ALIASES: dict[str, tuple[str, ...]] = {}-_AGGREGATOR_PROVIDERS = frozenset({"nous", "openrouter", "ai-gateway", "copilot", "kilocode"})+# Plugin profiles with ``aggregator=True`` join at sync time (``sync_plugin_provider_catalog``).+_AGGREGATOR_PROVIDERS: set[str] = {"nous", "openrouter", "ai-gateway", "kilocode"}+sync_plugin_provider_catalog() # every table it extends is defined above# Subscription/OAuth providers whose catalogs RE-EXPOSE other vendors' models; tried only as a last@@ -582,7 +602,7 @@ _LIVE_FIRST_PICKER_PROVIDERS: frozenset[str] = frozenset({"opencode-zen", "openc# Models supporting OpenAI Priority Processing (service_tier="priority"; see# openai.com/api-priority-processing). Pattern-based: any OpenAI flagship (gpt-*, o1*, o3*, o4*).-# Non-OpenAI endpoints (OpenRouter/Copilot/opencode-zen proxies) strip service_tier, so false+# Non-OpenAI endpoints (OpenRouter/opencode-zen and other proxies) strip service_tier, so false# positives are harmless. Codex-series models are excluded — the Codex Responses API doesn't# expose service_tier._OPENAI_FAST_MODE_PREFIXES: tuple[str, ...] = ("gpt-", "o1", "o3", "o4")@@ -597,7 +617,7 @@ _OPENAI_ULTRAFAST_MODELS: frozenset[str] = frozenset({"gpt-6-astra", "gpt-6.1-so# and the gateway /model picker. DELIBERATELY EXCLUDED: "openrouter" (curated list is a hand-picked# agentic subset of 400+ models — merging would dump everything), "nous" (curated list + Portal# /models are the subscription-tier source of truth), and providers with dedicated live-endpoint-# branches (copilot, anthropic, ai-gateway, ollama-cloud, custom, stepfun, openai-codex).+# branches (anthropic, ai-gateway, ollama-cloud, custom, stepfun, openai-codex, plugin live catalogs)._MODELS_DEV_PREFERRED: frozenset[str] = frozenset({"opencode-go", "opencode-zen", "kilocode", "fireworks", "mistral", "togetherai", "cohere","perplexity", "groq", "nvidia", "huggingface", "zai", "gemini", "google", "xai", "xai-oauth",diff --git a/hermes_cli/provider_catalog.py b/hermes_cli/provider_catalog.pyindex 1bc60b45524..32e4ea466cd 100644--- a/hermes_cli/provider_catalog.py+++ b/hermes_cli/provider_catalog.py@@ -17,10 +17,9 @@ from dataclasses import dataclass# Auth types that authenticate via an account / sign-in flow rather than a pasted API key; these# route to the desktop "Accounts" tab, everything else (api_key, and aws_sdk configured via# AWS_REGION/AWS_PROFILE) to "API keys". Mirrors the auth_type strings in PROVIDER_REGISTRY and-# ProviderProfile: external_process = copilot-acp (spawns `copilot --acp --stdio`), copilot = GitHub-# Copilot token / gh auth.+# ProviderProfile: external_process = a spawned CLI that owns its own login (e.g. an ACP agent)._ACCOUNTS_AUTH_TYPES: frozenset[str] = frozenset(- {"oauth_device_code", "oauth_external", "oauth_minimax", "external_process", "copilot"}+ {"oauth_device_code", "oauth_external", "oauth_minimax", "external_process"})@@ -31,7 +30,7 @@ class ProviderDescriptor:slug: str # canonical id, e.g. "openai-codex"label: str # human display namedescription: str # one-line description- auth_type: str # api_key | oauth_* | external_process | copilot | aws_sdk+ auth_type: str # api_key | oauth_* | external_process | aws_sdktab: str # "keys" | "accounts"api_key_env_vars: tuple[str, ...] # credential env vars (may be empty)base_url_env_var: str # base-URL override env var (may be "")diff --git a/hermes_cli/providers.py b/hermes_cli/providers.pyindex e3d604a300b..d4392165281 100644--- a/hermes_cli/providers.py+++ b/hermes_cli/providers.py@@ -39,9 +39,6 @@ HERMES_OVERLAYS: dict[str, HermesOverlay] = {base_url_env_var="HERMES_QWEN_BASE_URL"),"lmstudio": HermesOverlay(extra_env_vars=("LM_API_KEY",), base_url_override="http://127.0.0.1:1234/v1",base_url_env_var="LM_BASE_URL"),- "copilot-acp": HermesOverlay(transport="codex_responses", auth_type="external_process",- base_url_override="acp://copilot", base_url_env_var="COPILOT_ACP_BASE_URL"),- "github-copilot": HermesOverlay(extra_env_vars=("COPILOT_GITHUB_TOKEN", "GH_TOKEN")),"anthropic": HermesOverlay(transport="anthropic_messages", extra_env_vars=("ANTHROPIC_TOKEN", "CLAUDE_CODE_OAUTH_TOKEN")),"zai": HermesOverlay(extra_env_vars=("GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"), base_url_env_var="GLM_BASE_URL"),"kimi-for-coding": HermesOverlay(base_url_env_var="KIMI_BASE_URL"),@@ -122,8 +119,7 @@ _ALIAS_GROUPS: dict[str, tuple[str, ...]] = {"nvidia": ("nim", "nvidia-nim", "build-nvidia", "nemotron"),"kimi-for-coding": ("kimi", "kimi-coding", "kimi-coding-cn", "moonshot"),"stepfun": ("step", "stepfun-coding-plan"), "minimax-cn": ("minimax-china", "minimax_cn"),- "anthropic": ("claude", "claude-code"), "github-copilot": ("copilot", "github"),- "copilot-acp": ("github-copilot-acp",), "openai-codex": ("chatgpt", "chatgpt-codex"),+ "anthropic": ("claude", "claude-code"), "openai-codex": ("chatgpt", "chatgpt-codex"),"vercel": ("ai-gateway", "aigateway", "vercel-ai-gateway"),"opencode": ("opencode-zen", "zen"), "opencode-go": ("go", "opencode-go-sub"), "kilo": ("kilocode", "kilo-code", "kilo-gateway"),"deepseek": ("deep-seek",), "alibaba": ("dashscope", "aliyun", "qwen", "alibaba-cloud"),@@ -147,7 +143,7 @@ ALIASES: dict[str, str] = {alias: canon for canon, aliases in _ALIAS_GROUPS.item_LABEL_OVERRIDES: dict[str, str] = {"moa": "Mixture of Agents", "nous": "Nous Portal", "openai-codex": "ChatGPT or Codex Subscription",- "copilot-acp": "GitHub Copilot ACP", "stepfun": "StepFun Step Plan", "xiaomi": "Xiaomi MiMo", "gmi": "GMI Cloud",+ "stepfun": "StepFun Step Plan", "xiaomi": "Xiaomi MiMo", "gmi": "GMI Cloud","upstage": "Upstage Solar", "actual": "Actual Computer", "tencent-tokenhub": "Tencent TokenHub","nebius-token-factory": "Nebius Token Factory", "tencent-tokenplan": "Tencent TokenPlan", "lmstudio": "LM Studio","custom": "Custom endpoint", "bedrock": "AWS Bedrock", "vertex": "Google Vertex AI", "ollama-cloud": "Ollama Cloud",@@ -165,10 +161,51 @@ TRANSPORT_TO_API_MODE: dict[str, str] = {# -- Helper functions ---------------------------------------------------------+def _overlay_profiles() -> list:+ """Registered profiles that declare a ``provider_overlay`` (no plugin-dir rescan on a miss)."""+ from providers import list_providers+ return [prof for prof in list_providers() if prof.provider_overlay]+++def _overlay_profile(name: str):+ """The overlay-declaring profile *name* (its id, models.dev id or an alias) belongs to, or None."""+ if not name:+ return None+ return next((prof for prof in _overlay_profiles()+ if name in (prof.name, prof.models_dev_id, *prof.aliases)), None)+++def _profile_overlay_key(prof) -> str:+ return prof.models_dev_id or prof.name+++def hermes_overlays() -> dict[str, HermesOverlay]:+ """``HERMES_OVERLAYS`` plus the overlays registered profiles declare (``provider_overlay``)."""+ merged = dict(HERMES_OVERLAYS)+ for prof in _overlay_profiles():+ merged.setdefault(_profile_overlay_key(prof), HermesOverlay(**prof.provider_overlay))+ return merged++def normalize_provider(name: str) -> str:"""Resolve aliases and normalise casing to a canonical provider id."""key = name.strip().lower()- return ALIASES.get(key, key)+ if key in ALIASES:+ return ALIASES[key]+ prof = _overlay_profile(key) if key not in HERMES_OVERLAYS else None+ return _profile_overlay_key(prof) if prof is not None else key+++def _get_overlay(canonical: str) -> tuple[Optional[HermesOverlay], str]:+ """``(overlay, label)`` for a canonical id: the static table, else a profile's ``provider_overlay``+ (a profile labels its own id; a models.dev id keeps the catalog spelling)."""+ if canonical in HERMES_OVERLAYS:+ return HERMES_OVERLAYS[canonical], _LABEL_OVERRIDES.get(canonical, canonical)+ prof = _overlay_profile(canonical)+ if prof is None or _profile_overlay_key(prof) != canonical:+ return None, canonical+ label = (prof.display_name or canonical) if canonical == prof.name else canonical+ return HermesOverlay(**prof.provider_overlay), _LABEL_OVERRIDES.get(canonical, label)def is_actual_route(provider: str = "", base_url: str = "") -> bool:@@ -200,7 +237,7 @@ def get_provider(name: str, *, allow_network: bool = True) -> Optional[ProviderDHermes-only overlay (nous, openai-codex, …); plugin provider profiles with a concrete endpoint."""canonical = normalize_provider(name)mdev_info = _models_dev_info(canonical, allow_network)- overlay = HERMES_OVERLAYS.get(canonical)+ overlay, overlay_label = _get_overlay(canonical)if mdev_info is not None:ov = overlay or HermesOverlay()env_vars = list(mdev_info.env)@@ -210,7 +247,7 @@ def get_provider(name: str, *, allow_network: bool = True) -> Optional[ProviderDreturn _overlay_pdef(canonical, ov, mdev_info.name, tuple(env_vars), ov.base_url_override or mdev_info.api,mdev_info.doc, "models.dev")if overlay is not None:- return _overlay_pdef(canonical, overlay, _LABEL_OVERRIDES.get(canonical, canonical), overlay.extra_env_vars,+ return _overlay_pdef(canonical, overlay, overlay_label, overlay.extra_env_vars,overlay.base_url_override, "", "hermes")# Plugin-registered profiles (plugins/model-providers/<name>/) absent from models.dev and# HERMES_OVERLAYS would otherwise be "Unknown provider" in /model, --provider and model-switch@@ -482,7 +519,7 @@ def _lossy_alias_registry_pdef(raw: str, canonical: str) -> Optional[ProviderDef"""Exact Hermes registry ids win over LOSSY alias collapsing (kimi-coding-cn must stay distinctfrom kimi-coding instead of collapsing through the shared models.dev alias "kimi-for-coding").A collapse is lossy only when MULTIPLE registry providers normalize to the same canonical name;- single-entry rewrites ("copilot" -> "github-copilot") are correct routing and keep resolving+ single-entry rewrites (a Hermes id -> its models.dev id) are correct routing and keep resolvingthrough the built-in chain so overlay transports apply."""try:from hermes_cli.auth import PROVIDER_REGISTRY as _AUTH_PROVIDER_REGISTRYdiff --git a/plugins/model-providers/copilot-acp/__init__.py b/plugins/model-providers/copilot-acp/__init__.pyindex 26c8497166a..8f36ca7ead4 100644--- a/plugins/model-providers/copilot-acp/__init__.py+++ b/plugins/model-providers/copilot-acp/__init__.py@@ -11,6 +11,7 @@ from typing import Anyfrom providers import register_providerfrom providers.base import ProviderProfile+from .picker import PICKER_FIELDSfrom .setup import SETUP_FIELDS@@ -86,7 +87,7 @@ copilot_acp = CopilotACPProfile(process_args_env_var="HERMES_COPILOT_ACP_ARGS",# A delegation.command no other profile claims has always run through this ACP client.process_command_fallback=True,- **SETUP_FIELDS,+ **SETUP_FIELDS, **PICKER_FIELDS,)register_provider(copilot_acp)diff --git a/plugins/model-providers/copilot-acp/picker.py b/plugins/model-providers/copilot-acp/picker.pynew file mode 100644index 00000000000..da9a89a0974--- /dev/null+++ b/plugins/model-providers/copilot-acp/picker.py@@ -0,0 +1,15 @@+"""GitHub Copilot ACP's place in the provider tables: picker row, label, group, aliases, overlay.++Core reads these only through generic ``ProviderProfile`` fields (``PICKER_FIELDS``).+"""++PICKER_FIELDS = dict(+ display_name="GitHub Copilot ACP",+ description="GitHub Copilot ACP (Spawns copilot --acp --stdio)",+ picker_after="copilot",+ # Same group as the ``copilot`` provider: one "GitHub Copilot" row in the interactive pickers.+ picker_group=("copilot", "GitHub Copilot", "GitHub token API or copilot --acp process"),+ catalog_aliases=True,+ provider_overlay={"transport": "codex_responses", "auth_type": "external_process",+ "base_url_override": "acp://copilot", "base_url_env_var": "COPILOT_ACP_BASE_URL"},+)diff --git a/plugins/model-providers/copilot/__init__.py b/plugins/model-providers/copilot/__init__.pyindex deedcee0a7e..550573ef3f6 100644--- a/plugins/model-providers/copilot/__init__.py+++ b/plugins/model-providers/copilot/__init__.py@@ -12,6 +12,7 @@ from providers.base import ProviderProfilefrom .catalog import HOSTNAMES, METADATA_HOSTNAMES, MODELS_DEV_ID, CopilotCatalogMixinfrom .credentials import CopilotCredentialsMixin+from .picker import PICKER_FIELDSfrom .responses import RESPONSES_PROFILE_FIELDS, CopilotResponsesMixinfrom .setup import SETUP_FIELDSfrom .wire import CopilotWireMixin@@ -45,7 +46,7 @@ copilot = CopilotProfile(name="copilot", aliases=("github-copilot", "github-models", "github-model", "github"),env_vars=("COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"), base_url="https://api.githubcopilot.com",auth_type="copilot", ambient_credentials=True, **RESPONSES_PROFILE_FIELDS, **SETUP_FIELDS,- hostnames=HOSTNAMES, metadata_hostnames=METADATA_HOSTNAMES, models_dev_id=MODELS_DEV_ID,+ hostnames=HOSTNAMES, metadata_hostnames=METADATA_HOSTNAMES, models_dev_id=MODELS_DEV_ID, **PICKER_FIELDS,)register_provider(copilot)diff --git a/plugins/model-providers/copilot/picker.py b/plugins/model-providers/copilot/picker.pynew file mode 100644index 00000000000..7ee3dc0d09a--- /dev/null+++ b/plugins/model-providers/copilot/picker.py@@ -0,0 +1,19 @@+"""GitHub Copilot's place in the provider tables: picker row, label, group, aliases, models.dev overlay.++Core reads these only through generic ``ProviderProfile`` fields (``PICKER_FIELDS``).+"""++# Both Copilot providers fold under one "GitHub Copilot" row in the interactive pickers.+PICKER_GROUP = ("copilot", "GitHub Copilot", "GitHub token API or copilot --acp process")++PICKER_FIELDS = dict(+ display_name="GitHub Copilot",+ description="GitHub Copilot (Uses GITHUB_TOKEN or gh auth token)",+ picker_after="nvidia",+ picker_group=PICKER_GROUP,+ catalog_aliases=True,+ # The Copilot catalog serves OpenAI, Anthropic, Google and xAI models.+ aggregator=True,+ # models.dev lists GitHub Copilot under GITHUB_TOKEN only; Hermes also reads these two.+ provider_overlay={"extra_env_vars": ("COPILOT_GITHUB_TOKEN", "GH_TOKEN")},+)diff --git a/providers/base.py b/providers/base.pyindex da1f3bca24a..ef8996e42b9 100644--- a/providers/base.py+++ b/providers/base.py@@ -688,3 +688,12 @@ class ProviderProfile:def replays_function_thought_signature(self, *, model: str | None, base_url: str) -> bool:"""True when replayed tool calls keep ``function.thought_signature`` (stripped everywhere else)."""return False++ # --- I2-static: provider-table placement ---+ picker_after: str = "" # provider slug this row follows in the provider list ("" = appended)+ picker_group: tuple = () # (group_id, label, description): fold with same-group rows in interactive pickers+ catalog_aliases: bool = False # ``aliases`` also normalize in the model catalog (``/model``, pickers)+ aggregator: bool = False # catalog re-exposes many vendors' models (vendor/family ids, alias resolution)+ # HermesOverlay fields (transport, auth_type, extra_env_vars, base_url_override, base_url_env_var) for+ # the provider's models.dev-keyed definition, keyed by ``models_dev_id`` or ``name``; {} = none.+ provider_overlay: dict = field(default_factory=dict)diff --git a/tests/hermes_cli/test_provider_table_placement.py b/tests/hermes_cli/test_provider_table_placement.pynew file mode 100644index 00000000000..e7829f88e6b--- /dev/null+++ b/tests/hermes_cli/test_provider_table_placement.py@@ -0,0 +1,101 @@+"""Plugin profiles place themselves in the core provider tables through generic fields.++``picker_after`` / ``picker_group`` / ``catalog_aliases`` / ``aggregator`` feed the picker catalog+(``sync_plugin_provider_catalog``); ``provider_overlay`` feeds ``hermes_cli.providers``;+``models_dev_id`` feeds the models.dev lookups at lookup time. Exercised with fake profiles only.+"""++import pytest++from providers.base import ProviderProfile+++def catalog(monkeypatch):+ """The picker tables as private copies, so admissions stay inside the test."""+ import hermes_cli.models_catalog_static as cat++ monkeypatch.setattr(cat, "CANONICAL_PROVIDERS", list(cat.CANONICAL_PROVIDERS))+ monkeypatch.setattr(cat, "_canonical_slugs", set(cat._canonical_slugs))+ monkeypatch.setattr(cat, "_PROVIDER_LABELS", dict(cat._PROVIDER_LABELS))+ monkeypatch.setattr(cat, "PROVIDER_GROUPS", {k: (lbl, d, list(m)) for k, (lbl, d, m) in cat.PROVIDER_GROUPS.items()})+ monkeypatch.setattr(cat, "_SLUG_TO_GROUP", dict(cat._SLUG_TO_GROUP))+ monkeypatch.setattr(cat, "_PROVIDER_ALIASES", dict(cat._PROVIDER_ALIASES))+ monkeypatch.setattr(cat, "_AGGREGATOR_PROVIDERS", set(cat._AGGREGATOR_PROVIDERS))+ return cat+++def _use_profiles(monkeypatch, *profiles):+ import providers++ monkeypatch.setattr(providers, "list_providers", lambda: list(profiles))+++def test_picker_fields_place_plugin_rows(catalog, monkeypatch):+ group = ("zz-vendor", "ZZ Vendor", "API or local agent")+ # Registered child-first: the chained anchor must still land the child right after its parent.+ child = ProviderProfile(name="zz-agent", display_name="ZZ Agent", picker_after="zz-api", picker_group=group)+ parent = ProviderProfile(+ name="zz-api", aliases=("zz", "zz-cloud"), display_name="ZZ API", description="ZZ API (direct)",+ picker_after="nvidia", picker_group=group, catalog_aliases=True, aggregator=True)+ _use_profiles(monkeypatch, child, parent)++ assert catalog.sync_plugin_provider_catalog() == 2++ slugs = [p.slug for p in catalog.CANONICAL_PROVIDERS]+ at = slugs.index("nvidia")+ assert slugs[at + 1:at + 3] == ["zz-api", "zz-agent"]+ assert catalog.CANONICAL_PROVIDERS[at + 1].label == "ZZ API"+ assert catalog.CANONICAL_PROVIDERS[at + 1].tui_desc == "ZZ API (direct)"+ row = next(r for r in catalog.group_providers(slugs) if r.get("group_id") == "zz-vendor")+ assert (row["label"], row["description"], row["members"]) == ("ZZ Vendor", "API or local agent", ["zz-api", "zz-agent"])+ assert catalog._PROVIDER_ALIASES["zz-cloud"] == "zz-api"+ assert "zz-api" in catalog._AGGREGATOR_PROVIDERS and "zz-agent" not in catalog._AGGREGATOR_PROVIDERS+ assert catalog.sync_plugin_provider_catalog() == 0 # idempotent+++def test_unplaced_profile_keeps_generic_admission(catalog, monkeypatch):+ plain = ProviderProfile(name="zz-plain", aliases=("zzp",))+ _use_profiles(monkeypatch, plain)++ catalog.sync_plugin_provider_catalog()++ assert catalog.CANONICAL_PROVIDERS[-1].slug == "zz-plain"+ assert catalog.provider_group_for_slug("zz-plain") == ""+ assert "zzp" not in catalog._PROVIDER_ALIASES # aliases stay out of the model catalog by default+ assert "zz-plain" not in catalog._AGGREGATOR_PROVIDERS+++def test_provider_overlay_defines_the_models_dev_keyed_provider(monkeypatch):+ from hermes_cli import providers as prov++ overlaid = ProviderProfile(+ name="zz-acp", aliases=("zz-acp-agent",), display_name="ZZ ACP", base_url="acp://zz",+ auth_type="external_process",+ provider_overlay={"transport": "codex_responses", "auth_type": "external_process",+ "base_url_override": "acp://zz", "base_url_env_var": "ZZ_ACP_BASE_URL"})+ plain = ProviderProfile(name="zz-plain", aliases=("zzp",), base_url="https://zz.test/v1")+ _use_profiles(monkeypatch, overlaid, plain)+ monkeypatch.setattr(prov, "_models_dev_info", lambda canonical, allow_network=True: None)++ assert prov.normalize_provider("ZZ-ACP-Agent") == "zz-acp"+ assert prov.normalize_provider("zzp") == "zzp" # no overlay: the providers layer leaves it alone+ pdef = prov.get_provider("zz-acp-agent")+ assert (pdef.id, pdef.name, pdef.transport, pdef.base_url, pdef.base_url_env_var, pdef.source) == (+ "zz-acp", "ZZ ACP", "codex_responses", "acp://zz", "ZZ_ACP_BASE_URL", "hermes")+ assert prov.determine_api_mode("zz-acp") == "codex_responses"+ assert "zz-acp" in prov.hermes_overlays() and "zz-plain" not in prov.hermes_overlays()+++def test_profile_models_dev_id_resolves_at_lookup_time(monkeypatch):+ import agent.models_dev as md++ _use_profiles(monkeypatch, ProviderProfile(name="zz-hosted", aliases=("zzh",), models_dev_id="zz-catalog"))+ monkeypatch.setattr(md, "PROVIDER_TO_MODELS_DEV", {})+ monkeypatch.setattr(md, "_MODELS_DEV_TO_PROVIDER", None)++ assert md.models_dev_id_for("zz-hosted") == "zz-catalog"+ assert md.models_dev_id_for("zzh") is None # exact Hermes ids only, like the static map+ assert md._models_dev_to_hermes_ids("zz-catalog") == ["zz-hosted"]+ assert md.models_dev_provider_map() == {"zz-hosted": "zz-catalog"}+ assert md.PROVIDER_TO_MODELS_DEV == {} # never merged into the static dict