Repository navigation
feat(gateway): WebUI 设置 → 权限,经网关查看、添加、删除权限规则 - #1104
Merged
AlphaCatMeow merged 2 commits intoNov 1, 2026
Merged
AlphaCatMeow merged 2 commits into
AlphaCatMeow merged 2 commits into
Conversation
- 「智能」分组新增「权限」页:列出所有项目和所选项目的规则(规则、允许/拒绝、 添加时间、来源会话),可删除(先确认),可手动添加允许或拒绝规则。 - 列表与加载它的项目绑定:删除项目规则用规则所在的项目,切换中不显示旧项目的规则。 - 后端无 permission_rules 能力时显示升级提示;只有能访问规则接口的宿主注册此页, WebUI 在 LA-3b 接入。 - 桌面端适配器直连 /v1/permissions/rules,错误只显示 K-brain 返回的原因。 - 规则输入框里输入法确认候选词的回车不提交。 Closes Stack-Cairn#1101 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 协议:新增 PermissionRulesRequest/Response(GatewayEnvelope 111、AgentEnvelope 119), action 只有 list/add/delete;桌面端在 hello 声明 PERMISSION_RULES_V1,网关对老桌面 直接拒绝并提示更新。 - 桌面端与直连 K-brain 的网关都只转发 workspace/rule/effect/scope(project|user)/id, 会话规则不经这里;K-brain 拒绝时显示它给的原因。 - WebUI 设置适配器补上三个方法,「权限」页在 WebUI 出现;只有读取会在重连后重发。 - 共享页面:添加或删除失败后也重新读列表,应答在断线时丢失也不留下已删的规则。 Closes Stack-Cairn#1103 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
LA-3a(#1102)给桌面端加了「设置 → 权限」。WebUI 拿不到 K-brain 的地址和令牌,网关也没有转发这类请求的通道,所以 WebUI 上还没有这一页。本 PR 是 LA-3b:新增一对网关请求和应答,WebUI 发出的请求经网关交给桌面端(网关直连 K-brain 时交给 K-brain),WebUI 由此也有了「权限」页。
Closes #1103
Depends-On: #1102
Stack-Root: #1102
改动
gateway.protoPermissionRulesRequest{action, input_json}和PermissionRulesResponse{result_json};在GatewayEnvelope.permission_rules = 111和AgentEnvelope.permission_rules_resp = 119各加一个分支,都放在末尾。已用buf generate重新生成 Go 和 TS 代码PERMISSION_RULES_V1。桌面端在 hello 里声明(ws_transport.rs),网关 guard 只有看到这个能力位才放行;老桌面会立刻收到 "update LiveAgent on the desktop" 的报错,不会一直等到超时vetPermissionRules:action 只能是 list、add 或 delete;参数必须是 JSON 对象,长度不超过 32768handle_permission_rules/kbrain_permission_rules:只转发 workspace/rule/effect/scope/id,scope 只接受 project 或 user,project 必须带 workspace;在envelope_handler里 spawn 执行,不阻塞调度循环;出错时回 400internal/kbrain/permission_rules.go:Relay.PermissionRules做同样的白名单和校验,并在browser_relay里先 vet 再转发;K-brain 拒绝时只返回它在{"error"}里给的原因;应答超过 4 MiB 时报"太大"gatewaySocketRpc.permissionRules:list 断线后会重发,add 和 delete 不重放。adapters.ts负责请求映射、字段白名单和应答解码。设置适配器补上三个方法,WebUI 上出现「权限」页PermissionRulesSection.run():添加或删除失败后也重新读一次列表。这样即使删除已经执行、应答却在断线时丢失,页面也不会一直显示已删掉的规则docs/architecture/protocols.md的管理协议表里加了一行契约面
PERMISSION_RULES_V1;直连 K-brain 时由 relay 处理截图(真实 WebUI,经网关连调试版桌面端)
1024:在 WebUI 添加的拒绝规则

390:

验证
v2_kbrain_permission_rules_test);Rust:kbrain_permission_rules_maps_actions_and_rejects_bad_input,并把新能力位加进 hello 能力列表测试;WebUI:请求和应答映射、设置适配器la-full-testspnpm --filter @liveagent/gateway-webui testgo test ./...go vet通过;gofmt 检查的是 LF 副本,也通过cargo test --lib:gateway_bridge 和 ws_transportbuf lint、buf breaking --against v2-kbrian、buf generate后与提交的代码比对check-mirror.mjs、git diff --checkBash(echo webui-deny:*),作用于所有项目echo webui-deny ok未覆盖:
🤖 Generated with Claude Code