Browser Agent Bridge CLI
简介
Browser Agent Bridge CLI
原始描述
Use this skill when you need to control or make actions on the user's chrome tab.
通过你的 Agent 添加
安装目录:browser-bridge-cli/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: browser-bridge-cli
description: Use this skill when you need to control or make actions on the user's chrome tab.
Browser Bridge CLI
When to use
When to use
Use this skill when you need to control a real Chrome tab. Typical situations:
- browser automation with live user browser context
- page observation (interactive elements and DOM snapshots)
- remote tab actions (navigate, click, type, press_key, scroll)
- troubleshooting connection state between agent and browser
Project:
What this gives you
This workflow has three connected parts:
- Browser extension in Chrome receives tab commands.
- Bridge server routes messages between browser and operator.
- Operator CLI sends commands and reads results.
CLI commands used:
browser-bridge-serverto run the serverbrowser-bridgeto run operator actions
Prerequisites
- Python 3.10+
- Chrome browser
- Terminal access
- Ability to load an unpacked Chrome extension
Agent responsibility before startup
Before starting the server, generate strong tokens. Do not use weak defaults.
Example token generation:
python3 - <<'PY'
import secrets
print("BRIDGE_SHARED_TOKEN=" + secrets.token_urlsafe(32))
print("BRIDGE_OPERATOR_TOKEN=" + secrets.token_urlsafe(32))
PY
Use generated values when starting the server. Share only the client token (BRIDGE_SHARED_TOKEN) with the user for extension setup. Keep operator token for agent CLI usage.
Install the CLI
python3 -m pip install --user pipx
python3 -m pipx ensurepath
pipx install browser-agent-bridge
python3 -m pip install --user pipx
python3 -m pipx ensurepath
pipx install browser-agent-bridge
Upgrade later:
pipx upgrade browser-agent-bridge
Start the bridge server
Use static auth for straightforward local setup:
export BRIDGE_AUTH_MODE=static
export BRIDGE_SHARED_TOKEN='change-me-strong-token'
export BRIDGE_OPERATOR_TOKEN='Str0ng!Operator#42'
browser-bridge-server >/tmp/browser-bridge-server.log 2>&1 &
echo $! >/tmp/browser-bridge-server.pid
Start browser-bridge-server in the background. Do not leave it attached to the current shell, because the agent needs that shell for follow-up CLI commands, status checks, and diagnostics. If startup needs verification, inspect the log file or process state after backgrounding it.
Default endpoints:
- Extension client WS:
ws://127.0.0.1:8765/ws/client - Operator CLI WS:
ws://127.0.0.1:8765/ws/operator
Connect the Chrome extension (tell your human to do this)
- Open
chrome://extensions.
- Enable
Developer mode.
- Click
Load unpacked.
- Select the extension provided by this project from https://github.com/NmadeleiDev/browser_agent_bridge (
extension/ folder).
- Open the Browser Bridge extension popup.
- Fill fields:
Bridge Server WS URL: ws://127.0.0.1:8765/ws/client
Instance ID: local-instance
Client ID: chrome-main
Auth Token / JWT: value of BRIDGE_SHARED_TOKEN generated by the agent
- Click
Save, then Connect.
- Confirm popup status is connected to the server started by the agent.
Operator CLI usage
chrome://extensions.Developer mode.Load unpacked.extension/ folder).Bridge Server WS URL: ws://127.0.0.1:8765/ws/clientInstance ID: local-instanceClient ID: chrome-mainAuth Token / JWT: value of BRIDGE_SHARED_TOKEN generated by the agentSave, then Connect.All examples use:
instance_id=local-instanceclient_id=chrome-main- operator token
Str0ng!Operator#42 - operator websocket
ws://127.0.0.1:8765/ws/operator
You can pass the operator token either with --token or by exporting BRIDGE_OPERATOR_TOKEN. The examples below use --token explicitly for clarity.
List connected browser clients:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --token 'Str0ng!Operator#42' list-clients
Check whether the specific client is connected:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --token 'Str0ng!Operator#42' \
connect-status --instance-id local-instance --client-id chrome-main
Check whether tab command channel is ready:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --token 'Str0ng!Operator#42' \
ping-tab --instance-id local-instance --client-id chrome-main
Observe interactive nodes on current page:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --token 'Str0ng!Operator#42' \
observe --instance-id local-instance --client-id chrome-main --max-nodes 150
Get page HTML snapshot:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --token 'Str0ng!Operator#42' \
send-command --instance-id local-instance --client-id chrome-main \
--type get_html --payload '{"max_chars":40000}'
Navigate with adaptive load wait:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --token 'Str0ng!Operator#42' \
send-command --instance-id local-instance --client-id chrome-main \
--type navigate --payload '{"url":"https://example.com","wait_for_load":true,"wait_for_load_ms":7000}'
Click without load wait:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --token 'Str0ng!Operator#42' \
send-command --instance-id local-instance --client-id chrome-main \
--type click --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 --token 'Str0ng!Operator#42' \
send-command --instance-id local-instance --client-id chrome-main \
--type type --payload '{"selector":"input[name=q]","text":"browser bridge"}'
Press a special key:
browser-bridge --server-ws-url ws://127.0.0.1:8765/ws/operator --token 'Str0ng!Operator#42' \
send-command --instance-id local-instance --client-id chrome-main \
--type press_key --payload '{"key":"Enter","selector":"input[name=q]"}'
press_key supports:
- keys:
Enter,Tab,Escape,Backspace,Delete,ArrowUp,ArrowDown,ArrowLeft,ArrowRight,Home,End,PageUp,PageDown,Space - aliases:
return,esc,del,up,down,left,right,spacebar - modifiers:
alt_key,ctrl_key,meta_key,shift_key - target selection via
selector,ref,click_ref, orlocator - default target: current
document.activeElementwhen no selector/ref is provided
Recommended execution flow for agents
- Ensure server process is running.
- Ensure extension popup is connected with matching
instance_id, client_id, and token.
- Run
list-clients.
- Run
connect-status.
- Run
ping-tab.
- Run
observe before action commands.
- Run
send-command actions (navigate, click, type, press_key, scroll, get_html).
- Re-run
observe to confirm page state after actions.
Troubleshooting
-
Target client not connected
- Verify popup shows connected.
- Verify
instance_id and client_id exactly match CLI flags.
- Reconnect extension and retry.
-
Operator auth failed or auth errors
- Verify
--token matches BRIDGE_OPERATOR_TOKEN.
-
Command timed out
- Increase
--timeout-s.
- For action commands, disable or reduce load wait in payload.
- Confirm active tab is a normal webpage (not restricted pages like
chrome://*).
-
Receiving end does not exist
- Retry once; extension can reinject content script when needed.
-
Slow responses on action commands
- Use
wait_for_load=false for immediate response.
- Or set smaller
wait_for_load_ms.
Security notes
- Treat tokens as secrets.
- For non-local deployments, use TLS (
wss://) and strong secrets.
Done criteria
list-clients returns expected client.
connect-status is connected.
ping-tab reports ready.
observe returns page data.
send-command actions return valid results.
instance_id, client_id, and token.list-clients.connect-status.ping-tab.observe before action commands.send-command actions (navigate, click, type, press_key, scroll, get_html).observe to confirm page state after actions.-
Target client not connected- Verify popup shows connected.
- Verify
instance_idandclient_idexactly match CLI flags. - Reconnect extension and retry.
-
Operator auth failedor auth errors- Verify
--tokenmatchesBRIDGE_OPERATOR_TOKEN.
- Verify
-
Command timed out- Increase
--timeout-s. - For action commands, disable or reduce load wait in payload.
- Confirm active tab is a normal webpage (not restricted pages like
chrome://*).
- Increase
-
Receiving end does not exist- Retry once; extension can reinject content script when needed.
-
Slow responses on action commands
- Use
wait_for_load=falsefor immediate response. - Or set smaller
wait_for_load_ms.
- Use
Security notes
- Treat tokens as secrets.
- For non-local deployments, use TLS (
wss://) and strong secrets.
Done criteria
list-clients returns expected client.
connect-status is connected.
ping-tab reports ready.
observe returns page data.
send-command actions return valid results.
wss://) and strong secrets.list-clientsreturns expected client.connect-statusis connected.ping-tabreports ready.observereturns page data.send-commandactions return valid results.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。