mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-29 20:30:00 +08:00
feat(hermes): add lsp diagnostic controls
This commit is contained in:
@@ -3329,6 +3329,8 @@ const HERMES_TERMINAL_VERCEL_RUNTIMES = new Set(['node24', 'node22', 'python3.13
|
||||
const HERMES_BROWSER_ENGINES = new Set(['auto', 'lightpanda', 'chrome'])
|
||||
const HERMES_BROWSER_DIALOG_POLICIES = new Set(['must_respond', 'auto_dismiss', 'auto_accept'])
|
||||
const HERMES_WEB_BACKENDS = new Set(['tavily', 'firecrawl', 'parallel', 'exa', 'searxng', 'brave', 'brave_free', 'ddgs', 'xai', 'native'])
|
||||
const HERMES_LSP_WAIT_MODES = new Set(['document', 'full'])
|
||||
const HERMES_LSP_INSTALL_STRATEGIES = new Set(['auto', 'manual', 'off'])
|
||||
const HERMES_STT_PROVIDERS = new Set(['auto', 'local', 'groq', 'openai', 'mistral'])
|
||||
const HERMES_STT_LOCAL_MODELS = new Set(['tiny', 'base', 'small', 'medium', 'large-v3', 'turbo'])
|
||||
const HERMES_STT_OPENAI_MODELS = new Set(['whisper-1', 'gpt-4o-mini-transcribe', 'gpt-4o-transcribe'])
|
||||
@@ -3497,6 +3499,20 @@ function normalizeHermesWebBackend(value, key, strict = false) {
|
||||
return ''
|
||||
}
|
||||
|
||||
function normalizeHermesLspWaitMode(value, strict = false) {
|
||||
const mode = String(value ?? '').trim().toLowerCase() || 'document'
|
||||
if (HERMES_LSP_WAIT_MODES.has(mode)) return mode
|
||||
if (strict) throw new Error('lsp.wait_mode 必须是 document 或 full')
|
||||
return 'document'
|
||||
}
|
||||
|
||||
function normalizeHermesLspInstallStrategy(value, strict = false) {
|
||||
const strategy = String(value ?? '').trim().toLowerCase() || 'auto'
|
||||
if (HERMES_LSP_INSTALL_STRATEGIES.has(strategy)) return strategy
|
||||
if (strict) throw new Error('lsp.install_strategy 必须是 auto、manual 或 off')
|
||||
return 'auto'
|
||||
}
|
||||
|
||||
function normalizeHermesSttProvider(value, strict = false) {
|
||||
const provider = String(value ?? '').trim().toLowerCase() || 'auto'
|
||||
if (HERMES_STT_PROVIDERS.has(provider)) return provider
|
||||
@@ -5535,6 +5551,33 @@ export function mergeHermesWebConfig(config = {}, form = {}) {
|
||||
return next
|
||||
}
|
||||
|
||||
export function buildHermesLspConfigValues(config = {}) {
|
||||
const root = config && typeof config === 'object' && !Array.isArray(config) ? config : {}
|
||||
const lsp = root.lsp && typeof root.lsp === 'object' && !Array.isArray(root.lsp)
|
||||
? root.lsp
|
||||
: {}
|
||||
return {
|
||||
lspEnabled: readHermesBool(lsp.enabled, true),
|
||||
lspWaitMode: normalizeHermesLspWaitMode(lsp.wait_mode, false),
|
||||
lspWaitTimeout: parseHermesFloat(lsp.wait_timeout, 'lsp.wait_timeout', 5, 0.1, 120, false),
|
||||
lspInstallStrategy: normalizeHermesLspInstallStrategy(lsp.install_strategy, false),
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeHermesLspConfig(config = {}, form = {}) {
|
||||
const next = mergeConfigsPreservingFields({}, config && typeof config === 'object' && !Array.isArray(config) ? config : {})
|
||||
const currentValues = buildHermesLspConfigValues(next)
|
||||
const lsp = next.lsp && typeof next.lsp === 'object' && !Array.isArray(next.lsp)
|
||||
? mergeConfigsPreservingFields(next.lsp, {})
|
||||
: {}
|
||||
lsp.enabled = formHermesBool(form, 'lspEnabled', currentValues.lspEnabled)
|
||||
lsp.wait_mode = normalizeHermesLspWaitMode(Object.hasOwn(form, 'lspWaitMode') ? form.lspWaitMode : currentValues.lspWaitMode, true)
|
||||
lsp.wait_timeout = parseHermesFloat(Object.hasOwn(form, 'lspWaitTimeout') ? form.lspWaitTimeout : currentValues.lspWaitTimeout, 'lsp.wait_timeout', 5, 0.1, 120, true)
|
||||
lsp.install_strategy = normalizeHermesLspInstallStrategy(Object.hasOwn(form, 'lspInstallStrategy') ? form.lspInstallStrategy : currentValues.lspInstallStrategy, true)
|
||||
next.lsp = lsp
|
||||
return next
|
||||
}
|
||||
|
||||
export function buildHermesSttConfigValues(config = {}) {
|
||||
const root = config && typeof config === 'object' && !Array.isArray(config) ? config : {}
|
||||
const stt = root.stt && typeof root.stt === 'object' && !Array.isArray(root.stt)
|
||||
@@ -12838,6 +12881,27 @@ const handlers = {
|
||||
}
|
||||
},
|
||||
|
||||
hermes_lsp_config_read() {
|
||||
const { configPath, exists, config } = readHermesConfigYamlObject()
|
||||
return {
|
||||
exists,
|
||||
configPath,
|
||||
values: buildHermesLspConfigValues(config),
|
||||
}
|
||||
},
|
||||
|
||||
hermes_lsp_config_save({ form } = {}) {
|
||||
const { configPath, config } = readHermesConfigYamlObject()
|
||||
const next = mergeHermesLspConfig(config, form || {})
|
||||
const backup = writeHermesConfigYamlObject(configPath, next)
|
||||
return {
|
||||
ok: true,
|
||||
configPath,
|
||||
backup,
|
||||
values: buildHermesLspConfigValues(next),
|
||||
}
|
||||
},
|
||||
|
||||
hermes_stt_config_read() {
|
||||
const { configPath, exists, config } = readHermesConfigYamlObject()
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user