mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-02 10:21:16 +08:00
feat: add Hermes frontend types, API layer, and hooks (Phase 7)
- Add "hermes" to AppId union type and all exhaustive Record<AppId> - Add HermesModelConfig, HermesAgentConfig, HermesEnvConfig types - Add hermes field to VisibleApps, McpApps, ProxyTakeoverStatus - Create src/lib/api/hermes.ts with Tauri invoke wrappers - Create src/hooks/useHermes.ts with 5 query + 3 mutation hooks - Register hermes in APP_IDS, APP_ICON_MAP (violet color scheme) - Split MCP_SKILLS_APP_IDS into MCP_APP_IDS (includes hermes) and SKILLS_APP_IDS (excludes hermes, since Hermes has no Skills support) - Wire hermes additive-mode into App.tsx (remove/duplicate handlers), ProviderList.tsx (live provider ID query + In Config badge), mutations.ts (cache invalidation on switch/add/delete) - Add Hermes checkbox to McpFormModal - Add basic hermes i18n keys (en/zh/ja)
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import type {
|
||||
HermesModelConfig,
|
||||
HermesAgentConfig,
|
||||
HermesEnvConfig,
|
||||
HermesHealthWarning,
|
||||
HermesWriteOutcome,
|
||||
} from "@/types";
|
||||
|
||||
/**
|
||||
* Hermes Agent configuration API
|
||||
*
|
||||
* Manages Hermes config sections:
|
||||
* - model (model selection and provider)
|
||||
* - agent (agent behavior)
|
||||
* - env (environment variables)
|
||||
*/
|
||||
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
|
||||
*/
|
||||
async getLiveProvider(
|
||||
providerId: string,
|
||||
): Promise<Record<string, unknown> | null> {
|
||||
return await invoke("get_hermes_live_provider", { providerId });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user