Conversation
4ier
left a comment
There was a problem hiding this comment.
Code Review
方向正确,几个需要修的问题:
1. status.ready 逻辑有 bug — optional checks 不应影响 ready
status.ready 初始 true,任何 check 失败就 flip 到 false。但 WebSocket bridge 和 IndexedDB captures 都是 optional 的——bridge 不跑是正常的,captures 为 0 也不阻碍 neo read/snapshot/open。
当前逻辑:bridge 没跑 → ready = false → agent 以为环境没准备好。
修复:只有 Chrome CDP 和 extension 这两个 critical checks 失败才 flip ready。或者给 check 加个 optional 标记。
2. doctor --fix 的 CDP 检测是 dead code
fixFn 只在 fn 抛异常时才执行。fn 已经 fetch(CDP_URL/json/version) 失败了才进 fixFn。在 fixFn 里又 fetch 同一个 URL——如果 fn 刚失败,fixFn 里也一定失败(除非在这几毫秒内 Chrome 被外部启动了,极端 race condition)。
实际上这个检测永远走不到 return Already running 分支。这段代码无害但也无用,删掉更干净,或者加个 short sleep 再重试。
3. neo start --force 没有杀旧进程
现在 --force 只跳过检测,直接 spawn 新 Chrome。但如果旧 Chrome 占着 9222 端口,新实例会绑端口失败静默启动到其他端口。--force 要么:
- 明确告诉用户"端口已被占用,需要先关闭现有 Chrome"
- 要么真的 kill 旧进程再启动
当前行为是两边都不做,容易让人困惑。
4. actions 消息在 fix 成功路径上漏了
当 --fix 成功修复了 extension,status.extension = true 了但 status.ready 还是被之前的 catch 设成了 false。fix 成功后应该 re-evaluate ready。
Minor
NEO_STATUS:行的status.captures在 extension 不可用时会留默认值 0 而非 -1 或 null,agent 可能误认为"有 extension 但 0 条 capture"。考虑用null表示"无法检测"。
011226d to
5b26bec
Compare
- neo start: detect existing Chrome CDP before launching new instance - neo doctor --fix: don't blindly restart Chrome if already running - neo doctor: always output NEO_STATUS JSON line with actionable instructions - Prevents agents from killing user's Chrome or looping on startup failures
5b26bec to
59f7568
Compare
问题
AI agent(Neal_5 等)使用 Neo 时反复失败,根因:
neo start盲目启动新 Chrome 实例,杀掉用户正在用的 Chromeneo doctor报错信息对 agent 不可操作——只说 "Not found" 没说该做什么neo doctor --fix也会盲目重启 ChromeAgent 陷入循环:手动启动 headless Chrome → 没扩展 → 复制 profile → 又没登录态 → pkill chrome → 再试...
改动
neo start:检测已有 Chrome启动前先检查 CDP 端口是否已有 Chrome 在跑:
--force→ 跳过检测,强制启动neo doctor --fix:不盲目重启Chrome CDP fix 先检测是否已在运行:
neo startneo doctor:输出结构化状态末尾始终输出一行 JSON:
actions数组包含精确的下一步指令,agent 可直接解析和执行。验证