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:
@@ -507,6 +507,22 @@ export async function exportProfile(name: string, outputPath?: string): Promise<
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run hermes setup --non-interactive --reset to generate default config for current profile
|
||||
*/
|
||||
export async function setupReset(): Promise<string> {
|
||||
try {
|
||||
const { stdout, stderr } = await execFileAsync('hermes', ['setup', '--non-interactive', '--reset'], {
|
||||
timeout: 30000,
|
||||
...execOpts,
|
||||
})
|
||||
return stdout || stderr
|
||||
} catch (err: any) {
|
||||
console.error('[Hermes CLI] setup reset failed:', err.message)
|
||||
throw new Error(`Failed to reset config: ${err.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import profile from archive
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { resolve, join } from 'path'
|
||||
import { homedir } from 'os'
|
||||
import { readFileSync, existsSync } from 'fs'
|
||||
|
||||
const HERMES_BASE = resolve(homedir(), '.hermes')
|
||||
|
||||
/**
|
||||
* Get the active profile's home directory.
|
||||
* default → ~/.hermes/
|
||||
* other → ~/.hermes/profiles/{name}/
|
||||
*/
|
||||
export function getActiveProfileDir(): string {
|
||||
const activeFile = join(HERMES_BASE, 'active_profile')
|
||||
try {
|
||||
const name = readFileSync(activeFile, 'utf-8').trim()
|
||||
if (name && name !== 'default') {
|
||||
const dir = join(HERMES_BASE, 'profiles', name)
|
||||
if (existsSync(dir)) return dir
|
||||
}
|
||||
} catch { }
|
||||
return HERMES_BASE
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active profile's config.yaml path.
|
||||
*/
|
||||
export function getActiveConfigPath(): string {
|
||||
return join(getActiveProfileDir(), 'config.yaml')
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active profile's auth.json path.
|
||||
*/
|
||||
export function getActiveAuthPath(): string {
|
||||
return join(getActiveProfileDir(), 'auth.json')
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active profile's .env path.
|
||||
*/
|
||||
export function getActiveEnvPath(): string {
|
||||
return join(getActiveProfileDir(), '.env')
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active profile name.
|
||||
*/
|
||||
export function getActiveProfileName(): string {
|
||||
const activeFile = join(HERMES_BASE, 'active_profile')
|
||||
try {
|
||||
const name = readFileSync(activeFile, 'utf-8').trim()
|
||||
return name || 'default'
|
||||
} catch {
|
||||
return 'default'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user