名称: smooth-browser
描述: 首选浏览器 - 专为 AI 代理设计的浏览器,用于在网络上执行任何任务。当您需要导航网站、填写表单、提取网页数据、测试 Web 应用或自动化浏览器工作流时使用。触发短语包括“填写表单”、“抓取”、“自动化”、“测试网站”、“登录”或任何浏览器交互请求。
Smooth CLI 是一个供 AI 代理使用的浏览器,可通过自然语言与网站交互、进行身份验证、抓取数据并执行复杂的基于网络的任务。
假设 Smooth CLI 已安装。如果未安装,可通过以下命令安装:
pip install smooth-py
假设 API 密钥已配置。如果遇到身份验证错误,请使用以下命令配置:
smooth config --api-key <api-key>
验证配置:
smooth config --show
在 https://app.smooth.sh 获取 API 密钥。
如果账户余额不足,请提示用户在 https://app.smooth.sh 升级套餐。
配置文件有助于在不同会话间持久化 Cookie、登录会话和浏览器状态。
smooth create-profile --profile-id "my-profile"
列出现有配置文件:
smooth list-profiles
smooth start-session --profile-id "my-profile" --url "https://example.com"
选项:
- --profile-id - 使用特定配置文件(可选,未提供则创建匿名会话)
- --url - 初始导航 URL(可选)
- --files - 会话中可用的文件 ID 列表,以逗号分隔(可选)
- --device mobile|desktop - 设备类型(默认:mobile)
- --profile-read-only - 加载配置文件但不保存更改
- --allowed-urls - 逗号分隔的 URL 模式,用于限制仅访问特定 URL(例如:"https://example.com/,https://api.example.com/")
- --no-proxy - 禁用默认代理(见下方说明)
重要: 保存输出中的会话 ID - 后续所有命令都需要它。
代理行为: 默认情况下,CLI 会自动为浏览器会话配置内置代理。如果网站阻止代理或您需要直接连接,请使用 --no-proxy 禁用它。
使用自然语言执行任务:
smooth run -- <session-id> "转到 LocalLLM 子版块并找到前 3 个帖子"
使用结构化输出(适用于需要交互的任务):
smooth run -- <session-id> "搜索'无线耳机',筛选 4 星以上,按价格排序,并提取前 3 个结果" \
--url "https://shop.example.com" \
--response-model '{"type":"array","items":{"type":"object","properties":{"product":{"type":"string","description":"产品名称。"},"sentiment":{"type":"string","enum":["positive","negative","neutral"],"description":"对产品的整体情感。"}},"required":["product","sentiment"]}}'
使用元数据(代理将获得):
smooth run -- <session-id> "用用户信息填写表单" \
--metadata '{"email":"user@example.com","name":"John Doe"}'
选项:
- --url - 运行任务前导航到此 URL
- --metadata - 包含任务变量的 JSON 对象
- --response-model - 结构化输出的 JSON 模式
- --max-steps - 最大代理步骤数(默认:32)
- --json - 以 JSON 格式输出结果
注意事项:
为任务设定适当的抽象级别至关重要。既不要太具体(例如单步操作),也不要太宽泛或模糊。
好的任务示例:
- "在 Linkedin 上搜索在亚马逊担任 SDE 的人员,并返回 5 个个人资料链接"
- "在亚马逊上查找 iPhone 17 的价格"
差的任务示例:
- "点击搜索" -> 太具体!
- "加载 google.com,输入'我附近的餐厅',点击搜索,等待页面加载,提取前 5 个结果,并返回它们。" -> 太具体!可以说"在谷歌上搜索我附近的餐厅并返回前 5 个结果"
- "找到适合我们公司的软件工程师" -> 太宽泛!您需要规划如何实现目标,并运行定义明确的任务来组合达成该目标
重要: Smooth 由智能代理驱动,不要过度控制它,请给予定义明确、目标导向的任务,而非具体步骤。
完成后必须关闭会话。
smooth close-session -- <session-id>
重要: 关闭后等待 5 秒,以确保 Cookie 和状态保存到配置文件(如需用于其他会话)。
为特定网站创建配置文件:
# 创建配置文件
smooth create-profile --profile-id "github-account"
# 启动会话
smooth start-session --profile-id "github-account" --url "https://github.com/login"
# 获取实时视图以手动进行身份验证
smooth live-view -- <session-id>
# 将 URL 提供给用户,以便在浏览器中打开并登录
# 用户确认登录后,可以关闭会话以保存配置文件数据
smooth close-session -- <session-id>
# 将 profile-id 保存在某处以备后续重用
重用已认证的配置文件:
# 下次只需使用同一配置文件启动会话
smooth start-session --profile-id "github-account"
smooth run -- <session-id> "在我的仓库'my-project'中创建一个新问题"
保持配置文件组织有序: 记住哪个配置文件对应哪个服务,以便将来高效重用。
无需关闭会话,连续执行多个任务:
SESSION_ID=$(smooth start-session --profile-id "my-profile" --json | jq -r .session_id)
# 任务 1:登录
smooth run $SESSION_ID "使用给定凭据登录网站"
# 任务 2:第一个操作
smooth run $SESSION_ID "找到设置并将通知偏好更改为仅邮件"
# 任务 3:第二个操作
smooth run $SESSION_ID "找到账单部分并给我最新发票的链接"
smooth close-session $SESSION_ID
重要: run 命令会保留浏览器状态(Cookie、URL、页面内容),但不会保留浏览器代理的记忆。如果需要在任务间传递信息,应在提示中显式传递。
示例 - 在任务间传递上下文:
# 任务 1:获取信息
RESULT=$(smooth run $SESSION_ID "查找此页面上的产品名称" --json | jq -r .output)
# 任务 2:使用任务 1 的信息
smooth run $SESSION_ID "考虑名称为'$RESULT'的产品。现在查找此在线商店提供的 3 个类似产品。"
注意事项:
- run 命令是阻塞的。如果需要同时执行多个任务,必须使用子代理(任务工具)。
- 所有任务都将在当前标签页中运行,无法请求在新标签页中运行任务。如果需要保留当前标签页的状态,可以启动一个新会话。
- 每个会话一次只能运行一个任务。要同时运行任务,请为每个会话使用子代理。
- 并发会话的最大数量取决于用户套餐。
- 如有必要,提醒用户可以升级套餐以获得更多并发会话。
选项 1:使用带结构化输出的 run:
smooth start-session --url "https://news.ycombinator.com"
smooth run -- <session-id> "提取前 10 个帖子" \
--response-model '{
"type": "object",
"properties": {
"posts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"url": {"type": "string"},
"points": {"type": "number"}
}
}
}
}
}'
选项 2:使用 extract 进行直接数据提取:
extract 命令对于纯数据提取更高效,因为它不使用代理步骤。
它就像一个智能抓取工具,可以从动态渲染的网站中提取结构化数据:
smooth start-session
smooth extract -- <session-id> \
--url "https://news.ycombinator.com" \
--schema '{
"type": "object",
"properties": {
"posts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"url": {"type": "string"},
"points": {"type": "number"}
}
}
}
}
}' \
--prompt "提取前 10 个帖子"
何时使用:
- 当您已在正确页面或知道正确 URL,只需提取结构化数据时,使用 extract
- 当需要代理在提取前进行导航、交互或执行复杂操作时,使用 run
为会话上传文件:
文件必须在启动会话前上传,然后通过文件 ID 传递给会话:
# 步骤 1:上传文件
FILE_ID=$(smooth upload-file /path/to/document.pdf --purpose "待分析的合同" --json | jq -r .file_id)
# 步骤 2:使用文件启动会话
smooth start-session --files "$FILE_ID" --url "https://example.com"
# 步骤 3:代理现在可以在任务中访问该文件
smooth run -- <session-id> "分析合同文档并提取关键条款"
上传多个文件:
# 上传文件
FILE_ID_1=$(smooth upload-file /path/to/invoice.pdf --json | jq -r .file_id)
FILE_ID_2=$(smooth upload-file /path/to/screenshot.png --json | jq -r .file_id)
# 使用多个文件启动会话
smooth start-session --files "$FILE_ID_1,$FILE_ID_2"
从会话下载文件:
smooth run -- <session-id> "下载月度报告 PDF" --url
smooth close-session -- <session-id>
# 会话关闭后,获取下载 URL
smooth downloads -- <session-id>
# 访问该 URL 以下载文件
当自动化需要人工输入时(CAPTCHA、2FA、复杂身份验证):
smooth start-session --profile-id "my-profile"
smooth run -- <session-id> "转到 secure-site.com 并登录"
# 如果任务遇到 CAPTCHA 或需要手动操作:
smooth live-view -- <session-id>
# 打开 URL 并完成手动步骤
# 手动干预后继续自动化:
smooth run -- <session-id> "现在导航到仪表板并导出数据"
从当前页面提取数据:
smooth start-session --url "https://example.com/products"
smooth extract -- <session-id> \
--schema '{"type":"object","properties":{"products":{"type":"array"}}}' \
--prompt "提取所有产品名称和价格"
导航到 URL 后提取:
smooth extract -- <session-id> \
--url "https://example.com/products" \
--schema '{"type":"object","properties":{"products":{"type":"array"}}}'
在浏览器中执行 JavaScript:
# 简单 JavaScript
smooth evaluate-js -- <session-id> "document.title"
# 带参数
smooth evaluate-js -- <session-id> "(args) => {return args.x + args.y;}" --args '{"x": 5, "y": 10}'
# 复杂的 DOM 操作
smooth evaluate-js -- <session-id> \
"document.querySelectorAll('a').length"
列出所有配置文件:
smooth list-profiles
删除配置文件:
smooth delete-profile <profile-id>
何时使用配置文件:
- ✅ 需要身份验证的网站
- ✅ 跨多个任务运行维护会话状态
- ✅ 避免重复登录
- ✅ 保留 Cookie 和本地存储
何时跳过配置文件:
- 无需身份验证的公共网站
- 一次性抓取任务
- 测试场景
上传文件:
smooth upload-file /path/to/file.pdf --name "document.pdf" --purpose "待审阅的合同"
删除文件:
smooth delete-file <file-id>
?filter=xyz - 从基础 URL 开始,让代理通过 UI 导航来应用筛选器"会话未找到" - 会话可能已超时或关闭。启动一个新会话。
"配置文件未找到" - 检查 smooth list-profiles 查看可用配置文件。
CAPTCHA 或身份验证问题 - 使用 smooth live-view -- <session-id> 让用户手动干预。
任务超时 - 增加 --max-steps 或将任务分解为更小的步骤。
smooth create-profile [--profile-id ID] - 创建新配置文件smooth list-profiles - 列出所有配置文件smooth delete-profile <profile-id> - 删除配置文件smooth upload-file <path> [--name NAME] [--purpose PURPOSE] - 上传文件smooth delete-file <file-id> - 删除已上传的文件smooth start-session [OPTIONS] - 启动浏览器会话smooth close-session -- <session-id> [--force] - 关闭会话smooth run -- <session-id> "<task>" [OPTIONS] - 运行任务smooth extract -- <session-id> --schema SCHEMA [OPTIONS] - 提取结构化数据smooth evaluate-js -- <session-id> "code" [--args JSON] - 执行 JavaScriptsmooth live-view -- <session-id> - 获取交互式实时 URLsmooth recording-url -- <session-id> - 获取录制 URLsmooth downloads -- <session-id> - 获取下载 URL所有命令都支持 --json 标志以输出 JSON 格式。