mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-07-10 23:12:05 +08:00
feat(hermes): add privacy redaction setting
This commit is contained in:
@@ -150,6 +150,15 @@ test('Hermes 配置页会暴露输入输出保护结构化配置字段', () => {
|
||||
}
|
||||
})
|
||||
|
||||
test('Hermes 配置页会暴露隐私脱敏结构化配置字段', () => {
|
||||
for (const id of [
|
||||
'hm-privacy-save',
|
||||
'hm-privacy-redact-pii',
|
||||
]) {
|
||||
assert.match(source, new RegExp(`id="${id}"`), `缺少 ${id}`)
|
||||
}
|
||||
})
|
||||
|
||||
test('Hermes 配置页会暴露终端执行结构化配置字段', () => {
|
||||
for (const id of [
|
||||
'hm-terminal-save',
|
||||
@@ -184,6 +193,7 @@ test('Hermes 配置页新增结构化配置不会暴露翻译 key', () => {
|
||||
key.includes('DisplayConfig') ||
|
||||
key.includes('StreamingConfig') ||
|
||||
key.includes('ExecutionLimits') ||
|
||||
key.includes('PrivacyConfig') ||
|
||||
key.includes('TerminalConfig')
|
||||
)))
|
||||
|
||||
|
||||
43
tests/hermes-privacy-config.test.js
Normal file
43
tests/hermes-privacy-config.test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import {
|
||||
buildHermesPrivacyConfigValues,
|
||||
mergeHermesPrivacyConfig,
|
||||
} from '../scripts/dev-api.js'
|
||||
|
||||
test('Hermes 隐私配置读取会提供上游默认值', () => {
|
||||
const values = buildHermesPrivacyConfigValues({})
|
||||
|
||||
assert.deepEqual(values, {
|
||||
redactPii: false,
|
||||
})
|
||||
})
|
||||
|
||||
test('Hermes 隐私配置读取会回显 YAML 字段', () => {
|
||||
const values = buildHermesPrivacyConfigValues({
|
||||
privacy: {
|
||||
redact_pii: true,
|
||||
},
|
||||
})
|
||||
|
||||
assert.equal(values.redactPii, true)
|
||||
})
|
||||
|
||||
test('Hermes 隐私配置保存会保留未知字段并写入上游结构', () => {
|
||||
const next = mergeHermesPrivacyConfig({
|
||||
model: { provider: 'anthropic' },
|
||||
privacy: {
|
||||
redact_pii: false,
|
||||
custom_flag: 'keep-privacy',
|
||||
},
|
||||
streaming: { enabled: true },
|
||||
}, {
|
||||
redactPii: true,
|
||||
})
|
||||
|
||||
assert.deepEqual(next.model, { provider: 'anthropic' })
|
||||
assert.deepEqual(next.streaming, { enabled: true })
|
||||
assert.equal(next.privacy.redact_pii, true)
|
||||
assert.equal(next.privacy.custom_flag, 'keep-privacy')
|
||||
})
|
||||
Reference in New Issue
Block a user