refactor(hermes): delegate deep config to Hermes Web UI

Slim the Hermes surface in CC Switch to match its core positioning —
cross-client provider switching and shared MCP/prompts/skills — and
delegate deep configuration (model, agent, env, skills, cron, logs)
to the Hermes Web UI at http://127.0.0.1:9119.

- Drop AgentPanel/EnvPanel/ModelPanel and their mutation commands,
  hooks, types, and i18n keys across zh/en/ja.
- Add open_hermes_web_ui Tauri command that probes /api/status and
  launches the URL in the system browser. Hermes injects its own
  session token into the returned HTML, so CC Switch doesn't need
  to touch auth.
- Surface the launcher from the Hermes toolbar and the health banner
  via a shared useOpenHermesWebUI() hook; the offline error code is
  defined once per side and referenced across the contract.
- Keep read-only access to model.provider so ProviderList can still
  highlight the active supplier; apply_switch_defaults continues to
  write the top-level model section when switching providers.

Net diff: +152 / -1253.
This commit is contained in:
Jason
2026-04-19 20:59:01 +08:00
parent 041f74db18
commit 088b47b08a
14 changed files with 152 additions and 1253 deletions
+12 -74
View File
@@ -1,92 +1,30 @@
import { invoke } from "@tauri-apps/api/core";
import type {
HermesModelConfig,
HermesAgentConfig,
HermesEnvConfig,
HermesHealthWarning,
HermesWriteOutcome,
} from "@/types";
import type { HermesModelConfig, HermesHealthWarning } from "@/types";
/**
* Hermes Agent configuration API
* Hermes Agent configuration API (CC Switch side).
*
* Manages Hermes config sections:
* - model (model selection and provider)
* - agent (agent behavior)
* - env (environment variables)
* CC Switch intentionally keeps its Hermes surface minimal — deep configuration
* (model, agent behavior, env vars, skills, cron, logs, analytics) lives in
* the Hermes Web UI at http://127.0.0.1:9119. CC Switch only reads the `model`
* section to highlight the active provider, scans config health, and launches
* the Hermes Web UI for everything else. Writes to `model` happen implicitly
* via `apply_switch_defaults` when the user switches providers.
*/
export const hermesApi = {
// ============================================================
// Model Configuration
// ============================================================
/**
* Get model configuration
*/
async getModelConfig(): Promise<HermesModelConfig | null> {
return await invoke("get_hermes_model_config");
},
/**
* Set model configuration
*/
async setModelConfig(config: HermesModelConfig): Promise<HermesWriteOutcome> {
return await invoke("set_hermes_model_config", { config });
},
// ============================================================
// Agent Configuration
// ============================================================
/**
* Get agent configuration
*/
async getAgentConfig(): Promise<HermesAgentConfig | null> {
return await invoke("get_hermes_agent_config");
},
/**
* Set agent configuration
*/
async setAgentConfig(config: HermesAgentConfig): Promise<HermesWriteOutcome> {
return await invoke("set_hermes_agent_config", { config });
},
// ============================================================
// Env Configuration
// ============================================================
/**
* Get env configuration (.env file)
*/
async getEnv(): Promise<HermesEnvConfig> {
return await invoke("get_hermes_env");
},
/**
* Set env configuration (.env file)
*/
async setEnv(env: HermesEnvConfig): Promise<HermesWriteOutcome> {
return await invoke("set_hermes_env", { env });
},
// ============================================================
// Health
// ============================================================
/**
* Scan config health and return warnings
*/
async scanHealth(): Promise<HermesHealthWarning[]> {
return await invoke("scan_hermes_config_health");
},
/**
* Get live provider config by ID
* Probe the local Hermes Web UI and open it in the system browser.
* Optional `path` lets callers deep-link to specific pages like `/config`.
*/
async getLiveProvider(
providerId: string,
): Promise<Record<string, unknown> | null> {
return await invoke("get_hermes_live_provider", { providerId });
async openWebUI(path?: string): Promise<void> {
await invoke("open_hermes_web_ui", { path: path ?? null });
},
};