欣淇
发布于 2026-05-14 / 0 阅读
0
0

🏇 Browser Harness:12.5k Stars 的自修复 CDP 浏览器控制工具,一行命令让 AI Agent 操控你的真实浏览器

🏇 Browser Harness:12.5k Stars 的自修复 CDP 浏览器控制工具,一行命令让 AI Agent 操控你的真实浏览器

项目地址:github.com/browser-use/browser-harness | ⭐ 12.5k Stars | 🐍 Python | 作者:browser-use

老实说,Browser Use 这名字在 AI Agent 圈子里基本没人不知道——93k Stars 的浏览器控制库,让 Agent 能像人一样操作网页。但 Browser Use 有个问题:它是"框架",意味着有抽象层、API 边界、预定义动作。有些场景下,你需要的是直接裸连 Chrome DevTools Protocol(CDP),没有中间层。

Browser Harness 就是干这个的。上个月刚发布就冲到 12.5k Stars,本质上是一个极简的 CDP WebSocket 桥接工具——~1k 行核心代码,四个源文件,一条命令搞定。不是替换 Browser Use,是给你多一个选择:当预定义动作不够用的时候,直接裸连 CDP。

🎯 什么是 Browser Harness?

简单说,这玩意儿在你的 Agent 和 Chrome 之间开了一条直连通道。没有 Selenium、没有 Playwright、没有 Browser Use 的抽象层——纯 CDP,你想让浏览器干嘛就干嘛。

最骚的操作是它的自修复(self-healing)能力:Agent 在跑任务时遇到当前 helper 代码不支持的场景,它会现场写代码补充缺失功能。下次同一场景直接复用,不需要手动干预。

  ● agent: wants to upload a file
  │
  ● agent-workspace/agent_helpers.py → helper missing
  │
  ● agent writes it                         agent_helpers.py
  │                                                       + custom helper
  ✓ file uploaded

说白了,这是一个能在运行时自我进化的浏览器控制工具。每个任务跑完,harness 都比之前更聪明。

⚡ 安装 & 连接 Chrome

# 克隆并安装
git clone https://github.com/browser-use/browser-harness
cd browser-harness
uv tool install -e .
command -v browser-harness

装完后在你的 Claude Code 或 Codex 里直接贴这个 prompt:

Set up https://github.com/browser-use/browser-harness for me.
Read install.md and follow the steps.

Agent 自动打开 chrome://inspect/#remote-debugging,勾上 checkbox,点 Allow,完事。有两种连接方式:

  • Way 1(推荐):用你真实的 Chrome profile,继承已登录的 session、扩展、书签。勾一次 checkbox 永久生效
  • Way 2:启动隔离的 Chrome 实例,命令行参数 --remote-debugging-port=9222 --user-data-dir=,适合无人值守场景
  • 🔧 实操:Python 代码操控浏览器

    # 打开新标签页并截图
    browser-harness <<'PY'
    new_tab("https://github.com/browser-use/browser-harness")
    wait_for_load()
    print(page_info())
    take_screenshot("/tmp/harness.png")
    PY
    
    # 使用云浏览器(Browser Use Cloud 免费 3 个并发)
    browser-harness <<'PY'
    start_remote_daemon("work", proxyCountryCode="de")
    new_tab("https://example.com")
    print(page_info())
    PY
    
    # 诊断连接状态
    browser-harness --doctor
    

    用 heredoc 传 Python 代码,所有 helper 函数预导入,daemon 自动启动/停止。不需要手动管理进程。核心架构是 Chrome → CDP WS → browser_harness.daemon → IPC → browser_harness.run,IPC 基于 Unix socket(POSIX)或 TCP loopback(Windows)。

    🤔 深度思考:为什么它值得关心?

    Browser Use 已经有了 93k Stars,Browser Harness 出来不到一个月就 12.5k,原因很简单——控制粒度不同

    我拿实际例子说:假设你的 Agent 要操作一个自定义 WebGL 画布应用。

  • Browser Use:框架里没有 get_webgl_context() 方法,你得等作者加或者自己 fork
  • Browser Harness:Agent 直接发 CDP Runtime.evaluate 跑 JS,发现缺东西就现场写 helper,下一轮就能用
  • 这也是那篇 The Bitter Lesson of Agent Harnesses 的核心观点:给 Agent 越高的自由度,它能力越强。预定义动作越多,天花板越低。

    架构上也很有意思——整个工具只有四个核心组件:

  • install.md — 首次安装和浏览器引导
  • SKILL.md — 日常使用手册
  • src/browser_harness/ — 受保护的核心包
  • agent-workspace/ — Agent 可以自由编辑的 helper 代码和 domain skills
  • 📋 总结

  • Browser Harness 是 browser-use 团队出的极简 CDP 桥接工具,~1k 行代码,一条命令安装,12.5k Stars(发布不到一个月)
  • 2. 核心杀手锏:运行时自修复——Agent 发现缺什么 helper 就现场写,越用越强

    3. 支持本地 Chrome(真实 profile / 隔离 profile)和 Browser Use Cloud 云浏览器(免费 3 并发)

    4. 适用场景:复杂网站交互、自定义 Web 应用、任何预定义动作不够用的时候

    5. 不适用场景:简单的 CRUD 操作 → 直接用 Browser Use 或其他高级封装就行

    想自己试试?三步:git cloneuv tool install → 在 Agent 里贴 setup prompt。别问为什么已经有人 Browser Use 了还要这个——用一次你就懂了。


    评论