feat: profile-aware routes, provider sync, channel settings improvements
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -3,10 +3,10 @@ import axios from 'axios'
|
||||
import { readFile, writeFile } from 'fs/promises'
|
||||
import { chmod } from 'fs/promises'
|
||||
import { resolve } from 'path'
|
||||
import { homedir } from 'os'
|
||||
import { restartGateway } from '../../services/hermes-cli'
|
||||
import { getActiveEnvPath } from '../../services/hermes-profile'
|
||||
|
||||
const envPath = resolve(homedir(), '.hermes/.env')
|
||||
const envPath = () => getActiveEnvPath()
|
||||
const ILINK_BASE = 'https://ilinkai.weixin.qq.com'
|
||||
|
||||
export const weixinRoutes = new Router()
|
||||
@@ -84,7 +84,7 @@ weixinRoutes.post('/api/hermes/weixin/save', async (ctx) => {
|
||||
try {
|
||||
let raw: string
|
||||
try {
|
||||
raw = await readFile(envPath, 'utf-8')
|
||||
raw = await readFile(envPath(), 'utf-8')
|
||||
} catch {
|
||||
raw = ''
|
||||
}
|
||||
@@ -124,8 +124,9 @@ weixinRoutes.post('/api/hermes/weixin/save', async (ctx) => {
|
||||
}
|
||||
|
||||
let output = result.join('\n').replace(/\n{3,}/g, '\n\n').replace(/\n+$/, '') + '\n'
|
||||
await writeFile(envPath, output, 'utf-8')
|
||||
try { await chmod(envPath, 0o600) } catch { /* ignore */ }
|
||||
const ep = envPath()
|
||||
await writeFile(ep, output, 'utf-8')
|
||||
try { await chmod(ep, 0o600) } catch { /* ignore */ }
|
||||
await restartGateway()
|
||||
|
||||
ctx.body = { success: true }
|
||||
|
||||
Reference in New Issue
Block a user