mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-07-14 00:43:19 +08:00
feat(hermes): add memory config form
This commit is contained in:
@@ -3453,6 +3453,35 @@ export function mergeHermesToolLoopGuardrailsConfig(config = {}, form = {}) {
|
||||
return next
|
||||
}
|
||||
|
||||
export function buildHermesMemoryConfigValues(config = {}) {
|
||||
const root = config && typeof config === 'object' && !Array.isArray(config) ? config : {}
|
||||
const memory = root.memory && typeof root.memory === 'object' && !Array.isArray(root.memory)
|
||||
? root.memory
|
||||
: {}
|
||||
return {
|
||||
memoryEnabled: readHermesBool(memory.memory_enabled, true),
|
||||
userProfileEnabled: readHermesBool(memory.user_profile_enabled, true),
|
||||
memoryCharLimit: parseHermesInteger(memory.memory_char_limit, 'memory.memory_char_limit', 2200, 100, 200000, false),
|
||||
userCharLimit: parseHermesInteger(memory.user_char_limit, 'memory.user_char_limit', 1375, 100, 200000, false),
|
||||
nudgeInterval: parseHermesInteger(memory.nudge_interval, 'memory.nudge_interval', 10, 0, 1000, false),
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeHermesMemoryConfig(config = {}, form = {}) {
|
||||
const next = mergeConfigsPreservingFields({}, config && typeof config === 'object' && !Array.isArray(config) ? config : {})
|
||||
const currentValues = buildHermesMemoryConfigValues(next)
|
||||
const memory = next.memory && typeof next.memory === 'object' && !Array.isArray(next.memory)
|
||||
? mergeConfigsPreservingFields(next.memory, {})
|
||||
: {}
|
||||
memory.memory_enabled = formHermesBool(form, 'memoryEnabled', currentValues.memoryEnabled)
|
||||
memory.user_profile_enabled = formHermesBool(form, 'userProfileEnabled', currentValues.userProfileEnabled)
|
||||
memory.memory_char_limit = parseHermesInteger(Object.hasOwn(form, 'memoryCharLimit') ? form.memoryCharLimit : currentValues.memoryCharLimit, 'memory.memory_char_limit', 2200, 100, 200000, true)
|
||||
memory.user_char_limit = parseHermesInteger(Object.hasOwn(form, 'userCharLimit') ? form.userCharLimit : currentValues.userCharLimit, 'memory.user_char_limit', 1375, 100, 200000, true)
|
||||
memory.nudge_interval = parseHermesInteger(Object.hasOwn(form, 'nudgeInterval') ? form.nudgeInterval : currentValues.nudgeInterval, 'memory.nudge_interval', 10, 0, 1000, true)
|
||||
next.memory = memory
|
||||
return next
|
||||
}
|
||||
|
||||
export function buildHermesSessionRuntimeConfigValues(config = {}) {
|
||||
const root = config && typeof config === 'object' && !Array.isArray(config) ? config : {}
|
||||
const sessionReset = root.session_reset && typeof root.session_reset === 'object' && !Array.isArray(root.session_reset)
|
||||
@@ -9717,6 +9746,27 @@ const handlers = {
|
||||
}
|
||||
},
|
||||
|
||||
hermes_memory_config_read() {
|
||||
const { configPath, exists, config } = readHermesConfigYamlObject()
|
||||
return {
|
||||
exists,
|
||||
configPath,
|
||||
values: buildHermesMemoryConfigValues(config),
|
||||
}
|
||||
},
|
||||
|
||||
hermes_memory_config_save({ form } = {}) {
|
||||
const { configPath, config } = readHermesConfigYamlObject()
|
||||
const next = mergeHermesMemoryConfig(config, form || {})
|
||||
const backup = writeHermesConfigYamlObject(configPath, next)
|
||||
return {
|
||||
ok: true,
|
||||
configPath,
|
||||
backup,
|
||||
values: buildHermesMemoryConfigValues(next),
|
||||
}
|
||||
},
|
||||
|
||||
// P1-3 lazy_deps: Web 模式下不能调 venv python,但仍提供 feature 列表 + 提示用户走桌面端装
|
||||
hermes_lazy_deps_features() {
|
||||
const features = [
|
||||
|
||||
Reference in New Issue
Block a user