fix: select capable models and align effective permission evidence

This commit is contained in:
Agent Workbench Dev
2026-11-07 00:18:24 +08:00
parent 762597b99d
commit dcaecd8b0a
18 changed files with 572 additions and 43 deletions
+11
View File
@@ -5,6 +5,15 @@ export const ceiling = (value, restrictedMaximum) => unrestricted(value) ? Infin
export const approvalModes = ['ask', 'auto', 'full'];
export const approvalLabels = { ask: '请求批准', auto: '帮我批准', full: '完全访问权限' };
export function mcpPermissionContext(config) {
const decision = automaticApproval(config, { command: 'MCP程序' });
return { schemaVersion: 1, approvalMode: decision.mode, executionMode: config.executionMode ?? 'restricted',
action: decision.approve ? 'execute' : 'request-approval', source: decision.source };
}
export function mcpPermissionDescription(context) {
return context.action === 'execute' ? '当前完全访问权限:任务中的已启用MCP调用直接执行,无需额外询问。'
: '当前' + (approvalLabels[context.approvalMode] ?? approvalLabels.ask) + ':外部MCP调用由工作台请求批准;模型直接提交工具调用,不要先用文字重复询问。';
}
export function automaticApproval(config, action = {}) {
const mode = config.approvalMode ?? 'ask';
if (mode === 'full') return { approve: true, mode, source: 'full-access-policy' };
@@ -17,6 +26,8 @@ export function automaticApproval(config, action = {}) {
}
export function openToolDefinitions(tools, config) {
tools = tools.map(tool => tool.function.name === 'call_registered_mcp' ? { ...tool, function: { ...tool.function,
description: '调用本次目录的已启用MCP工具。' + mcpPermissionDescription(mcpPermissionContext(config)) + '先核对固定程序/实际握手/schema,不自动重试;完整结果按工件读取。' } } : tool);
if (!unrestricted(config)) return tools.filter(tool => !['rollback_change', 'open_browser_tab'].includes(tool.function.name));
const open = value => Array.isArray(value) ? value.map(open) : value && typeof value === 'object'
? Object.fromEntries(Object.entries(value).filter(([key]) => !['maxLength', 'maxItems', 'maximum'].includes(key)).map(([key, item]) => [key, open(item)])) : value;