通过 inference.sh 实现 AI 代理的浏览器自动化。 支持网页导航、使用 `@e` 引用与页面元素交互、截图、录屏。 能力包括:网页抓取(web scraping)、表单填写(form filling)、点击(clicking)、输入(typing)、拖放(drag-drop)、文件上传(file upload)、JavaScript 执行。 适用场景:网页自动化、数据提取、测试、AI 代理浏览(agent browsing)、研究。 触发词:browser、web au
代理浏览器: 通过推论. sh. 使用 Playwright 的引擎盖下, 并使用简单的 @ e ref系统进行元素交互.是一项面向实际任务的技能,主要用于QQ快速启动.;Core Workflow. 每个浏览器自动。
从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;
若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。

基于 inference.sh 的 AI Agent 浏览器自动化工具。底层使用 Playwright,通过简洁的 @e 元素引用系统实现页面交互。
# 安装 CLI
curl -fsSL https://cli.inference.sh | sh && infsh login
# 打开页面并获取可交互元素
infsh app run agent-browser --function open --input '{"url": "https://example.com"}' --session new
所有浏览器自动化操作均遵循以下流程:
@e 引用@e 引用执行点击、输入、拖拽等操作# 1. 启动会话
RESULT=$(infsh app run agent-browser --function open --session new --input '{
"url": "https://example.com/login"
}')
SESSION_ID=$(echo $RESULT | jq -r '.session_id')
# 元素示例:@e1 [input] "Email",@e2 [input] "Password",@e3 [button] "Sign In"
# 2. 填写表单并提交
infsh app run agent-browser --function interact --session $SESSION_ID --input '{
"action": "fill", "ref": "@e1", "text": "user@example.com"
}'
infsh app run agent-browser --function interact --session $SESSION_ID --input '{
"action": "fill", "ref": "@e2", "text": "password123"
}'
infsh app run agent-browser --function interact --session $SESSION_ID --input '{
"action": "click", "ref": "@e3"
}'
# 3. 页面跳转后重新快照
infsh app run agent-browser --function snapshot --session $SESSION_ID --input '{}'
# 4. 完成后关闭会话
infsh app run agent-browser --function close --session $SESSION_ID --input '{}'
| 函数 | 说明 |
|---|---|
open |
导航至指定 URL,并配置浏览器参数(视口尺寸、代理、视频录制等) |
snapshot |
在 DOM 变更后重新获取页面状态及 @e 元素引用 |
interact |
基于 @e 引用执行各类操作(点击、输入、拖拽、上传等) |
screenshot |
截取当前页面截图(视口内或整页) |
execute |
在页面上下文中执行 JavaScript 代码 |
close |
关闭会话;若启用了录制,则返回视频文件 |
| 操作 | 说明 | 必需字段 |
|---|---|---|
click |
点击元素 | ref |
dblclick |
双击元素 | ref |
fill |
清空并输入文本 | ref、text |
type |
输入文本(不清空原有内容) | text |
press |
按键(如 Enter、Tab 等) | text |
select |
选择下拉框选项 | ref、text |
hover |
鼠标悬停于元素上方 | ref |
check |
勾选复选框 | ref |
uncheck |
取消勾选复选框 | ref |
drag |
拖拽并放置元素 | ref、target_ref |
upload |
上传一个或多个文件 | ref、file_paths |
scroll |
滚动页面 | direction(up/down/left/right)、scroll_amount |
back |
返回上一页(浏览器历史记录) | 无 |
wait |
等待指定毫秒数 | wait_ms |
goto |
导航至指定 URL | url |
元素以 @e 引用形式返回:
@e1 [a] "Home" href="/" @e2 [input type="text"] placeholder="Search" @e3 [button] "Submit" @e4 [select] "Choose option" @e5 [input type="checkbox"] name="agree"
注意: 页面跳转后,所有 @e 引用将失效。以下情况发生后务必调用 snapshot:
录制浏览器会话,用于调试或文档生成:
# 启用录制启动会话(可选显示光标指示器)
SESSION=$(infsh app run agent-browser --function open --session new --input '{
"url": "https://example.com",
"record_video": true,
"show_cursor": true
}' | jq -r '.session_id')
# ... 执行操作 ...
# 关闭会话以获取视频文件
infsh app run agent-browser --function close --session $SESSION --input '{}'
# 返回:{"success": true, "video": }
在截图和视频中显示可见光标(适用于演示场景):
infsh app run agent-browser --function open --session new --input '{
"url": "https://example.com",
"show_cursor": true,
"record_video": true
}'
光标以红色圆点形式呈现,随鼠标移动,并在点击时提供视觉反馈。
通过代理服务器路由网络请求:
infsh app run agent-browser --function open --session new --input '{
"url": "https://example.com",
"proxy_url": "http://proxy.example.com:8080",
"proxy_username": "user",
"proxy_password": "pass"
}'
向文件输入框上传文件:
infsh app run agent-browser --function interact --session $SESSION --input '{
"action": "upload",
"ref": "@e5",
"file_paths": ["/path/to/file.pdf"]
}'
将元素拖拽至目标位置:
infsh app run agent-browser --function interact --session $SESSION --input '{
"action": "drag",
"ref": "@e1",
"target_ref": "@e2"
}'
运行自定义 JavaScript 代码:
infsh app run agent-browser --function execute --session $SESSION --input '{
"code": "document.querySelectorAll("h2").length"
}'
# 返回:{"result": "5", "screenshot": }
| 参考文档 | 说明 |
|---|---|
| references/commands.md | 完整函数参考,含全部参数选项 |
| references/snapshot-refs.md | @e 引用生命周期、失效规则与排障指南 |
| references/session-management.md | 会话持久化机制与并发会话支持 |
| references/authentication.md | 登录流程、OAuth 集成与双因素认证(2FA)处理 |
| references/video-recording.md | 面向调试的视频录制工作流 |
| references/proxy-support.md | 代理配置详解与地域测试(geo-testing) |
| 模板 | 说明 |
|---|---|
| templates/form-automation.sh | 带校验逻辑的表单自动填充 |
| templates/authenticated-session.sh | 一次性登录,复用会话凭证 |
| templates/capture-workflow.sh | 结合截图的内容提取流程 |
SESSION=$(infsh app run agent-browser --function open --session new --input '{
"url": "https://example.com/contact"
}' | jq -r '.session_id')
# 获取元素:@e1 [input] "Name",@e2 [input] "Email",@e3 [textarea],@e4 [button] "Send"
infsh app run agent-browser --function interact --session $SESSION --input '{"action": "fill", "ref": "@e1", "text": "John Doe"}'
infsh app run agent-browser --function interact --session $SESSION --input '{"action": "fill", "ref": "@e2", "text": "john@example.com"}'
infsh app run agent-browser --function interact --session $SESSION --input '{"action": "fill", "ref": "@e3", "text": "Hello!"}'
infsh app run agent-browser --function interact --session $SESSION --input '{"action": "click", "ref": "@e4"}'
infsh app run agent-browser --function snapshot --session $SESSION --input '{}'
infsh app run agent-browser --function close --session $SESSION --input '{}'
SESSION=$(infsh app run agent-browser --function open --session new --input '{
"url": "https://google.com"
}' | jq -r '.session_id')
infsh app run agent-browser --function interact --session $SESSION --input '{"action": "fill", "ref": "@e1", "text": "weather today"}'
infsh app run agent-browser --function interact --session $SESSION --input '{"action": "press", "text": "Enter"}'
infsh app run agent-browser --function interact --session $SESSION --input '{"action": "wait", "wait_ms": 2000}'
infsh app run agent-browser --function snapshot --session $SESSION --input '{}'
infsh app run agent-browser --function close --session $SESSION --input '{}'
SESSION=$(infsh app run agent-browser --function open --session new --input '{
"url": "https://example.com",
"record_video": true
}' | jq -r '.session_id')
# 截取整页截图
infsh app run agent-browser --function screenshot --session $SESSION --input '{
"full_page": true
}'
# 关闭会话并获取视频
RESULT=$(infsh app run agent-browser --function close --session $SESSION --input '{}')
echo $RESULT | jq '.video'
浏览器状态在单个会话中保持持久。请始终遵循:
--session newsession_idclose 显式关闭会话# Web 搜索(适用于研究 + 浏览场景) npx skills add inferencesh/skills@web-search # LLM 模型(用于分析提取的内容) npx skills add inferencesh/skills@llm-models