闲社服务运行正常AI智能体自动化平台
s

Safari控制

技能标识:safari-control

Use Safari directly on macOS when work must happen in the user's real Safari session instead of a separate automation browser. Best for reading the current tab, inspecting the live session layout, operating Safari menu bar or native toolbar controls, reading page text and structure, running page JavaScript, waiting for page conditions, exporting page artifacts, and performing lightweight DOM interactions in the active Safari tab. If Safari JavaScript from Apple Events is disabled, guide the user

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.1
检测标记
后台标记通过
免费
免费获取
1
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

Safari控制

Safari 控制

当任务必须在 Safari 本身中执行时使用此技能:

  • - 用户已在该浏览器中登录
  • Safari 扩展、Cookie 或配置文件很重要
  • 你需要当前标签页、标签页列表、页面 URL 或页面文本
  • 无头浏览器无法反映真实会话

不要强制 Safari 像 Playwright 那样运行。优先使用 Safari 的会话访问和 DOM 辅助工具,其次是 Safari 原生 UI 自动化,desktop-control 仅用于重度指针操作的 UI。

核心工具

从 safari-control 技能目录运行命令,以便相对路径 scripts/ 能正确解析。

bash
swift scripts/safari_control.swift

推荐流程

除非任务明确从某个特定层开始,否则使用以下精确流程:

  1. 1. 检查环境和活动页面:

bash
swift scripts/safari_control.swift doctor
swift scripts/safari_control.swift current --json

doctor 是分支点:

  • - safarijs=false:在用户通过 Apple Events 启用 JavaScript 之前,不要使用 DOM 命令。
  • accessibility=false:不要使用原生 Safari chrome 命令。
  • screenshotbackground=false:当需要图像时,使用 screenshot --mode foreground。
  • 如果 Safari 缺少所需的权限或功能,请在继续之前告知用户。特别要检查 Safari 是否允许自动化、智能搜索字段中的 JavaScript 以及来自 Apple Events 的 JavaScript。启用这些功能可以解锁更多功能,但也会增加风险,因为自动化和脚本交互对用户的 Safari 会话拥有更多控制权。如果用户拒绝,不要继续推荐,并在功能受限的情况下继续操作。
  1. 2. 如果 Safari 会话状态很重要,在修改任何内容之前先进行检查:

bash
swift scripts/safari_control.swift list-windows --json
swift scripts/safari_control.swift list-tabs --json

  1. 3. 如果需要页面内容或网页操作,验证 DOM 访问:

bash
swift scripts/safari_control.swift check-js
swift scripts/safari_control.swift snapshot --interactive-only --limit 30

  1. 4. 选择最合适的底层:
  • - 对于页面内容、表单、链接和标准网页控件,优先使用 DOM 命令。
  • 对于智能搜索字段、工具栏按钮、标签组和菜单栏命令,使用原生 Safari 控件或菜单。
  • 仅对扩展弹窗、原生选择器、重度指针拖放或无障碍无法暴露的 UI,使用 desktop-control。
  • 当你想将用户注意力吸引到页面上的重要内容时,可以使用 JavaScript 进行视觉高亮,例如添加红色轮廓、背景色调或临时注释。

命令层

1. 环境和会话

用于机器可读的状态和标签页/窗口管理。

bash
swift scripts/safari_control.swift doctor
swift scripts/safari_control.swift current --json
swift scripts/safari_control.swift list-windows --json
swift scripts/safari_control.swift list-tabs --json
swift scripts/safari_control.swift save-session ./session.json --front-only
swift scripts/safari_control.swift restore-session ./session.json
swift scripts/safari_control.swift new-window https://example.com
swift scripts/safari_control.swift switch-window 2
swift scripts/safari_control.swift switch-tab 2 --window 1
swift scripts/safari_control.swift switch-tab-title Dashboard
swift scripts/safari_control.swift switch-tab-url /dashboard
swift scripts/safari_control.swift duplicate-tab
swift scripts/safari_control.swift close-tab --tab 2 --window 1
swift scripts/safari_control.swift close-window --window 2

规则:

  • - 对于代理可读的输出,优先使用 --json。
  • 大多数只读页面命令支持 --window N --tab M,因此你可以在不切换焦点的情况下检查后台标签页。
  • 在需要保留用户布局的侵入性操作之前,使用 save-session。
  • restore-session 是累加性的:它会重新创建窗口和标签页,不会合并或关闭当前窗口和标签页。

2. 页面读取和检查

当来自 Apple Events 的 JavaScript 已启用且目标在网页内部时使用。

