diff --git a/index.js b/index.js index 132f2b6..c7c9ba8 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ import path from 'node:path' import { createWorkbenchHost, resolveStorePath } from './workbench/host/index.mjs' const PRESET_ID = 'sansheng-liubu' -export const POLICY_VERSION = '0.4.0' +export const POLICY_VERSION = '0.5.0' /** * 默认不强制任何 provider/model:宿主未必注册了这些适配器,强行指定会让整轮请求 @@ -173,7 +173,14 @@ export function evaluateToolPolicy(role, toolName, tasks = [], options = {}) { audit({ action: 'management-tool', role, toolName, decision: 'allow', approvalId: approval.id }) return undefined } - if (!MUTATING_TOOLS.has(toolName)) return undefined + if (!MUTATING_TOOLS.has(toolName)) { + // 走到这里的不是禁用工具,也过了签字与管理工具两关。剩下两类: + // 登记在册的只读工具、刚核验过人工签字的签字类工具,放行; + // 其余从没登记过的工具一律先拦——「没在名单里」不等于只读安全, + // 问清它只读还是会改动、登记进对应分类后才放行。 + if (READ_ONLY_TOOLSET.includes(toolName) || HUMAN_SIGNATURE_TOOLS.has(toolName)) return undefined + return `${toolName} 尚未登记分类,未知工具默认拦截:请先确认它只读还是会改动,只读的登记进只读工具集、会改动的登记进写入分类,再放行。` + } if (READ_ONLY_ROLES.has(role)) return `${role} 是只读规划、审核或调度角色,不得调用写入型工具 ${toolName}。` if (!EXECUTION_ROLES.has(role)) return `${role} 不是获准的执行部门,不能调用 ${toolName}。` if (!ROLE_ALLOWED_MUTATIONS[role]?.has(toolName)) return `${toolName} 不属于 ${role} 的职责范围。`