Files
Hermes-ui/packages/server/src/services/hermes/hermes-profile.ts
T
ekko 9a9416c99c Fix bridge history, profile models, and Windows gateway handling (#845)
* feat: support profile-aware group chat bridge flows

* feat: route cron jobs through hermes cli

* Fix group chat routing and isolate bridge tests

* Add Grok image-to-video media skill

* Default Grok videos to media directory

* Fix bridge profile fallback and cron repeat clearing

* Refine bridge chat and gateway platform handling

* Filter bridge tool-call text deltas

* Preserve structured bridge chat history

* Prepare beta release build artifacts

* Fix Windows run profile resolution

* Fix Windows path compatibility checks

* Fix profile-scoped model page display

* Hide Windows subprocess windows for jobs and updates

* Hide Windows file backend subprocess windows

* Avoid Windows gateway restart lock conflicts

* Treat Windows gateway lock as running on startup

* Force release Windows gateway lock on restart

* Tighten Windows gateway lock cleanup

* Update chat e2e source expectation

* Bump package version to 0.5.30

---------

Co-authored-by: Codex <codex@openai.com>
2026-05-19 16:09:59 +08:00

90 lines
2.3 KiB
TypeScript

import { join } from 'path'
import { readFileSync, existsSync, readdirSync } from 'fs'
import { detectHermesRootHome } from './hermes-path'
export function getHermesBaseDir(): string {
return detectHermesRootHome()
}
/**
* Get the active profile's home directory.
* default → ~/.hermes/
* other → ~/.hermes/profiles/{name}/
*/
export function getActiveProfileDir(): string {
const hermesBase = getHermesBaseDir()
const activeFile = join(hermesBase, 'active_profile')
try {
const name = readFileSync(activeFile, 'utf-8').trim()
if (name && name !== 'default') {
const dir = join(hermesBase, 'profiles', name)
if (existsSync(dir)) return dir
}
} catch { }
return hermesBase
}
/**
* 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(getHermesBaseDir(), 'active_profile')
try {
const name = readFileSync(activeFile, 'utf-8').trim()
return name || 'default'
} catch {
return 'default'
}
}
/**
* Get profile directory by name.
* default → ~/.hermes/
* other → ~/.hermes/profiles/{name}/
*/
export function getProfileDir(name: string): string {
const hermesBase = getHermesBaseDir()
if (!name || name === 'default') return hermesBase
const dir = join(hermesBase, 'profiles', name)
return existsSync(dir) ? dir : hermesBase
}
export function listProfileNamesFromDisk(): string[] {
const hermesBase = getHermesBaseDir()
const names = new Set<string>(['default'])
const profilesDir = join(hermesBase, 'profiles')
try {
for (const entry of readdirSync(profilesDir, { withFileTypes: true })) {
if (entry.isDirectory() && entry.name.trim()) {
names.add(entry.name)
}
}
} catch {}
return [...names].sort((a, b) => {
if (a === 'default') return -1
if (b === 'default') return 1
return a.localeCompare(b)
})
}