bash
swift scripts/safari_control.swift snapshot --limit 20 --heading-limit 10 --form-limit 5
swift scripts/safari_control.swift snapshot --interactive-only --limit 30
swift scripts/safari_control.swift interactive --json
swift scripts/safari_control.swift query form input --json
swift scripts/safari_control.swift element-info button[type=\submit\]
swift scripts/safari_control.swift find-text Buy now --json
swift scripts/safari_control.swift exists button[data-testid=\submit\]
swift scripts/safari_control.swift count button
swift scripts/safari_control.swift get-text --mode article
swift scripts/safari_control.swift extract-links --json
swift scripts/safari_control.swift extract-tables --json
swift scripts/safari_control.swift run-js document.title
swift scripts/safari_control.swift eval-js document.querySelectorAll(\a\).length

规则:

  • - 在不熟悉的页面上进行手动探测之前,优先使用 snapshot。
  • 当只需要可操作的控件并希望输出更小时,优先使用 snapshot --interactive-only。
  • 优先使用 get-text --mode article 而不是 body;它通常噪音更少。
  • 当选择器存在但行为异常时,优先使用 element-info。

3. 页面操作和等待

在确认目标在页面内部后,用于标准 DOM 交互。

bash
swift scripts/safari_control.swift focus input[name=\email\]
swift scripts/safari_control.swift focus-text Email --selector input, textarea, select
swift scripts/safari_control.swift fill input[name=\email\] user@example.com
swift scripts/safari_control.swift click button[type=\submit\]
swift scripts/safari_control.swift click-text Continue --exact
swift scripts/safari_control.swift select-option select[name=\country\] CN --by value
swift scripts/safari_control.swift check #agree
swift scripts/safari_control.swift uncheck #agree
swift scripts/safari_control.swift upload input[type=\file\] ./avatar.png
swift scripts/safari_control.swift submit form
swift scripts/safari_control.swift wait-selector form --visible
swift scripts/safari_control.swift wait-text Success
swift scripts/safari_control.swift wait-count .result-item 10 --op ge
swift scripts/safari_control.swift wait-title Success
swift scripts/safari_control.swift wait-url /success
swift scripts/safari_control.swift wait-download report-*.csv
swift scripts/safari_control.swift reload
swift scripts/safari_control.swift back
swift scripts/safari_control.swift forward

规则:

  • - 在操作前优先使用 exists、count、wait-* 和 snapshot 进行显式分支判断。
  • 操作后,等待具体条件而不是休眠。
  • 仅对页面级 DOM 处理程序使用 press-key 和 press-shortcut,不用于 Safari chrome。
  • back、forward 和 reload 返回结构化的前后状态以进行变更检测。

4. 原生 Safari UI

当目标是 Safari chrome 而非页面时使用。

bash
swift scripts/safari_control.swift list-menu-bar --json
swift scripts/safari_control.swift list-menu-items View --json
swift scripts/safari_control.swift click-menu View Reload Page
swift scripts/safari_control.swift list-native-controls --json
swift scripts/safaricontrol.swift focus-native-control WEBBROWSERADDRESSANDSEARCHFIELD --field identifier --exact
swift scripts/safaricontrol.swift set-native-value WEBBROWSERADDRESSANDSEARCHFIELD https://example.com --field identifier --exact
swift scripts/safari_control.swift press-native-control ReloadButton --field identifier --exact
swift scripts/safaricontrol.swift perform-native-action WEBBROWSERADDRESSANDSEARCHFIELD AXConfirm --field identifier --exact
swift scripts/safari_control.swift list-native-menu-items NewTabGroupButton --field identifier --exact --json
swift scripts/safari_control.swift click-native-menu-item NewTabGroup

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 safari-control-1776050702 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 safari-control-1776050702 技能

通过命令行安装

skillhub install safari-control-1776050702

下载

⬇ 下载 safari-control v1.0.1(免费)

文件大小: 39.12 KB | 发布时间: 2026-4-14 11:18

v1.0.1 最新 2026-4-14 11:18
## Changelog / 更新日志

### Initial release / 首次发布

`safari-control` is now available on Clawhub.
`safari-control` 现已发布到 Clawhub。

This first release brings full real-session Safari automation to macOS, built for workflows where the user's actual Safari state matters: logged-in sessions, cookies, open tabs, native Safari chrome, and live page content inside the real browser.
这是首个版本,提供面向 macOS 的真实 Safari 会话自动化能力,适用于用户真实 Safari 状态很重要的场景,例如登录态、Cookie、已打开标签页、Safari 原生界面元素,以及浏览器中的实时页面内容。

### What’s included / 包含功能

- Real Safari session control
真实 Safari 会话控制

