Repository navigation
feat(approval): 接入 K-brain 记住规则、拒绝说明与自动放行标记,去掉 3 分钟自动拒绝 - #1094
Merged
AlphaCatMeow merged 1 commit intoNov 1, 2026
Merged
Conversation
- K-brain 审批不设截止时间(timeoutMs: null),审批栏没有截止时间时不显示倒计时;
其他调用方仍是 3 分钟
- permission.requested 的 shell、suggestion {rules, default_scope} 进入审批存储,
同步给桌面审批栏与 WebUI;"本会话始终允许"写明要存的规则,并以 scope:"session"
发出;后端没有建议规则时行为不变
- 审批决定带 scope(仅有规则可记的 approve_session)与 reason(仅 deny),
桌面直连与 WebUI→Gateway→桌面两条路径都透传;K-brain 回 400(规则存不下、
提示仍在等待)时重新询问,最多 3 次,不再取消整轮
- permission.auto_resolved 记入桌面存储并叠加到 Gateway 同步参数,工具行(含文件
链接行)显示"只读,自动允许"/"按规则允许"
- 同步给 WebUI 的规则文本按序列化长度截到 2000 字,桌面菜单显示截到 300 字
Closes Stack-Cairn#1093
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
K-brain beta.27(#1092 已锁定)给审批提供了记住规则、自动放行事件,并且等待审批不会超时;客户端此前不读这些数据,还会在 3 分钟后替用户拒绝。本 PR 是 LA-2 的数据通路部分(LA-2a):接上这些数据,去掉自动拒绝,并在工具行说明为什么没有弹审批。审批卡片 1/2/3、作用域选择与拒绝说明输入框在 LA-2b。
Closes #1093
Depends-On: none
Stack-Root: #1094
改动
timeoutMs: null挂起(以前 3 分钟后按拒绝落定),ToolApprovalBar在没有截止时间时不显示倒计时,多项时只显示1 / N。其他调用方与 AskUserQuestion 的 3 分钟不变。KBrainPermissionRequest读shell与suggestion {rules, default_scope},进入审批存储并经 Gateway 同步参数(__toolApprovalRememberRules、__toolApprovalDefaultScope)给 WebUI。现有"本会话始终允许"显示真正要存的规则(以前显示首段命令,复合命令时与存下的不一致),有建议时以allow_always + scope:"session"发出;后端没有建议时仍发不带 scope 的 allow_always。answerToolApproval/ToolApprovalBar.onDecide/ WebUI bridge /chat_queue.tool_approvalrequest_json 带scope(仅有规则可记的 approve_session)与reason(仅 deny,去空格、截 2000)。turn.ts的resolvePermission发 scope/reason;K-brain 回 400(规则存不下,提示仍在等待)时重新询问,最多 3 次,不再取消整轮。permission.auto_resolved记入桌面存储permissionAutoResolved.ts,并叠加到 Gateway 同步参数(__toolPermissionAutoResolved);两端适配器新增usePermissionAutoResolved,ToolCallItem三种标题样式(文件链接、紧凑、完整)都显示ToolPermissionMarker:"只读,自动允许" / "按规则允许"(悬停显示规则)。标记只在内存中,重新加载历史后不显示。DISPLAY_SYNTHETIC_ARG_KEYS,不出现在参数展示里。契约面
__合成参数;不带截止标记时不发__toolApprovalDeadlineAt截图(调试版真实客户端,已裁侧栏)
审批不显示倒计时(挂起近 4 分钟仍在):

"本会话始终允许"写明要存的规则:

同一会话再次运行按规则放行:

只读工具(含文件链接行 Read)标记:

验证
typecheck:ui/typecheck:gui/typecheck:webui通过;改动文件转 LF 后biome check --line-ending=lf通过;node scripts/check-mirror.mjs通过;git diff --check通过。tools/tool-approval-remember(不超时、作用域与说明的落定规则;改前 6 个中 5 个失败)、providers/kbrain-permission-answer(shell/suggestion、scope/reason 发送、auto_resolved;改前 5 个中 4 个失败)、chat/kbrain-approval-remember(真实 K-brain SSE 下的会话轮次、Gateway overlay、WebUI 决定的 build/parse 与透传)、chat/kbrain-approval-ui(无截止不显示倒计时;三种工具行真实渲染标记,修复前文件链接行失败)。review-la2a-approval*.test.mjs保留,全部通过。复核时另发现文件链接行未显示标记(原测试只数源码出现次数),已改为真实渲染测试并修复。la-full-tests.mjs,8 批次全部运行):总计 4318,通过 4314,失败 3,跳过 1;3 个失败均为已登记环境问题(Rust 测试首次编译超过 180 秒上限;两个按 CWD 相对路径读源码的用例,在crates/agent-gui下重跑通过)。文件行标记修复在这次全量之后,修复后相关的 3 个测试文件 44 个用例与三项 typecheck 通过。git status不弹审批并显示"只读,自动允许";hostname弹审批且无倒计时,挂起近 4 分钟仍在;菜单显示"本会话始终允许 终端 · Bash(hostname:*)",选择后同会话再次运行显示"按规则允许",新会话重新询问;后端只写入一个会话规则文件Bash(hostname:*)。Read/List/Glob/Grep 四行都显示标记(另用 KB-3 本地 sidecar 复跑同样显示)。用户已验收。🤖 Generated with Claude Code