feat(agent): 补齐 Browser/Computer Use 动作契约并对齐 a11y 协议(P0) - #1328
Open
sheepbox8646 wants to merge 2 commits into
Open
sheepbox8646 wants to merge 2 commits into
sheepbox8646 wants to merge 2 commits into
Conversation
按 docs/computer-browser-capability-completion-plan.md 的 P0 阶段实施: - a11y-cli 与 Go 之间改为带 protocol_version 的 JSON 契约:lines 为数组、 逐项 x/y/width/height 与 states、helper_version/limit/truncated 与诊断计数; 旧 helper 或版本不匹配时返回「重建工作区镜像」错误而不是空树。 - 新增 a11y-cli locate 子命令,按 ref 从持久化索引取几何信息而不重扫; ref 的双击/三击/中键/右键据此回放真实指针事件。 - 一份动作规范同时生成 browser_action/browser_observe/computer_action/ computer_observe/browser_remote_session 的 schema、参数说明与执行前校验: 六个遗漏 action 进入枚举,别名归一化;不属于该动作的参数、冲突定位、 timeout 与 duration_ms 并存、double_click 冲突 click_count 等在副作用前拒绝。 - Browser click/double_click/hover/drag 支持 button、click_count 与视口坐标; fill 两侧接受空字符串清空,Computer 的 RFB 回退先 Select All + BackSpace; 导航/刷新/历史的就绪失败改为返回错误。 - 修复 GTK 未布局表格单元报告 i32::MIN 坐标时被当成指针目标的问题。 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Sep 19, 2026
sheepbox8646
added this pull request to stack #1343
September 20, 2026 11:59
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.
Author
Type
Summary
实施
docs/computer-browser-capability-completion-plan.md的 P0 阶段(修复现有协议和动作错误),计划文档本身也随本 PR 入库并勾选 P0 项;P1–P5 未在本 PR 中实施。问题
a11y-cli输出的lines是数组、几何字段是x/y/width/height,而 Go 侧按字符串lines和center解码:真实 helper 的快照在 Go 侧解码失败,ref 中心坐标也永远拿不到(C07/C08)。keyboard_type、keyboard_inserttext、keydown、keyup、dblclick、scrollintoview)没有进入 schema 枚举,严格 schema 调用无法表达(C01)。action/observe,错误的参数组合要到执行时才失败,部分输入被静默忽略(C02)。button,AX 双击只调一次默认动作(C03/C04)。fill的 RFB 回退只输入不清空,两侧都拒绝空文本,替换/清空语义不成立(C05)。timeout默认值与执行分支不一致,导航就绪失败被_ =吞掉(C10)。-2147483648,-2147483648的坐标,原实现会把它当成指针目标——实测双击落到了桌面左上角的 Applications 菜单(见截图 00)。改动
crates/a11y-cli输出带protocol_version(2)、helper_version、limit、truncated、数组lines、逐项几何与states;Go 侧computer_a11y.go先校验版本再解码,旧 helper 或不认识locate/--limit的 helper 返回「重建工作区镜像」错误。诊断计数返回给模型,总线地址只进日志。a11y-cli locate --ref eN:从持久化索引取几何信息,不重扫、不重新编号;ref 的双击/三击/中键/右键据此回放真实指针事件(AT-SPI 默认动作只触发一次且没有按钮)。中心不在 0–32767 范围内的元素视为无几何,指针类动作明确报错。internal/agent/tool/gui_contract.go(定义在browser_contract.go/computer_contract.go):一份规范同时生成五个工具的 schema、action参数说明和执行前校验。不属于该动作的参数、未知枚举值、越界数字、ref+selector、元素+坐标、半个坐标对、timeout+duration_ms、double_click冲突的click_count都在任何副作用之前被拒绝。click/double_click/hover/drag支持button、click_count与视口坐标;fill两侧接受空字符串清空(Browser 端同时校验元素可编辑并返回实际值,Computer 端 RFB 回退先 Select All + BackSpace);select校验选项存在;timeout只用于就绪等待(默认 30000),duration_ms用于固定等待,旧的 Computerwait.amount/ Browser 无目标wait.timeout仍单独接受;导航、刷新、历史的就绪失败改为返回错误;RFB 多次点击与滚轮步在一个批次内发送。docs/agent-runtime.md补充契约与协议说明。Related Issues
无。
Validation
自动化
cargo test -p a11y-cli:37 项通过。go test ./internal/agent/... ./internal/display/... ./internal/handlers/...:34 个包通过(新增契约校验、a11y 协议解码/版本拒绝、schema 枚举完整性等测试)。golangci-lint run ./...(仓库全量):无问题。go test ./...(仓库全量):156 个包通过,0 失败。.husky/check-go、.husky/check-go-test的内容执行的;本 PR 不含 web 文件,lint-staged无需运行。scripts/check-ui-contract.mjs报告apps/web/src/pages/home/components/tool-call-diff-panel.vue有一个 hand-spun loader,该文件在 main 上已存在且本 PR 未触碰,与本改动无关。真实运行环境
memoh-cua(devenv/docker-compose.yml+ 项目名/端口 override):Serverhttp://localhost:19880,Webhttp://localhost:19882,工作区镜像用scripts/prepare-dev-workspace-image.sh从本分支重建(含新版a11y-cli),server 重启后重新导入并重建 Bot 工作区,GET /bots/{id}/container/display返回a11y_available: true。ref+selector、timeout90000、double_click带click_count3、navigate带text、timeout+duration_ms、amount+duration_ms、无定位的click、空text的type),全部在执行前被拒绝并返回明确错误;最后一个合法wait正常完成。fill写入「新名字 Memoh 🚀」(evaluate读回一致,页面收到 input 事件)→fill空串清空(读回"")→double_click触发页面dblclick(detail 2)→button: right触发mousedown(button 2)与contextmenu→ 视口坐标click_count: 3→get_content与 screenshot。exec启动 xfce4-appfinder → snapshot(helper_version0.1.0、诊断计数)→fill输入框「term」(via a11y,列表被过滤)→button: right→ 后续 snapshot 出现menu与Cut/Copy/Paste/Delete/Select All/Insert Emoji菜单项 → Escape →fill空串清空(via a11y)→ 再过滤并double_click可见的「Terminal Emulator」行(via rfb)→ snapshot 出现frame "Terminal -"与terminal "Terminal" (focused),桌面上打开了 Xfce Terminal。double_click与右键click,两次都返回「ref … has no on-screen box …」错误,随后 snapshot 与之前一致,桌面未被误操作。computer_context、稳定 ref/generation、paste/select_text 等)不在本 PR;upload、pdf、tab_*路径只做了契约校验测试,未在真实 UI 中逐一触发。Screenshots / Recordings
截图托管在分支
computer-p0/assets(shots/)。fill通过 AT-SPI 把「term」写进应用查找器输入框,列表被过滤Human QA
🤖 Generated with Claude Code