Files
clawpanel/src-tauri
晴天 17759fc1e6 feat(hermes): add 22-provider registry + rewrite core commands (Step 1)
Introduce an authoritative Hermes provider registry in Rust, mirroring
upstream `hermes-agent` data (PROVIDER_REGISTRY + _PROVIDER_MODELS), and
refactor the four critical Hermes commands to be provider-aware.

Closes the G1/G2/G3 blockers identified in the v3 integration design.

New module `src-tauri/src/commands/hermes_providers.rs`:
- Static catalog of 22 providers: 17 api_key (incl. DeepSeek, Gemini,
  xAI, GLM/Z.AI, Kimi, MiniMax int'l + CN, Alibaba DashScope, Xiaomi,
  Copilot PAT, HuggingFace, OpenRouter, Vercel AI Gateway, OpenCode
  Zen/Go, Kilocode), 3 OAuth (Nous, OpenAI Codex, Qwen OAuth), 1
  external_process (Copilot ACP), and `custom` placeholder.
- Each entry carries id, display name, auth_type, base_url, env var
  priority list, transport, probe strategy, known models, aggregator
  flag, and CLI auth hint.
- Helpers: `get_provider`, `primary_api_key_env`, `primary_base_url_env`,
  `all_managed_env_keys`, `infer_provider_from_env_keys`,
  `find_provider_by_model`.
- New Tauri command `hermes_list_providers` (cached client-side).
- 5 unit tests covering registry integrity and lookup semantics.

Refactored `src-tauri/src/commands/hermes.rs`:
- `configure_hermes`: writes `model.provider` in config.yaml and routes
  API keys through the registry's `api_key_env_vars`. Skips key write
  for OAuth providers (Hermes CLI manages auth.json itself). Clears
  all managed keys on provider switch to avoid stale credentials.
- `hermes_read_config`: reads `model.provider`, then reverse-looks up
  the matching API key from the registry's env var priority list.
  Falls back to inferring provider from .env when config.yaml omits
  the provider field.
- `hermes_update_model`: accepts optional `provider` param; writes
  `model.provider` line into config.yaml (adds it when missing, updates
  in place when present, removes it for `custom`).
- `hermes_fetch_models`: accepts optional `provider` param; uses
  registry's probe strategy (`PROBE_NONE` returns static catalog for
  OAuth providers instead of hitting the API).

Registration:
- `src-tauri/src/commands/mod.rs`: declare `hermes_providers` module.
- `src-tauri/src/lib.rs`: import + register `hermes_list_providers`.

Verified: cargo fmt / cargo clippy -D warnings / cargo test all green
(5 new unit tests pass).
2026-04-24 20:40:40 +08:00
..
2026-04-20 16:08:15 +08:00
2026-04-20 16:08:15 +08:00