From 6edacc3065956aad7d095656dd85782761467634 Mon Sep 17 00:00:00 2001 From: QQ Date: Tue, 10 Nov 2026 21:08:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(policy):=20=E6=9C=AA=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=BB=98=E8=AE=A4=E6=8B=A6=E6=88=AA=EF=BC=8C?= =?UTF-8?q?=E9=97=AE=E6=B8=85=E5=8F=AA=E8=AF=BB=E8=BF=98=E6=98=AF=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E3=80=81=E7=99=BB=E8=AE=B0=E5=90=8E=E6=89=8D=E6=94=BE?= =?UTF-8?q?=E8=A1=8C=EF=BC=88POLICY=5FVERSION=200.5.0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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} 的职责范围。`