Fix bridge profile environment isolation (#796)

This commit is contained in:
ekko
2026-05-16 20:27:23 +08:00
committed by GitHub
parent 7d7c8b7321
commit 8357c8ed84
8 changed files with 602 additions and 133 deletions
@@ -7,7 +7,7 @@
* - 用户自定义: HERMES_HOME 环境变量
*/
import { resolve, join } from 'path'
import { basename, dirname, resolve, join } from 'path'
import { homedir } from 'os'
/**
@@ -38,6 +38,20 @@ export function detectHermesHome(): string {
return resolve(homedir(), '.hermes')
}
/**
* Detect the Hermes root data directory.
*
* `HERMES_HOME` may intentionally point at a profile directory when launching a
* specific gateway (`<root>/profiles/<name>`). Web UI profile management needs
* the root directory so it can read `active_profile` and enumerate profiles.
*/
export function detectHermesRootHome(): string {
const home = detectHermesHome()
const parent = dirname(home)
if (basename(parent) === 'profiles') return dirname(parent)
return home
}
/**
* 获取 Hermes CLI 二进制文件路径
* @param customBin 自定义的 hermes 二进制路径