pi: 档位判定 tool_call hook + 心跳报 native

- worker.mjs: mailContext 加 permissionMode 字段(从 SSE payload 读入)
- tool_call hook 增加档位判定:
  full → 不拦截任何工具(直接 return)
  plan → 被守卫工具(bash/write/edit)一律 block + 返回原因说明
  workspace → 走原有问人流程(不变)
- index.mjs 心跳上报 mode_enforcement: 'native'
- 导入 normalizeMode/MODE_FULL/MODE_PLAN 从 lib/permission-mode.js
- 377 测试全过
This commit is contained in:
2026-09-06 19:19:42 +08:00
parent 3bb419f2f2
commit 0c98fab4d5
2 changed files with 16 additions and 1 deletions

View File

@ -322,6 +322,7 @@ async function main() {
const beat = async () => {
const [platform_sessions, models] = await Promise.all([reportSessions(), reportModels()]);
const body = {};
body.mode_enforcement = 'native'; // tool_call hook 能 block bash/write/edit
if (platform_sessions) body.platform_sessions = platform_sessions;
if (models) body.models = models;
try {