mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-30 04:40:18 +08:00
fix(hermes): validate mcp sampling config
This commit is contained in:
@@ -49,6 +49,13 @@ test('Hermes MCP 服务配置保存会保留未知字段并写入 mcp_servers',
|
||||
sampling: {
|
||||
enabled: true,
|
||||
model: 'gemini-3-flash',
|
||||
max_tokens_cap: 4096,
|
||||
timeout: 30,
|
||||
max_rpm: 10,
|
||||
allowed_models: ['gemini-3-flash', 'gpt-5-mini'],
|
||||
max_tool_rounds: 5,
|
||||
log_level: 'info',
|
||||
custom_flag: 'keep-sampling',
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -62,6 +69,13 @@ test('Hermes MCP 服务配置保存会保留未知字段并写入 mcp_servers',
|
||||
sampling: {
|
||||
enabled: true,
|
||||
model: 'gemini-3-flash',
|
||||
max_tokens_cap: 4096,
|
||||
timeout: 30,
|
||||
max_rpm: 10,
|
||||
allowed_models: ['gemini-3-flash', 'gpt-5-mini'],
|
||||
max_tool_rounds: 5,
|
||||
log_level: 'info',
|
||||
custom_flag: 'keep-sampling',
|
||||
},
|
||||
},
|
||||
notion: {
|
||||
@@ -81,6 +95,13 @@ test('Hermes MCP 服务配置保存会保留未知字段并写入 mcp_servers',
|
||||
assert.equal(next.mcp_servers.time.timeout, 120)
|
||||
assert.equal(next.mcp_servers.time.sampling.enabled, true)
|
||||
assert.equal(next.mcp_servers.time.sampling.model, 'gemini-3-flash')
|
||||
assert.equal(next.mcp_servers.time.sampling.max_tokens_cap, 4096)
|
||||
assert.equal(next.mcp_servers.time.sampling.timeout, 30)
|
||||
assert.equal(next.mcp_servers.time.sampling.max_rpm, 10)
|
||||
assert.deepEqual(next.mcp_servers.time.sampling.allowed_models, ['gemini-3-flash', 'gpt-5-mini'])
|
||||
assert.equal(next.mcp_servers.time.sampling.max_tool_rounds, 5)
|
||||
assert.equal(next.mcp_servers.time.sampling.log_level, 'info')
|
||||
assert.equal(next.mcp_servers.time.sampling.custom_flag, 'keep-sampling')
|
||||
assert.equal(next.mcp_servers.notion.url, 'https://mcp.notion.com/mcp')
|
||||
assert.equal(next.mcp_servers.notion.headers.Authorization, 'Bearer token')
|
||||
assert.equal(next.mcp_servers.notion.connect_timeout, 30)
|
||||
@@ -129,4 +150,24 @@ test('Hermes MCP 服务配置保存会拒绝非法 JSON、名称、结构和超
|
||||
() => mergeHermesMcpServersConfig({}, { mcpServersJson: JSON.stringify({ time: { command: 'uvx', timeout: 0 } }) }),
|
||||
/mcp_servers\.time\.timeout/,
|
||||
)
|
||||
assert.throws(
|
||||
() => mergeHermesMcpServersConfig({}, { mcpServersJson: JSON.stringify({ time: { command: 'uvx', sampling: [] } }) }),
|
||||
/mcp_servers\.time\.sampling/,
|
||||
)
|
||||
assert.throws(
|
||||
() => mergeHermesMcpServersConfig({}, { mcpServersJson: JSON.stringify({ time: { command: 'uvx', sampling: { enabled: 'yes' } } }) }),
|
||||
/mcp_servers\.time\.sampling\.enabled/,
|
||||
)
|
||||
assert.throws(
|
||||
() => mergeHermesMcpServersConfig({}, { mcpServersJson: JSON.stringify({ time: { command: 'uvx', sampling: { allowed_models: 'gpt-5' } } }) }),
|
||||
/mcp_servers\.time\.sampling\.allowed_models/,
|
||||
)
|
||||
assert.throws(
|
||||
() => mergeHermesMcpServersConfig({}, { mcpServersJson: JSON.stringify({ time: { command: 'uvx', sampling: { max_tool_rounds: -1 } } }) }),
|
||||
/mcp_servers\.time\.sampling\.max_tool_rounds/,
|
||||
)
|
||||
assert.throws(
|
||||
() => mergeHermesMcpServersConfig({}, { mcpServersJson: JSON.stringify({ time: { command: 'uvx', sampling: { log_level: 'trace' } } }) }),
|
||||
/mcp_servers\.time\.sampling\.log_level/,
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user