Browser Agent Bridge CLI — Browser 代理 Bridge 命令行工具
v1.0.4Use this 技能 when you need to control or make actions on the user's chrome tab.
运行时依赖
安装命令
点击复制技能文档
Browser Bridge 命令行工具 When to use
Use this 技能 when you need to control a real Chrome tab. Typical situations:
browser 自动化 with live user browser 上下文 page observation (interactive elements and DOM snapshots) remote tab actions (navigate, 命令行工具ck, type, press_key, scroll) troubleshooting connection 状态 between 代理 and browser
Project:
https://github.com/NmadeleiDev/browser_代理_bridge What this gives you
This 工作流 has three connected parts:
Browser 扩展 in Chrome 接收s tab commands. Bridge server 路由s messages between browser and operator. Operator 命令行工具 发送s commands and reads 结果s.
命令行工具 commands used:
browser-bridge-server to 运行 the server browser-bridge to 运行 operator actions Prerequisites Python 3.10+ Chrome browser Terminal 访问 Ability to load an unpacked Chrome 扩展 代理 responsibility before 启动up
Before 启动ing the server, 生成 strong 令牌s. Do not use weak defaults.
Example 令牌 generation:
python3 - <<'PY' 导入 secrets print("BRIDGE_分享D_令牌=" + secrets.令牌_urlsafe(32)) print("BRIDGE_OPERATOR_令牌=" + secrets.令牌_urlsafe(32)) PY
Use 生成d values when 启动ing the server. 分享 only the 命令行工具ent 令牌 (BRIDGE_分享D_令牌) with the user for 扩展 设置up. Keep operator 令牌 for 代理 命令行工具 usage.
安装 the 命令行工具 python3 -m pip 安装 --user pipx python3 -m pipx ensurepath pipx 安装 browser-代理-bridge
升级 later:
pipx 升级 browser-代理-bridge
启动 the bridge server
Use static auth for strAIghtforward local 设置up:
导出 BRIDGE_AUTH_MODE=static 导出 BRIDGE_分享D_令牌='change-me-strong-令牌' 导出 BRIDGE_OPERATOR_令牌='Str0ng!Operator#42' browser-bridge-server >/tmp/browser-bridge-server.记录 2>&1 & echo $! >/tmp/browser-bridge-server.pid
启动 browser-bridge-server in the background. Do not leave it attached to the current shell, because the 代理 needs that shell for follow-up 命令行工具 commands, 状态 检查s, and diagnostics. If 启动up needs verification, inspect the 记录 file or process 状态 after backgrounding it.
Default 端点s:
扩展 命令行工具ent WS: ws://127.0.0.1:8765/ws/命令行工具ent Operator 命令行工具 WS: ws://127.0.0.1:8765/ws/operator Connect the Chrome 扩展 (tell your human to do this) Open chrome://扩展s. Enable Developer mode. 命令行工具ck Load unpacked. Select the 扩展 provided by this project from https://github.com/NmadeleiDev/browser_代理_bridge (扩展/ folder). Open the Browser Bridge 扩展 popup. Fill fields: Bridge Server WS URL: ws://127.0.0.1:8765/ws/命令行工具ent Instance ID: local-instance 命令行工具ent ID: chrome-mAIn Auth 令牌 / JWT: value of BRIDGE_分享D_令牌 生成d by the 代理 命令行工具ck Save, then Connect. Confirm popup 状态 is connected to the server 启动ed by the 代理. Operator 命令行工具 usage
All examples use:
instance_id=local-instance 命令行工具ent_id=chrome-mAIn operator 令牌 Str0ng!Operator#42 operator 网页socket ws://127.0.0.1:8765/ws/operator
You can pass the operator 令牌 either with --令牌 or by 导出ing BRIDGE_OPERATOR_令牌. The examples below use --令牌 explicitly for clarity.
列出 connected browser 命令行工具ents:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --令牌 'Str0ng!Operator#42' 列出-命令行工具ents
检查 whether the specific 命令行工具ent is connected:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --令牌 'Str0ng!Operator#42' \ connect-状态 --instance-id local-instance --命令行工具ent-id chrome-mAIn
检查 whether tab command channel is ready:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --令牌 'Str0ng!Operator#42' \ ping-tab --instance-id local-instance --命令行工具ent-id chrome-mAIn
Observe interactive nodes on current page:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --令牌 'Str0ng!Operator#42' \ observe --instance-id local-instance --命令行工具ent-id chrome-mAIn --max-nodes 150
获取 page HTML snapshot:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --令牌 'Str0ng!Operator#42' \ 发送-command --instance-id local-instance --命令行工具ent-id chrome-mAIn \ --type 获取_html --payload '{"max_chars":40000}'
Navigate with adaptive load wAIt:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --令牌 'Str0ng!Operator#42' \ 发送-command --instance-id local-instance --命令行工具ent-id chrome-mAIn \ --type navigate --payload '{"url":"https://example.com","wAIt_for_load":true,"wAIt_for_load_ms":7000}'
命令行工具ck without load wAIt:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --令牌 'Str0ng!Operator#42' \ 发送-command --instance-id local-instance --命令行工具ent-id chrome-mAIn \ --type 命令行工具ck --payload '{"selector":"a[href]","wAIt_for_load":false}'
Type into an element:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --令牌 'Str0ng!Operator#42' \ 发送-command --instance-id local-instance --命令行工具ent-id chrome-mAIn \ --type type --payload '{"selector":"输入[name=q]","text":"browser bridge"}'
Press a special key:
browser-bridge --server-ws-url ws://127.0.0.1