Repository navigation
fix(herdr): macOS 首启 CLI 不再被 Gatekeeper 杀掉,重试不留空窗格、不误 resume - #2029
Merged
deepcoldy merged 2 commits intoOct 20, 2026
Merged
Conversation
- macOS 上 zsh 直接执行 botmux 刚写出的启动脚本时,系统会先扣住这次 exec 做 Gatekeeper 联网评估;Herdr 按脚本名就能认出 agent,startPaneAgent 改名后 立刻在 finally 里删掉脚本,XProtect 随后打不开文件,判定失败并 SIGKILL 首启 CLI(窗格里显示 zsh: killed)。识别成功后改为让启动器自删,只保留 60 秒的 兜底清理;启动失败的路径仍立即删除。 - 托管 agent 退出后,worker 在重启前就丢掉了这个 backend,没人再关它的窗格, 每次崩溃重试都会在宿主会话里留下一个空 shell 窗格。handleExit 时由拥有该 agent 的 backend 关闭自己的窗格;接管外部窗格(adopt)不受影响。
进程内重启固定带 resume,Claude 的探测在项目目录存在、但本会话 jsonl 不存在时 返回「不确定」,于是首启就失败的新会话会先跑一次 `--resume <id>`,报 No conversation found 再退出,要第二次重启才被强制改成新会话。没有记录过 CLI 会话 id 时,唯一可恢复的就是本会话自己的 jsonl,它不存在即可判定无可恢复, 直接按新会话启动。
nengqi
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
October 19, 2026 12:14
Owner
|
你好,这个 PR 的自动评审群已建,麻烦点击链接加入群聊、查看评审意见并跟进后续修改: 另外你暂时不在自动拉群名单里,也可以把 GitHub 账号和飞书信息补进名单文档,补好后后续评审会自动拉你进群:https://bytedance.larkoffice.com/wiki/WJ1nwWbtxi89erkNGNbcgkt9nUe (本条为自动流程发出的提示消息) |
Owner
PR #2029 首审(自动评审,最终以维护者审阅为准)|head c97ce2f|结论:0 阻断,可合
|
Owner
|
🚀 Released in v3.48.0 |
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.
现象
macOS 上用 Herdr 后端新开话题,稳定复现:
zsh: killed <launcher>;--resume <id>启动,报No conversation found with session ID;原因
Terminating process due to Gatekeeper rejection: <pid>,pid 与 Herdr 日志里该窗格 agent 的 pgid 一致。zsh 直接执行 botmux 刚写出的启动脚本时,系统先扣住这次 exec 做 Gatekeeper 评估(含一次联网查询,冷连接约 0.5 秒)。这期间 Herdr 已能按 argv 认出 agent,startPaneAgent改名后在finally里删掉了脚本;随后的 XProtect 扫描报The file “claude” couldn’t be opened … scan failed,评估失败即拒绝,进程被 SIGKILL。连接变热后评估能赶在删除前完成,所以后面的重试能起来。onExit先把backend置空,之后的restartCliProcess拿不到旧 backend,不会调用destroySession(),窗格里剩下的 shell 没人关。resume: true重拉;Claude 的checkResumeTargetExists在项目目录存在(同目录其它会话会创建它)、但本会话 jsonl 不存在时返回「不确定」,于是先跑一次必然失败的--resume,要等第二次重启的 tier-2 兜底才改成新会话。改了什么
herdr-backend.tsrm -f "$0",exec 放行后才会执行到),后端只保留 60 秒兜底清理;启动失败的路径仍立即删除。handleExit:拥有该 agent(ownsAgent)的 backend 在 CLI 退出后关闭自己的窗格;externalTarget(/adopt 接管的外部窗格)不关。claude-code.ts:没有记录过 CLI 会话 id、且本会话 jsonl 不存在时,checkResumeTargetExists返回false。此时唯一可恢复的就是本会话自己的 jsonl,它不存在就可以判定无可恢复,直接按新会话启动;worker 已有逻辑会在「从没写过对话记录」时压掉「上下文丢失」提示。影响面
bmx-*会话不变。/cd换目录后同步过对话记录的会话都不受影响。tmux 等其它后端遇到同样的首启失败也会直接走新会话。测试验证
npx tsc --noEmit -p .:通过npx vitest run --project unit test/herdr-backend.test.ts test/cli-adapters.test.ts test/tmux-reattach-backend.test.ts:624 passed,1 skipped。新增用例:识别后保留启动脚本、60 秒后兜底清理;托管 agent 退出时关窗格、非托管不关;Claude 探测的三种情况。vitest run --project unit里其余失败在 master 上同样失败(本机环境相关),没有新增。Terminating记录;窗格里/exit后窗格自动关闭,下一轮在新窗格里接上原来的上下文。另在单独的 Herdr 会话里kill -9CLI,它的窗格自动关闭,同一 Tab 的其它窗格不受影响。(真机验证用的是同时包含 Herdr 放置功能的构建,见另一个 PR。)🤖 Generated with Claude Code