gui-agent-vlm 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. gui_agent_vlm-0.1.0/.gitignore +7 -0
  2. gui_agent_vlm-0.1.0/LICENSE +21 -0
  3. gui_agent_vlm-0.1.0/PKG-INFO +229 -0
  4. gui_agent_vlm-0.1.0/README.md +182 -0
  5. gui_agent_vlm-0.1.0/SKILL.md +234 -0
  6. gui_agent_vlm-0.1.0/docs/DESIGN.md +334 -0
  7. gui_agent_vlm-0.1.0/examples/basic_usage.py +56 -0
  8. gui_agent_vlm-0.1.0/examples/e2e_extended.py +188 -0
  9. gui_agent_vlm-0.1.0/examples/e2e_test.py +117 -0
  10. gui_agent_vlm-0.1.0/examples/manop_api_test.py +96 -0
  11. gui_agent_vlm-0.1.0/examples/manop_cloud_test.py +121 -0
  12. gui_agent_vlm-0.1.0/examples/ollama_e2e.py +71 -0
  13. gui_agent_vlm-0.1.0/pyproject.toml +59 -0
  14. gui_agent_vlm-0.1.0/src/browser_agent/__init__.py +13 -0
  15. gui_agent_vlm-0.1.0/src/browser_agent/agent.py +376 -0
  16. gui_agent_vlm-0.1.0/src/browser_agent/browser.py +355 -0
  17. gui_agent_vlm-0.1.0/src/browser_agent/cli.py +76 -0
  18. gui_agent_vlm-0.1.0/src/browser_agent/config.py +65 -0
  19. gui_agent_vlm-0.1.0/src/browser_agent/executors/__init__.py +107 -0
  20. gui_agent_vlm-0.1.0/src/browser_agent/executors/mano_p.py +303 -0
  21. gui_agent_vlm-0.1.0/src/browser_agent/executors/playwright.py +86 -0
  22. gui_agent_vlm-0.1.0/src/browser_agent/mcp_server.py +195 -0
  23. gui_agent_vlm-0.1.0/src/browser_agent/models/__init__.py +9 -0
  24. gui_agent_vlm-0.1.0/src/browser_agent/models/base.py +54 -0
  25. gui_agent_vlm-0.1.0/src/browser_agent/models/mano_p.py +115 -0
  26. gui_agent_vlm-0.1.0/src/browser_agent/models/ollama.py +147 -0
  27. gui_agent_vlm-0.1.0/src/browser_agent/models/openai.py +75 -0
  28. gui_agent_vlm-0.1.0/src/browser_agent/models/router.py +250 -0
  29. gui_agent_vlm-0.1.0/src/browser_agent/models/vllm.py +73 -0
  30. gui_agent_vlm-0.1.0/src/browser_agent/supervisor.py +148 -0
  31. gui_agent_vlm-0.1.0/src/browser_agent/tools/__init__.py +27 -0
  32. gui_agent_vlm-0.1.0/src/browser_agent/tools/browser_tools.py +334 -0
  33. gui_agent_vlm-0.1.0/src/browser_agent/utils/__init__.py +115 -0
  34. gui_agent_vlm-0.1.0/src/browser_agent/utils/logger.py +31 -0
  35. gui_agent_vlm-0.1.0/src/browser_agent/vision/__init__.py +7 -0
  36. gui_agent_vlm-0.1.0/src/browser_agent/vision/find_pois.js +195 -0
  37. gui_agent_vlm-0.1.0/tests/test_agent_supervised.py +152 -0
  38. gui_agent_vlm-0.1.0/tests/test_config.py +38 -0
  39. gui_agent_vlm-0.1.0/tests/test_manop.py +49 -0
  40. gui_agent_vlm-0.1.0/tests/test_models.py +50 -0
  41. gui_agent_vlm-0.1.0/tests/test_supervisor.py +156 -0
  42. gui_agent_vlm-0.1.0/tests/test_tools.py +56 -0
  43. gui_agent_vlm-0.1.0/tests/test_utils.py +57 -0
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .env
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 守一
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: gui-agent-vlm
3
+ Version: 0.1.0
4
+ Summary: GUI 自动化编排器 — 让 AI 通过纯视觉理解操作任何界面
5
+ Project-URL: Homepage, https://github.com/xyshanren/browser-agent
6
+ Project-URL: Source, https://github.com/xyshanren/browser-agent
7
+ Project-URL: Documentation, https://github.com/xyshanren/browser-agent/blob/main/README.md
8
+ Author-email: 守一 <lixy2017@aliyun.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Software Development :: Testing
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: httpx>=0.28.0
21
+ Requires-Dist: openai>=1.61.0
22
+ Requires-Dist: pillow>=11.0.0
23
+ Requires-Dist: playwright>=1.50.0
24
+ Requires-Dist: pydantic>=2.10.0
25
+ Requires-Dist: rich>=13.9.0
26
+ Requires-Dist: tenacity>=9.0.0
27
+ Provides-Extra: all
28
+ Requires-Dist: mcp>=1.0.0; extra == 'all'
29
+ Requires-Dist: mss>=10.0.0; extra == 'all'
30
+ Requires-Dist: ollama>=0.4.0; extra == 'all'
31
+ Requires-Dist: playwright-stealth>=1.0.6; extra == 'all'
32
+ Requires-Dist: pynput>=1.8.0; extra == 'all'
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest-asyncio>=0.25.0; extra == 'dev'
35
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
36
+ Requires-Dist: ruff>=0.9.0; extra == 'dev'
37
+ Provides-Extra: manop
38
+ Requires-Dist: mss>=10.0.0; extra == 'manop'
39
+ Requires-Dist: pynput>=1.8.0; extra == 'manop'
40
+ Provides-Extra: mcp
41
+ Requires-Dist: mcp>=1.0.0; extra == 'mcp'
42
+ Provides-Extra: ollama
43
+ Requires-Dist: ollama>=0.4.0; extra == 'ollama'
44
+ Provides-Extra: stealth
45
+ Requires-Dist: playwright-stealth>=1.0.6; extra == 'stealth'
46
+ Description-Content-Type: text/markdown
47
+
48
+ # Browser-Agent
49
+
50
+ <div align="center">
51
+
52
+ **GUI 自动化编排器 — 让 AI 通过纯视觉理解操作任何界面**
53
+
54
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
55
+ [![Python](https://img.shields.io/badge/Python-3.11+-blue.svg)](pyproject.toml)
56
+ [![Playwright](https://img.shields.io/badge/Playwright-1.50+-green.svg)](pyproject.toml)
57
+ [![MCP](https://img.shields.io/badge/MCP-ready-purple.svg)](SKILL.md)
58
+
59
+ </div>
60
+
61
+ ---
62
+
63
+ ## 快速开始
64
+
65
+ ```bash
66
+ pip install browser-agent
67
+ playwright install chromium
68
+ ```
69
+
70
+ ### 使用
71
+
72
+ ```python
73
+ from browser_agent import BrowserAgent
74
+
75
+ # 自动检测可用模型(Mano-P > Ollama > vLLM > LM Studio)
76
+ agent = BrowserAgent()
77
+ result = agent.run("搜索今天深圳的天气并告诉我结果")
78
+ print(result.text)
79
+ ```
80
+
81
+ 或通过 CLI:
82
+ ```bash
83
+ browser-agent "搜索今天深圳的天气"
84
+ ```
85
+
86
+ ### 指定模型
87
+
88
+ ```bash
89
+ browser-agent --model-type ollama --model qwen3-vl:2b "搜索深圳天气"
90
+ browser-agent --model-type openai --model gpt-4o --api-key sk-xxx "搜索深圳天气"
91
+ browser-agent --model-type manop "搜索深圳天气" # Mano-P 云端
92
+ ```
93
+
94
+ ## 架构
95
+
96
+ ```
97
+ Agent (高层规划)
98
+ │ "帮我查天气、整理文件、发邮件"
99
+
100
+ browser-agent (编排器 + ModelRouter 自动选模型)
101
+ │ Observe → Think → Act → Verify
102
+
103
+ ├── PlaywrightExecutor (浏览器)
104
+ │ └── 通过 VLM 截图理解 + 操作
105
+
106
+ └── ManoPExecutor (桌面 GUI)
107
+ └── 纯视觉定位(Mano-P 云端 API)
108
+ ```
109
+
110
+ - **执行器可插拔** — Playwright(Web)/ Mano-P(桌面 GUI)
111
+ - **模型自动检测** — Mano-P → Ollama → vLLM → LM Studio 自动回退
112
+ - **三种调用方式** — CLI / Python API / MCP Server
113
+
114
+ ## 跨平台支持
115
+
116
+ browser-agent 是纯 Python 项目,依赖全部跨平台,支持 **Linux、Windows、macOS**。
117
+
118
+ ### 平台兼容性矩阵
119
+
120
+ | 场景 | Linux 原生 | WSL2 | Windows 原生 | macOS |
121
+ |------|-----------|------|-------------|-------|
122
+ | Playwright headless | ✅ | ✅ | ✅ | ✅ |
123
+ | Playwright headed | ✅ Xvfb/X11 | ✅ WSLg(Win11)/Xvfb(Win10) | ✅ | ✅ |
124
+ | Ollama 本地 VLM | ✅ | ✅ | ✅ | ✅ |
125
+ | vLLM GPU | ✅ 最优 | ⚠️ GPU 穿透复杂 | ⚠️ CUDA | ⚠️ Metal |
126
+ | LM Studio | ❌ | ❌ | ✅ | ✅ |
127
+ | Mano-P 桌面 GUI | ❌ | ❌ | ❌ | ✅ MLX |
128
+
129
+ ### WSL2 中使用(Hermes Agent 典型场景)
130
+
131
+ Hermes Agent 运行在 WSL2 中时,browser-agent 可直接装在 WSL2 内使用:
132
+
133
+ ```bash
134
+ # WSL2 中安装
135
+ pip install browser-agent playwright
136
+ playwright install chromium
137
+ playwright install-deps chromium # 安装 Linux 系统依赖
138
+
139
+ # 使用(headless 模式,无需显示环境)
140
+ browser-agent "搜索今天深圳的天气"
141
+ ```
142
+
143
+ **headless 模式完全不需要显示环境**,Playwright 在 WSL2 中运行无任何障碍。
144
+
145
+ 如需查看浏览器窗口(调试用):
146
+ - **Windows 11**: WSLg 自动支持,`--no-headless` 即可
147
+ - **Windows 10**: 需安装 X 服务器(如 VcXsrv),设置 `DISPLAY=:0`
148
+
149
+ ### 跨平台调用(WSL2 Hermes → Windows browser-agent)
150
+
151
+ 如果需要在 WSL2 中调用 Windows 原生桌面上的浏览器或 Mano-P:
152
+
153
+ ```bash
154
+ # 方案 1: 全部在 WSL2 内完成(推荐)
155
+ # browser-agent 在 WSL2 中启动自己的 Chromium 进程,无需操作 Windows 浏览器
156
+ browser-agent "搜索深圳天气"
157
+
158
+ # 方案 2: 通过 MCP 桥接 Windows
159
+ # Windows 上启动 MCP Server
160
+ # PowerShell: browser-agent-mcp
161
+ # WSL2 中的 Hermes 通过 host.docker.internal:PORT 连接
162
+ ```
163
+
164
+ > **关键理解**: Playwright 启动的是自己管理的 Chromium 实例,不是操作"系统上已经打开的浏览器"。因此 WSL2 里的 browser-agent 无需与 Windows 端的浏览器交互——它自己在 WSL2 中启动 Chromium 即可。
165
+
166
+ ## 模型选择
167
+
168
+ browser-agent 内置 ModelRouter,自动检测可用 VLM:
169
+
170
+ | 优先级 | 模型源 | 如何启用 |
171
+ |--------|--------|----------|
172
+ | P0 | 用户显式指定 | `--model-type` / `--model` 参数 |
173
+ | P1 | Ollama | 运行 `ollama serve` + 拉取 VLM 模型 |
174
+ | P2 | vLLM | `vllm serve Qwen/Qwen2.5-VL-* --port 8000` |
175
+ | P3 | LM Studio | 启动并加载 VLM 模型 |
176
+ | P4 | Agent 注入 | 设置 `BROWSER_AGENT_FALLBACK_*` 环境变量 |
177
+
178
+ Mano-P 云端 API 也已集成,代码就绪,但需要明略科技提供的 API key(`MANOP_API_KEY`),目前暂未开放注册。有 key 后可作为显式指定使用:`--model-type manop`。
179
+
180
+ 任何 AI Agent 可以通过环境变量将自己的模型注入 browser-agent:
181
+
182
+ ```bash
183
+ export BROWSER_AGENT_FALLBACK_MODEL_TYPE=openai
184
+ export BROWSER_AGENT_FALLBACK_MODEL=gpt-4o
185
+ export BROWSER_AGENT_FALLBACK_API_KEY=sk-xxx
186
+ ```
187
+
188
+ ## MCP Server
189
+
190
+ browser-agent 内置 MCP Server,可被任何 MCP 兼容客户端调用:
191
+
192
+ ```json
193
+ {
194
+ "mcpServers": {
195
+ "browser-agent": {
196
+ "command": "python",
197
+ "args": ["-m", "browser_agent.mcp_server"]
198
+ }
199
+ }
200
+ }
201
+ ```
202
+
203
+ 支持工具:`browser_navigate` / `browser_screenshot` / `browser_click` / `browser_type` / `browser_extract`
204
+
205
+ ## 作为 Agent Skill 使用
206
+
207
+ 参阅 [SKILL.md](SKILL.md) — 支持 CLI、Python API、MCP Server 三种集成方式。
208
+
209
+ ## Mano-P 集成
210
+
211
+ Mano-P 是明略科技开源的 GUI-VLA 模型,代码已集成,但暂未默认启用。
212
+
213
+ | 场景 | 方案 | 状态 |
214
+ |:----|:------|:----:|
215
+ | Web 浏览器 | PlaywrightExecutor + 本地 VLM | ✅ 生产可用 |
216
+ | 桌面软件/3D/专业工具 | ManoPExecutor + Mano-P Cloud API | ⚠️ 代码就绪,需 `MANOP_API_KEY`(暂未开放注册) |
217
+ | Mano-P 本地推理 | 直接在本地运行模型 | ⏳ 仅 macOS Apple Silicon,等待 NVIDIA CUDA 开源 |
218
+
219
+ > 注意:Mano-P 不在自动检测队列中。持有了 `MANOP_API_KEY` 后通过 `--model-type manop` 显式指定即可使用。
220
+
221
+ ## 测试
222
+
223
+ ```bash
224
+ pytest tests/ -v
225
+ ```
226
+
227
+ ## 许可证
228
+
229
+ MIT
@@ -0,0 +1,182 @@
1
+ # Browser-Agent
2
+
3
+ <div align="center">
4
+
5
+ **GUI 自动化编排器 — 让 AI 通过纯视觉理解操作任何界面**
6
+
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
+ [![Python](https://img.shields.io/badge/Python-3.11+-blue.svg)](pyproject.toml)
9
+ [![Playwright](https://img.shields.io/badge/Playwright-1.50+-green.svg)](pyproject.toml)
10
+ [![MCP](https://img.shields.io/badge/MCP-ready-purple.svg)](SKILL.md)
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## 快速开始
17
+
18
+ ```bash
19
+ pip install browser-agent
20
+ playwright install chromium
21
+ ```
22
+
23
+ ### 使用
24
+
25
+ ```python
26
+ from browser_agent import BrowserAgent
27
+
28
+ # 自动检测可用模型(Mano-P > Ollama > vLLM > LM Studio)
29
+ agent = BrowserAgent()
30
+ result = agent.run("搜索今天深圳的天气并告诉我结果")
31
+ print(result.text)
32
+ ```
33
+
34
+ 或通过 CLI:
35
+ ```bash
36
+ browser-agent "搜索今天深圳的天气"
37
+ ```
38
+
39
+ ### 指定模型
40
+
41
+ ```bash
42
+ browser-agent --model-type ollama --model qwen3-vl:2b "搜索深圳天气"
43
+ browser-agent --model-type openai --model gpt-4o --api-key sk-xxx "搜索深圳天气"
44
+ browser-agent --model-type manop "搜索深圳天气" # Mano-P 云端
45
+ ```
46
+
47
+ ## 架构
48
+
49
+ ```
50
+ Agent (高层规划)
51
+ │ "帮我查天气、整理文件、发邮件"
52
+
53
+ browser-agent (编排器 + ModelRouter 自动选模型)
54
+ │ Observe → Think → Act → Verify
55
+
56
+ ├── PlaywrightExecutor (浏览器)
57
+ │ └── 通过 VLM 截图理解 + 操作
58
+
59
+ └── ManoPExecutor (桌面 GUI)
60
+ └── 纯视觉定位(Mano-P 云端 API)
61
+ ```
62
+
63
+ - **执行器可插拔** — Playwright(Web)/ Mano-P(桌面 GUI)
64
+ - **模型自动检测** — Mano-P → Ollama → vLLM → LM Studio 自动回退
65
+ - **三种调用方式** — CLI / Python API / MCP Server
66
+
67
+ ## 跨平台支持
68
+
69
+ browser-agent 是纯 Python 项目,依赖全部跨平台,支持 **Linux、Windows、macOS**。
70
+
71
+ ### 平台兼容性矩阵
72
+
73
+ | 场景 | Linux 原生 | WSL2 | Windows 原生 | macOS |
74
+ |------|-----------|------|-------------|-------|
75
+ | Playwright headless | ✅ | ✅ | ✅ | ✅ |
76
+ | Playwright headed | ✅ Xvfb/X11 | ✅ WSLg(Win11)/Xvfb(Win10) | ✅ | ✅ |
77
+ | Ollama 本地 VLM | ✅ | ✅ | ✅ | ✅ |
78
+ | vLLM GPU | ✅ 最优 | ⚠️ GPU 穿透复杂 | ⚠️ CUDA | ⚠️ Metal |
79
+ | LM Studio | ❌ | ❌ | ✅ | ✅ |
80
+ | Mano-P 桌面 GUI | ❌ | ❌ | ❌ | ✅ MLX |
81
+
82
+ ### WSL2 中使用(Hermes Agent 典型场景)
83
+
84
+ Hermes Agent 运行在 WSL2 中时,browser-agent 可直接装在 WSL2 内使用:
85
+
86
+ ```bash
87
+ # WSL2 中安装
88
+ pip install browser-agent playwright
89
+ playwright install chromium
90
+ playwright install-deps chromium # 安装 Linux 系统依赖
91
+
92
+ # 使用(headless 模式,无需显示环境)
93
+ browser-agent "搜索今天深圳的天气"
94
+ ```
95
+
96
+ **headless 模式完全不需要显示环境**,Playwright 在 WSL2 中运行无任何障碍。
97
+
98
+ 如需查看浏览器窗口(调试用):
99
+ - **Windows 11**: WSLg 自动支持,`--no-headless` 即可
100
+ - **Windows 10**: 需安装 X 服务器(如 VcXsrv),设置 `DISPLAY=:0`
101
+
102
+ ### 跨平台调用(WSL2 Hermes → Windows browser-agent)
103
+
104
+ 如果需要在 WSL2 中调用 Windows 原生桌面上的浏览器或 Mano-P:
105
+
106
+ ```bash
107
+ # 方案 1: 全部在 WSL2 内完成(推荐)
108
+ # browser-agent 在 WSL2 中启动自己的 Chromium 进程,无需操作 Windows 浏览器
109
+ browser-agent "搜索深圳天气"
110
+
111
+ # 方案 2: 通过 MCP 桥接 Windows
112
+ # Windows 上启动 MCP Server
113
+ # PowerShell: browser-agent-mcp
114
+ # WSL2 中的 Hermes 通过 host.docker.internal:PORT 连接
115
+ ```
116
+
117
+ > **关键理解**: Playwright 启动的是自己管理的 Chromium 实例,不是操作"系统上已经打开的浏览器"。因此 WSL2 里的 browser-agent 无需与 Windows 端的浏览器交互——它自己在 WSL2 中启动 Chromium 即可。
118
+
119
+ ## 模型选择
120
+
121
+ browser-agent 内置 ModelRouter,自动检测可用 VLM:
122
+
123
+ | 优先级 | 模型源 | 如何启用 |
124
+ |--------|--------|----------|
125
+ | P0 | 用户显式指定 | `--model-type` / `--model` 参数 |
126
+ | P1 | Ollama | 运行 `ollama serve` + 拉取 VLM 模型 |
127
+ | P2 | vLLM | `vllm serve Qwen/Qwen2.5-VL-* --port 8000` |
128
+ | P3 | LM Studio | 启动并加载 VLM 模型 |
129
+ | P4 | Agent 注入 | 设置 `BROWSER_AGENT_FALLBACK_*` 环境变量 |
130
+
131
+ Mano-P 云端 API 也已集成,代码就绪,但需要明略科技提供的 API key(`MANOP_API_KEY`),目前暂未开放注册。有 key 后可作为显式指定使用:`--model-type manop`。
132
+
133
+ 任何 AI Agent 可以通过环境变量将自己的模型注入 browser-agent:
134
+
135
+ ```bash
136
+ export BROWSER_AGENT_FALLBACK_MODEL_TYPE=openai
137
+ export BROWSER_AGENT_FALLBACK_MODEL=gpt-4o
138
+ export BROWSER_AGENT_FALLBACK_API_KEY=sk-xxx
139
+ ```
140
+
141
+ ## MCP Server
142
+
143
+ browser-agent 内置 MCP Server,可被任何 MCP 兼容客户端调用:
144
+
145
+ ```json
146
+ {
147
+ "mcpServers": {
148
+ "browser-agent": {
149
+ "command": "python",
150
+ "args": ["-m", "browser_agent.mcp_server"]
151
+ }
152
+ }
153
+ }
154
+ ```
155
+
156
+ 支持工具:`browser_navigate` / `browser_screenshot` / `browser_click` / `browser_type` / `browser_extract`
157
+
158
+ ## 作为 Agent Skill 使用
159
+
160
+ 参阅 [SKILL.md](SKILL.md) — 支持 CLI、Python API、MCP Server 三种集成方式。
161
+
162
+ ## Mano-P 集成
163
+
164
+ Mano-P 是明略科技开源的 GUI-VLA 模型,代码已集成,但暂未默认启用。
165
+
166
+ | 场景 | 方案 | 状态 |
167
+ |:----|:------|:----:|
168
+ | Web 浏览器 | PlaywrightExecutor + 本地 VLM | ✅ 生产可用 |
169
+ | 桌面软件/3D/专业工具 | ManoPExecutor + Mano-P Cloud API | ⚠️ 代码就绪,需 `MANOP_API_KEY`(暂未开放注册) |
170
+ | Mano-P 本地推理 | 直接在本地运行模型 | ⏳ 仅 macOS Apple Silicon,等待 NVIDIA CUDA 开源 |
171
+
172
+ > 注意:Mano-P 不在自动检测队列中。持有了 `MANOP_API_KEY` 后通过 `--model-type manop` 显式指定即可使用。
173
+
174
+ ## 测试
175
+
176
+ ```bash
177
+ pytest tests/ -v
178
+ ```
179
+
180
+ ## 许可证
181
+
182
+ MIT
@@ -0,0 +1,234 @@
1
+ ---
2
+ name: browser-agent
3
+ description: 浏览器/桌面 GUI 自动化工具。通过纯视觉理解操作界面,支持搜索、填表、数据抓取等任务。支持自动检测本地 VLM / Mano-P 云端 API / Agent 模型注入三种模型源。
4
+ version: 1.2.0
5
+ author: xyshanren
6
+ license: MIT
7
+ metadata:
8
+ hermes:
9
+ tags: [Browser-Automation, GUI-VLA, Web-Scraping, Vision-Language-Model, MCP]
10
+ related_skills: [cli, web-development]
11
+ homepage: https://github.com/xyshanren/browser-agent
12
+ mcp:
13
+ server_name: browser-agent
14
+ tools: [browser_navigate, browser_screenshot, browser_click, browser_type, browser_extract]
15
+ prerequisites:
16
+ commands: [python3, pip3]
17
+ env_vars: []
18
+ run_once:
19
+ - command: pip3 install browser-agent playwright
20
+ description: 安装 browser-agent 及其依赖
21
+ - command: python3 -m playwright install chromium
22
+ description: 安装 Playwright 浏览器引擎
23
+ - command: pip3 install "browser-agent[mcp]"
24
+ description: 安装 MCP 支持(可选)
25
+ required_environment_variables: []
26
+ ---
27
+
28
+ # Browser-Agent: GUI 自动化工具
29
+
30
+ 通过 AI 视觉理解自动操作浏览器/桌面界面。支持:
31
+ - 🌐 网页搜索、数据抓取、表单填写
32
+ - 📊 提取结构化数据(表格、列表、价格)
33
+ - 🔄 多步骤任务编排(先查天气、再搜索、最后汇总)
34
+ - 🖥️ 浏览器操作(点击、输入、滚动、导航)
35
+
36
+ ## 工作原理
37
+
38
+ ```
39
+ 用户输入任务 → ModelRouter 自动选模型 → 截图观察页面 → VLM 理解内容 → 规划操作 → 执行操作 → 返回结果
40
+ ```
41
+
42
+ 模型选择(无需手动配置,自动检测):
43
+
44
+ | 优先级 | 模型源 | 检测方式 |
45
+ |--------|--------|----------|
46
+ | P0 | 显式指定 | `--model-type` / `--model` 参数 |
47
+ | P1 | 本地 VLM (Ollama / vLLM / LM Studio) | 自动 ping localhost 端口 |
48
+ | P2 | Agent 模型注入 | `BROWSER_AGENT_FALLBACK_*` 环境变量 |
49
+
50
+ Mano-P 云端 API 也已集成(代码就绪,需 `MANOP_API_KEY`),有 key 后通过 `--model-type manop` 显式指定即可。
51
+
52
+ ## 使用方法
53
+
54
+ ### 基础任务
55
+
56
+ ```terminal
57
+ browser-agent "搜索今天深圳的天气"
58
+ ```
59
+
60
+ ### 显示浏览器窗口(调试用)
61
+
62
+ ```terminal
63
+ browser-agent --no-headless "帮我登录 GitHub 检查通知"
64
+ ```
65
+
66
+ ### 流式查看每一步
67
+
68
+ ```terminal
69
+ browser-agent --stream "搜索 Python 3.13 新特性并总结"
70
+ ```
71
+
72
+ ### 使用不同模型
73
+
74
+ 不指定模型时,ModelRouter 自动检测可用模型:
75
+
76
+ ```terminal
77
+ # 自动检测:Mano-P > Ollama > vLLM > LM Studio > Agent 注入
78
+ browser-agent "搜索今天深圳的天气"
79
+ ```
80
+
81
+ 也支持手动指定:
82
+
83
+ ```terminal
84
+ # 本地 vLLM
85
+ browser-agent --model-type vllm --model "Qwen/Qwen2.5-VL-3B-Instruct" --api-base "http://localhost:8000/v1" "..."
86
+
87
+ # OpenAI API
88
+ browser-agent --model-type openai --model gpt-4o --api-key "sk-xxx" "..."
89
+
90
+ # Mano-P 云端(GUI专用)
91
+ browser-agent --model-type manop "..."
92
+ ```
93
+
94
+ ### Python 集成
95
+
96
+ ```python
97
+ from browser_agent import BrowserAgent
98
+
99
+ # 自动检测模型
100
+ agent = BrowserAgent()
101
+ result = agent.run("打开百度,搜索今天深圳的天气,告诉我温度和湿度")
102
+
103
+ # 显式指定模型
104
+ agent = BrowserAgent(model_type="ollama", model="qwen3-vl:2b")
105
+ result = agent.run("搜索深圳天气")
106
+ print(result.text)
107
+ ```
108
+
109
+ ## 多步骤编排
110
+
111
+ 对于复杂任务,Hermes Agent 可以分步调用 browser-agent:
112
+
113
+ ```terminal
114
+ # 步骤 1: 收集信息
115
+ browser-agent "打开百度,搜索深圳今天天气,提取温度和风力"
116
+
117
+ # 步骤 2: 对比分析(基于步骤 1 的结果继续)
118
+ browser-agent "打开百度,搜索广州今天天气,和深圳对比"
119
+
120
+ # 或使用 Python 一次性编排
121
+ python -c "
122
+ from browser_agent import BrowserAgent
123
+ a = BrowserAgent()
124
+ r1 = a.run('搜索深圳天气')
125
+ print('深圳:', r1.text)
126
+ r2 = a.run('搜索广州天气')
127
+ print('广州:', r2.text)
128
+ print('综合:', r1.text, r2.text)
129
+ "
130
+ ```
131
+
132
+ ## 注意事项
133
+
134
+ 1. **模型自动选择**: 不指定模型时,ModelRouter 按 P1→P2→P3 优先级自动检测。可用 `--model-type` 显式覆盖。
135
+ 2. **本地 VLM**: 如使用本地模型,需先安装并运行 Ollama / vLLM / LM Studio。Ollama: `ollama pull qwen3-vl:2b && ollama serve`
136
+ 3. **Mano-P 云端**: 设置 `MANOP_API_KEY` 环境变量即可启用,无需本地 GPU。
137
+ 4. **Agent 模型注入**: 调用方可设置 `BROWSER_AGENT_FALLBACK_*` 环境变量传递备选模型,仅 VLM 模型有效。
138
+ 5. **headless 模式(默认)**: 浏览器在后台运行,不显示窗口。
139
+ 6. **耗时任务**: 模型推理需要时间,每步约 5-15 秒。
140
+ 7. **反爬检测**: 部分网站可能拦截自动化操作,可尝试 `--no-headless` 降低被检测概率。
141
+
142
+ ### 跨平台说明
143
+
144
+ browser-agent 是纯 Python 项目,**Android 和 iOS 除外**,主流平台均可运行:
145
+
146
+ | 平台 | Playwright headless | Playwright headed | Ollama | 备注 |
147
+ |------|-------------------|-------------------|--------|------|
148
+ | Linux 原生 | ✅ | ✅ 需 Xvfb/X11 | ✅ | 服务器部署首选 |
149
+ | WSL2 | ✅ | ✅ WSLg(Win11)/Xvfb(Win10) | ✅ | Hermes Agent 典型场景 |
150
+ | Windows 原生 | ✅ | ✅ | ✅ | 桌面自动化首选 |
151
+ | macOS | ✅ | ✅ | ✅ | 开发调试友好 |
152
+
153
+ **WSL2 关键说明**:Playwright 在 WSL2 中 headless 模式运行无需任何额外配置。Hermes Agent 与 browser-agent 都装在 WSL2 内即可正常使用。Mano-P(桌面 GUI 自动化)目前仅支持 macOS Apple Silicon,Windows/Linux 暂不支持,等待其第三阶段开源。详见 [跨平台支持](README.md#跨平台支持)。
154
+
155
+ ---
156
+
157
+ ## MCP Server 模式
158
+
159
+ browser-agent 内置 MCP Server,可以被**任何 MCP 兼容客户端**调用:
160
+
161
+ ### Claude Desktop 配置
162
+
163
+ ```json
164
+ // Windows: %APPDATA%\Claude\claude_desktop_config.json
165
+ // macOS: ~/.config/Claude/claude_desktop_config.json
166
+ {
167
+ "mcpServers": {
168
+ "browser-agent": {
169
+ "command": "python",
170
+ "args": ["-m", "browser_agent.mcp_server"]
171
+ }
172
+ }
173
+ }
174
+ ```
175
+
176
+ ### Cline / Cursor / Continue 配置
177
+
178
+ 在对应的 MCP settings 中添加:
179
+
180
+ ```json
181
+ {
182
+ "mcpServers": {
183
+ "browser-agent": {
184
+ "command": "python",
185
+ "args": ["-m", "browser_agent.mcp_server"]
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ ### MCP 工具列表
192
+
193
+ | 工具 | 说明 | 参数 |
194
+ |------|------|------|
195
+ | `browser_navigate` | 执行浏览器任务 | `task` (必填), `headless`, `max_steps` |
196
+ | `browser_screenshot` | 截图当前页面 | `describe` (是否描述内容) |
197
+ | `browser_click` | 点击元素 | `x`, `y` 或 `description` |
198
+ | `browser_type` | 输入文本 | `text` (必填), `submit` |
199
+ | `browser_extract` | 提取结构化数据 | `query` (必填), `format` |
200
+
201
+ ### 使用示例
202
+
203
+ ```
204
+ 用户: 帮我搜索一下 GitHub 上的热门 AI 项目
205
+ ↓ MCP 调用 browser_navigate
206
+ ↓ Agent 执行任务并返回结果
207
+ ```
208
+
209
+ ---
210
+
211
+ ## 多 Agent 共享
212
+
213
+ browser-agent 作为独立 Python 包,支持被多个 Agent 框架共享:
214
+
215
+ ### 方式 A: pip 安装(推荐)
216
+
217
+ ```bash
218
+ pip install browser-agent
219
+ # 直接 import 使用
220
+ ```
221
+
222
+ ### 方式 B: MCP Server(跨框架通用)
223
+
224
+ 任何支持 MCP 的 Agent 框架都能通过 MCP Server 调用 browser-agent。
225
+
226
+ ### 方式 C: Agent 模型注入
227
+
228
+ 调用方可设置环境变量让 browser-agent 使用 Agent 自身的模型(需为 VLM):
229
+
230
+ ```bash
231
+ export BROWSER_AGENT_FALLBACK_MODEL_TYPE=openai
232
+ export BROWSER_AGENT_FALLBACK_MODEL=gpt-4o
233
+ export BROWSER_AGENT_FALLBACK_API_KEY=sk-xxx
234
+ ```