- Read the current tab, inspect windows and tabs, switch tabs, duplicate tabs, open new tabs or windows, close tabs or windows, and save or restore Safari session layouts
读取当前标签页、查看窗口和标签页、切换标签页、复制标签页、新建标签页或窗口、关闭标签页或窗口,以及保存和恢复 Safari 会话布局

- Native Safari UI automation
Safari 原生界面自动化

- List Safari menu bar items and nested menu items
列出 Safari 菜单栏项目及其嵌套菜单项

- Click Safari menu commands
点击 Safari 菜单命令

- Inspect native Safari controls such as the smart search field, toolbar buttons, tab controls, and popup controls
检查 Safari 原生控件,例如智能搜索栏、工具栏按钮、标签页控件和弹出式控件

- Focus controls, press them, set values, open native menus, and invoke specific AX actions such as `AXConfirm`
聚焦控件、点击控件、设置值、打开原生菜单,并调用特定的辅助功能动作,例如 `AXConfirm`

- Live page inspection and DOM automation
实时页面检查与 DOM 自动化

- Run JavaScript in Safari tabs
在 Safari 标签页中运行 JavaScript

- Evaluate expressions as JSON-friendly output
将表达式求值为适合 JSON 的输出

- Read page text, HTML, links, tables, interactive elements, and form state
读取页面文本、HTML、链接、表格、可交互元素以及表单状态

- Query selectors, inspect elements, find visible text, and check element existence or counts
查询选择器、检查元素、查找可见文本,并检查元素是否存在及其数量

- Perform DOM actions including click, fill, focus, hover, scroll, drag, select, check, uncheck, upload, submit, keypress, shortcut dispatch, and custom event dispatch
执行 DOM 操作,包括点击、填写、聚焦、悬停、滚动、拖拽、选择、勾选、取消勾选、上传、提交、按键、快捷键派发以及自定义事件派发

- Real Safari wait and export workflows
真实 Safari 等待与导出工作流

- Wait for selectors, text, titles, URLs, JavaScript conditions, DOM mutations, element counts, and downloads
等待选择器、文本、标题、URL、JavaScript 条件、DOM 变化、元素数量以及下载完成

- Save HTML, extracted text, links, tables, snapshots, screenshots, and complete page bundles with manifests
保存 HTML、提取文本、链接、表格、快照、截图,以及带 manifest 的完整页面打包结果

- Packaging and release support
打包与发布支持

- Build standalone binaries
构建独立二进制

- Create release folders and zip archives
创建发布目录和 zip 压缩包

- Generate build and release manifests with checksums, git metadata, and environment metadata
生成带校验和、git 元数据和环境元数据的构建与发布 manifest

### v1 improvements included in this release / 本次 v1 发布包含的改进

- Structured JSON-based Safari session inspection for current tab, windows, and tabs
基于结构化 JSON 的 Safari 会话检查,覆盖当前标签页、窗口和标签页列表

- Rich native control metadata including `pressable`, `focusable`, `settable`, and `menuable`
更丰富的原生控件元数据,包括 `pressable`、`focusable`、`settable` 和 `menuable`

- Configurable smart search confirmation modes with `ax`, `enter`, and `both`
可配置的智能搜索栏确认模式,支持 `ax`、`enter` 和 `both`

- Post-action tab-state waiting for native URL open and native search flows
在原生打开 URL 和原生搜索流程中,支持动作完成后的标签页状态等待

- Agent-friendly workflow documentation organized by session, DOM, native UI, and export layers
面向 Agent 的工作流文档,按会话、DOM、原生 UI 和导出层进行组织

- Public-facing docs updated to use relative paths and English UI examples
对外文档已更新为相对路径,并使用英文界面示例

### Important note about Safari settings / 关于 Safari 设置的重要说明

To unlock more advanced functionality, users may need to enable Safari capabilities such as:
要启用更高级的功能,用户可能需要在 Safari 中开启以下能力:

- Allow Automation
允许自动化

- Allow JavaScript in the Smart Search field
允许在智能搜索栏中使用 JavaScript

- Allow JavaScript from Apple Events
允许 Apple 事件中的 JavaScript

These settings make more of `safari-control` available, especially for native Safari automation and script-driven workflows. They also increase risk, because automation and scripting gain more power over the user’s real Safari session. Users should enable them intentionally and only when they understand that tradeoff.
这些设置会让 `safari-control` 的更多功能可用,尤其是 Safari 原生自动化和脚本驱动工作流;但与此同时也会带来更高风险,因为自动化和脚本会获得对用户真实 Safari 会话更强的控制能力。用户应在理解这一权衡的前提下,主动决定是否开启。
返回顶部