Repository navigation
fix(acp): 对齐 ACP v1 规范、参考适配器映射与 Zed 1.21 增量 - #279
Merged
3 commits merged intoSep 24, 2026
Merged
3 commits merged into
3 commits merged into
Conversation
added 3 commits
September 23, 2026 23:20
zuno-acp 有四处与 ACP v1 schema 及参考实现 codex-acp 不一致:
- `session/set_mode` 未派发。规范仍把它列为专用模式方法(横幅说明将来会移除),
Zed 等客户端会先调它;现在翻译成 `mode` 配置项走同一份 thread 设置,返回 `{}`
- 桥接层自有结果用了 `-32001`/`-32002`:前者与 App Server 队列满时透传的 OVERLOADED
同码,客户端无法区分"prompt 已并入活动 turn"与"请求失败";后者与 ACP 的
"Resource not found" 同码。改为两侧都空闲的 `-32010`/`-32011`,session.rs 改用常量,
并加测试断言不与任一保留码重合
- `resource` 的 blob 无条件当图片,`resource_link` 压成 "Resource name: uri" 丢掉
名字语义。现按 codex-acp 的形状映射:`resource_link` → `[@name](uri)`(无名时取
file:// 的文件名);文本 `resource` → 链接 + `<context ref="uri">` 块;`image/*`
blob → 图片;其他 blob → 带 mimeType 的 base64 `<context>` 块;`image` 块带
http(s)/data URI 时直接使用。未宣告的块类型(audio)仍以 -32602 拒绝
- `initialize` 只读 protocolVersion:现校验 `clientCapabilities`/`clientInfo` 必须是
对象并记录 debug 日志。桥接层不调用 fs/terminal 客户端方法,所以能力值不改变行为
`cargo test -p zuno-acp`(10 个单测)与 `cargo test -p codex-cli --test acp` 通过,
clippy -D warnings 干净。文档同步说明映射规则与错误码。
Zed 1.21 把 Rust SDK 升到 agent-client-protocol 2.1(schema 1.7),但 initialize 仍发 protocolVersion 1;SDK 与 schema 版本不决定线协议兼容性,v2 仍是草案且 Zed 未采纳, 所以桥接层不需要重设计,只补协议 1 内客户端已开始依赖的增量: - tool_call 更新加一等 `name`(schema 1.8):shell / apply_patch / web_search / spawn_agent(Zed 以此识别子代理)/ MCP 与动态工具自身名字 / view_image / image_generation / sleep。Zed #64080 起优先读 `name`,`_meta.tool_name` 只是遗留回退 - contextCompaction、enteredReviewMode、exitedReviewMode、functionCallOutput 不再被投影为 工具调用(此前 contextCompaction 会显示成一个标题为 contextCompaction 的工具卡) - initialize 记录 clientCapabilities;客户端宣告 elicitation.form 时, item/tool/requestUserInput 通过一次 elicitation/create 表单收集:选择题→enum、自由文本 →string,decline/cancel 映射为 -32800;机密问题按规范拒绝。无表单能力的客户端保持 request_permission 选择题 + 自由文本拒绝的旧行为 新增 12 个单测覆盖 name/排除表/表单构造与回填;clippy -D warnings 与 fmt 通过。文档新增 "协议版本与客户端兼容"一节说明三条版本轴。
core 的 request_user_input 规范化后每题都带非空 options 且 is_other = true(客户端负责 加"其他");上一提交把有选项的问题一律映射成封闭 enum,会让支持表单的 ACP 客户端无法 提交列表外答案。现在带 isOther 的问题保持 string 属性并在 description 里列出建议选项, 只有不带 isOther 的问题才用 enum。测试改用生产形状(options + isOther),同时保留无 options 的遗留形状。`clientCapabilities.elicitation.form` 只在是对象时算支持。
sunerpy
pushed a commit
that referenced
this pull request
Sep 24, 2026
对抗式复审(对 #278/#279/#280 集成分支)确认的缺陷与本轮处理: ACP(codex-rs/zuno-acp) - 桥接把 App Server 的审批/提问请求放在事件循环的 select! 分支内同步等待 客户端应答,而应答帧只能由同一循环轮询的传输层读到,因此任何一次 session/request_permission 或 elicitation/create 都会让桥接永久挂起。 现在每个 App Server 请求在 JoinSet 任务里等待,事件循环继续读取传输层 与投影通知,完成后再 resolve/reject。新增端到端回归测试 native_acp_completes_a_turn_after_the_client_answers_a_permission_request (mock 模型发出需审批的 shell 调用,客户端回答 allow_once 后 prompt 必须以 end_turn 结束):修复前 94 秒超时失败,修复后 5 秒通过。 上游同步 workflow(.github/workflows/zuno-upstream-sync.yml) - 默认 GITHUB_TOKEN 排下的 auto-merge 被 GitHub 合并后产生的 pull_request: closed 事件不会启动任何 workflow,zuno-release.yml 永远不会晋升,发布会 静默缺失。现在只有配置了 ZUNO_UPSTREAM_SYNC_TOKEN 才排队,否则留言说明。 - 队列绑定巡检推送的精确 head:PR 正文新增 Zuno-Candidate-Commit trailer, state 步在每一轮(含 skip 路径)发现 head 不等于该提交且 auto-merge 仍启用 时撤回并留言,协作者向候选分支推送后不再会被免人工合入。 - 撤回旧队列提前到 PR 步与冲突步的最前面,失败即中止(不再 || true), 避免后续命令失败留下过期队列。 - issue 的关闭改用默认 token(自动化 PAT 不再需要 issues 权限),关闭 被取代 PR/issue 失败只告警不中止;PR 正文的重叠路径列表截断到 200 条。 - 边界脚本钉住以上守卫:USING_DEFAULT_TOKEN 分支、pr_number 撤回、 Zuno-Candidate-Commit、撤回先于关闭、禁止吞掉撤回失败、禁止 --trust-local-tags。 同步脚本(scripts/zuno_upstream.py、scripts/zuno_rebrand.py) - 所选 rust-v* 标签必须与 openai/codex 远端发布的提交一致 (verify_tag_on_remote,git ls-remote 取 peeled 提交),只存在于 origin 的 伪造标签被拒绝;--trust-local-tags 仅供离线演练,巡检永不传。 - 源码永不改名:.rs 文件里上游新增的行只在字符串字面量与 // 注释内改名 (rust_text_spans / rebrand_new_text),基线已有的行按谓词结果完整改名; 受影响文件以 guarded 列入报告与 PR 正文。 文档与契约 - docs/zuno-upstream-sync*.md:免人工三项前置条件(secret、Allow auto-merge、 无人工评审)、暂停自动化须先关 automatic_merge 或撤回队列、标签来源校验、 Cargo.toml 版本行例外、--reuse 遇规则变化的行为、token 暴露的残余风险。 - FORK_REBRAND.toml 不再声称门禁快照测试会兜底 [[added]];FORK_DELTA.toml 与 UPSTREAM_CODEX.toml 的契约/注释同步;ZUNO_ARCHITECTURE.md 示例注释改为 policy next;docs/zuno-acp*.md 说明审批/提问不再阻塞传输层。 本地验证:check_zuno_update_boundaries.py OK、actionlint OK、ruff OK、 test_zuno_upstream.py + test_zuno_rebrand.py 48 个测试通过、 cargo test -p codex-cli --test acp(2)与 cargo test -p zuno-acp(12)通过、 cargo clippy -p zuno-acp -p codex-cli --all-targets -- -D warnings 通过、 cargo fmt --check 干净。
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.
背景
zuno-acp有四处与 ACP v1 schema 及参考实现agentclientprotocol/codex-acp不一致。改动
session/set_mode:规范仍列为专用模式方法(横幅注明将来会移除),Zed 等客户端会先调它。现在翻译成mode配置项,走与session/set_config_option相同的线程设置更新,返回{}。-32001/-32002。前者与 App Server 队列满时透传的 OVERLOADED 同码,客户端无法区分"prompt 已并入活动 turn"与"请求失败";后者与 ACP 的 Resource not found 同码。改为两侧都空闲的-32010/-32011,session.rs改用常量,并加测试断言不与任一保留码重合。resource的 blob 原先无条件当图片,resource_link压成 "Resource name: uri"。现按 codex-acp 的buildPromptItems形状映射:resource_link→[@name](uri)(无名时取file://的文件名);文本resource→ 链接 +<context ref="uri">块;image/*blob → 图片;其他 blob → 带 mimeType 的 base64<context>块;image块带 http(s)/data URI 时直接使用。未宣告的块类型(audio)仍以-32602拒绝。initialize:校验clientCapabilities/clientInfo必须是对象并记录 debug 日志。桥接层不调用 fs/terminal 客户端方法,能力值不改变行为。验证
cargo test -p zuno-acp(10 个单测,含新增的映射、错误码、set_mode、initialize 校验)cargo test -p codex-cli --test acp(stdio 端到端 initialize)cargo clippy -p zuno-acp --all-targets -- -D warnings、cargo fmt --checkdocs/zuno-acp.md(含 zh-CN)同步说明映射规则与错误码。错误码、ContentBlock 映射无法在 CI 端到端验证(需要真实模型调用),只靠纯函数单测。