From 99a47cf1ad87f18e7e52658c0523f20647138187 Mon Sep 17 00:00:00 2001 From: ekko Date: Thu, 16 Apr 2026 13:51:42 +0800 Subject: [PATCH] feat: profile-aware routes, provider sync, channel settings improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add hermes-profile.ts for dynamic profile path resolution (all backend routes now read from active profile directory instead of hardcoded ~/.hermes/) - Add profile switcher dropdown in sidebar, reload page on switch - Sync PROVIDER_PRESETS with Hermes CLI (fix keys: kimi-coding→kimi-for-coding, kilocode→kilo, ai-gateway→vercel, opencode-zen→opencode; remove moonshot) - Sync PROVIDER_ENV_MAP with Hermes models.dev + overlays (correct env var names) - Add gateway restart after adding model provider - Don't write GLM_BASE_URL/KIMI_BASE_URL for zai/kimi (let Hermes auto-detect) - Write API keys to .env and credential_pool for all providers - Built-in providers skip custom_providers in config.yaml - Add debounce + per-field loading state for channel settings inputs - Run hermes setup --reset for profiles without config.yaml - Create empty .env for new profiles (not copied from default) Co-Authored-By: Claude Opus 4.6 --- CLAUDE.md | 2 + package.json | 2 +- packages/client/src/api/hermes/skills.ts | 4 +- packages/client/src/api/hermes/system.ts | 7 + .../hermes/profiles/ProfileCard.vue | 19 +-- .../hermes/settings/PlatformSettings.vue | 151 +++++++++++------ .../src/components/layout/AppSidebar.vue | 85 +++++++--- .../src/components/layout/ProfileSelector.vue | 67 ++++++++ packages/client/src/env.d.ts | 2 + packages/client/src/i18n/locales/en.ts | 8 + packages/client/src/i18n/locales/zh.ts | 10 +- packages/client/src/shared/providers.ts | 22 +-- packages/client/src/stores/hermes/app.ts | 31 +++- .../client/src/views/hermes/MemoryView.vue | 53 +++++- packages/server/src/index.ts | 79 ++++++++- packages/server/src/routes/hermes/config.ts | 23 +-- .../server/src/routes/hermes/filesystem.ts | 155 ++++++++++++++---- packages/server/src/routes/hermes/profiles.ts | 68 +++++++- packages/server/src/routes/hermes/weixin.ts | 11 +- packages/server/src/services/hermes-cli.ts | 16 ++ .../server/src/services/hermes-profile.ts | 56 +++++++ packages/server/src/shared/providers.ts | 22 +-- vite.config.ts | 4 + 23 files changed, 712 insertions(+), 185 deletions(-) create mode 100644 packages/client/src/components/layout/ProfileSelector.vue create mode 100644 packages/server/src/services/hermes-profile.ts diff --git a/CLAUDE.md b/CLAUDE.md index 10f833a..7b84b4a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -333,6 +333,8 @@ Unmatched `/api/hermes/*` and `/v1/*` requests are forwarded to the upstream Her The proxy is implemented as both a route (`proxyRoutes.all('/api/hermes/{*any}', proxy)`) and a middleware (`proxyMiddleware`) registered on the main app to catch any requests that slip through route matching. +**Important:** Custom API endpoints handled locally (not proxied) must be registered **before** `hermesRoutes.routes()` in `bootstrap()`. The proxy route `proxyRoutes.all('/api/hermes/{*any}')` matches all `/api/hermes/*` paths, so any middleware registered after it will never be reached. See the `update` middleware in `index.ts` for an example. + ### Hermes CLI Wrapper (`packages/server/src/services/hermes-cli.ts`) All Hermes interactions go through `child_process.execFile('hermes', [...args])`. Each function wraps a CLI subcommand: diff --git a/package.json b/package.json index 754f38a..9e3a00c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hermes-web-ui", - "version": "0.2.7", + "version": "0.2.6", "description": "Web dashboard for Hermes Agent — multi-platform AI chat, session management, scheduled jobs, usage analytics & channel configuration (Telegram, Discord, Slack, WhatsApp)", "repository": { "type": "git", diff --git a/packages/client/src/api/hermes/skills.ts b/packages/client/src/api/hermes/skills.ts index 490874d..b31fd10 100644 --- a/packages/client/src/api/hermes/skills.ts +++ b/packages/client/src/api/hermes/skills.ts @@ -25,8 +25,10 @@ export interface SkillFileEntry { export interface MemoryData { memory: string user: string + soul: string memory_mtime: number | null user_mtime: number | null + soul_mtime: number | null } export async function fetchSkills(): Promise { @@ -48,7 +50,7 @@ export async function fetchMemory(): Promise { return request('/api/hermes/memory') } -export async function saveMemory(section: 'memory' | 'user', content: string): Promise { +export async function saveMemory(section: 'memory' | 'user' | 'soul', content: string): Promise { await request('/api/hermes/memory', { method: 'POST', body: JSON.stringify({ section, content }), diff --git a/packages/client/src/api/hermes/system.ts b/packages/client/src/api/hermes/system.ts index 3aaa9f5..1eeddab 100644 --- a/packages/client/src/api/hermes/system.ts +++ b/packages/client/src/api/hermes/system.ts @@ -3,6 +3,9 @@ import { request } from '../client' export interface HealthResponse { status: string version?: string + webui_version?: string + webui_latest?: string + webui_update_available?: boolean } // Config-based model types @@ -45,6 +48,10 @@ export async function checkHealth(): Promise { return request('/health') } +export async function triggerUpdate(): Promise<{ success: boolean; message: string }> { + return request<{ success: boolean; message: string }>('/api/hermes/update', { method: 'POST' }) +} + export async function fetchConfigModels(): Promise { return request('/api/hermes/config/models') } diff --git a/packages/client/src/components/hermes/profiles/ProfileCard.vue b/packages/client/src/components/hermes/profiles/ProfileCard.vue index ce9ef52..5bb0b57 100644 --- a/packages/client/src/components/hermes/profiles/ProfileCard.vue +++ b/packages/client/src/components/hermes/profiles/ProfileCard.vue @@ -41,12 +41,13 @@ function handleSwitch() { positiveText: t('common.confirm'), negativeText: t('common.cancel'), onPositiveClick: async () => { - const ok = await profilesStore.switchProfile(props.profile.name) - if (ok) { - message.success(t('profiles.switchSuccess', { name: props.profile.name })) - } else { - message.error(t('profiles.switchFailed')) - } + profilesStore.switchProfile(props.profile.name).then(ok => { + if (ok) { + window.location.reload() + } else { + message.error(t('profiles.switchFailed')) + } + }) }, }) } @@ -101,10 +102,6 @@ async function handleExport() { {{ t('profiles.gateway') }} {{ profile.gateway }} -
- {{ t('profiles.alias') }} - {{ profile.alias }} -
@@ -164,7 +161,7 @@ async function handleExport() { size="tiny" quaternary type="error" - :disabled="isDefault" + :disabled="isDefault || profile.active" @click="handleDelete" > {{ t('common.delete') }} diff --git a/packages/client/src/components/hermes/settings/PlatformSettings.vue b/packages/client/src/components/hermes/settings/PlatformSettings.vue index 8273a6b..7bc4996 100644 --- a/packages/client/src/components/hermes/settings/PlatformSettings.vue +++ b/packages/client/src/components/hermes/settings/PlatformSettings.vue @@ -1,5 +1,5 @@