环境:macOS + DSH NEXT 客户端。Computer Use 是随客户端内置、默认关闭的 experimental bundle;开启后才会注册
cua工具到 PTC 会话。 本文记录:怎么开插件与权限、实际测了哪些场景、每个场景的截图与结论。
一、先开启插件与系统权限
1. 开启 Computer Use 插件
在 DSH NEXT 左侧栏进入 插件 → 更多 → 实验性插件,找到 Computer Use,打开开关。
- 该 bundle 随客户端提供,开启时无需下载。
- 开启后会准备本机 helper,并出现权限页面;详情页可设置 PTC、设为持久化。
- 关闭时工具会从 Agent 作用域撤回,已保存授权保留。
本机实测也可通过用户 patch 开启(把 bundle 的 cordis.patch.yml 内容 insert 进 ~/.dsh/profiles/desktop/cordis.patch.yml),但官方推荐走界面开关。
2. 给 helper 授予 macOS 系统权限(截图失败的根因)
这是最容易踩坑的地方。 Computer Use 不在 DSH NEXT 进程里截图,而是通过一个独立的 helper app:DSH Computer Use.app。给终端、DSH NEXT 本身授权都不生效,必须给这个 helper 授权。
实测教训:系统设置里很容易顺手把 DSH NEXT 的屏幕录制打开,但那没用——列表里要找的是 DSH Computer Use。开完后回
getCapabilities()看screenRecording是否变成 true,别凭「我开了」判断。另一个坑:
Computer Use目录下通常有两个 hash 子文件夹(新旧两份 helper)。系统设置的 + 弹窗里要选当前正在运行的那个。用ps aux | grep 'dsh-cua-native --serve'看进程路径里的 hash,进对应文件夹选DSH Computer Use.app。两个都加也行(bundle id 相同、不冲突),但至少要加当前运行的那个。谁来做:这些是 macOS 系统授权,Agent 无法代劳。如果
getCapabilities()的screenRecording仍是 false,必须明确通知用户本人去系统设置添加并授权,然后重启 DSH NEXT;不要反复尝试 CUA 截图,也不要改用open -a激活窗口去绕过。
helper 在哪
启用插件后,helper 会被释放到本机并运行。用下面命令确认它是否在运行、拿到准确路径:
ps aux | grep 'dsh-cua-native --serve'
本机实测路径:
~/Library/Application Support/DeepSeek Harness/Computer Use/<hash>/DSH Computer Use.app
必须开的两项权限
打开 系统设置 → 隐私与安全性,在 屏幕录制 和 辅助功能 里都找到 DSH Computer Use:
| 权限 | 用途 | 不开的后果 |
|---|---|---|
| 辅助功能 Accessibility | 读取 AX 树、按 token 点击、键盘输入 | 工具不注册或操作失败 |
| 屏幕录制 Screen Recording | CUA 截图、绝对坐标点击/滚动 | 报 PERMISSION_DENIED: Screen Recording permission is required for the responsible host/helper |
开启步骤:
- 系统设置 → 隐私与安全性 → 屏幕录制
- 找到 DSH Computer Use,打开开关
- 同页面进入 辅助功能,确认 DSH Computer Use 已开
- 如果列表里没有它:点 +,按
Cmd+Shift+G,粘贴上面的 helper 路径,选中添加 - 重启 DSH NEXT(权限变更需要 helper 重启后重新读取)
本次实测
getCapabilities()返回screenRecording: false,所以截图场景失败;辅助功能为 true,其余场景可用。这就是「截图场景测试失败」的全部原因。
验证权限是否生效
重启后调用:
await tools.cua({ method: "getCapabilities", params: {} });
返回里这两项都为 true 才算成功:
"permissions": { "accessibility": true, "screenRecording": true }
3. 给具体目标应用授权
即使系统权限开了,任务访问某个应用前仍会单独询问。实测中第一次 getApp("Notes") 卡住,就是在等应用级授权;确认后在按 profile 隔离的存储里留下决策:
~/.dsh/storages/cua_permissions_*.json,其中 Notes 的 decision: allow。
4. 确认已开启
cua.getCapabilities() 关键返回:
{
"platform": "macos",
"permissions": { "accessibility": true, "screenRecording": false },
"systemPointer": true,
"methods": ["getApp","listWindows","getState","listActions","performAction","click", ...]
}
本次实测时 screenRecording: false,所以 CUA 自带截图失败;辅助功能为 true,其余操作可用。

二、测试场景与结果
说明:本文截图用系统
screencapture保存(因为 CUA 截图权限未开);窗口截图用screencapture -l <windowId>离屏抓取,不需要把窗口切到前台。
场景 1:发现应用(listApps / findApps)
目的:找到要操作的目标应用。
await tools.cua({ method: "listApps", params: {} });
await tools.cua({ method: "findApps", params: { query: "Notes" } });
结果:返回本机运行中的应用(Notes、Chrome、Feishu、Xcode 等),findApps 找到 Notes 的 bundleId / path / pid。
场景 2:读取窗口列表(listWindows)
目的:拿到目标应用的窗口与边界,不激活窗口。
const app = await tools.cua({ method: "getApp", params: { selector: "com.apple.Notes" } });
await tools.cua({ method: "listWindows", params: { appHandle: app.appHandle } });
结果:拿到 Notes 的 appHandle 和 5 个窗口,其中主窗口 windowId: 10556、isOnScreen: true、bounds 0,30,1920x972。窗口截图:

场景 3:读取辅助功能树(getState)
目的:结构化理解窗口内容,拿到可交互元素的 token。
await tools.cua({ method: "getState", params: { appHandle } });
结果:返回 AX 树,包含文件夹列表、笔记列表、正文文本区、工具栏按钮等。元素带编号(如 [26] AXButton "Folders"),可直接用于点击;同时返回 snapshotId,后续元素操作必须带它。
关键结构节选:
- [0] AXWindow "Notes – 1 note" actions=["Raise"]
- [6] AXScrollArea
- AXTable "My Notes as List"
- [7] AXRow selected
- [12] AXTextArea focused valueWritable=true = "Dsh-univer-office..."
- [24] AXToolbar
- [25] AXButton "Add Folder"
- [26] AXButton "Folders" help="Hide folders"
- [28] AXButton "New Note"

场景 4:通过元素 token 后台点击(listActions + performAction)
目的:不靠坐标、不激活窗口,直接按可访问性元素点击。
const state = await tools.cua({ method: "getState", params: { appHandle } });
await tools.cua({
method: "listActions",
params: { appHandle, snapshotId: state.snapshotId, elementId: "26" }
});
await tools.cua({
method: "performAction",
params: { appHandle, snapshotId: state.snapshotId, elementId: "26", action: "AXPress" }
});
结果:listActions 返回 ["AXPress", ...];performAction 返回 { dispatched: true }。按指导文本要求,重新读取新状态验证:按钮仍为 Folders / Hide folders,说明点击已派发但本次切换未产生可见状态变化(也可能是窗口未激活时该按钮不响应)。结论:点击流程可用,但要用新快照验证实际结果,不能只看 dispatched。

场景 5:CUA 截图(权限开启后通过)
目的:验证屏幕录制权限是否就绪。
const app = await tools.cua({ method: "getApp", params: { selector: "com.apple.Notes" } });
await tools.cua({
method: "screenshot",
params: { appHandle: app.appHandle, windowId: 10556 }
});
第一次(权限未开)结果:
PERMISSION_DENIED: Screen Recording permission is required for the responsible host/helper
按第一节给 DSH Computer Use.app 授权并重启 DSH 后结果:
{ "mimeType": "image/webp", "pixelWidth": 1920, "pixelHeight": 972, "windowId": 10556 }
截图内容见「场景 2」的 Notes 窗口图(同一窗口)。
注意:重启后旧的 appHandle 会失效,先报 APP_ACCESS_REQUIRED: Select the application with getApp and obtain user consent,必须重新 getApp 拿新句柄再截图。
结论:截图与绝对坐标点击/滚动都依赖此权限;screenRecording: true + 新 appHandle 后可用。
三、实测结论
| 场景 | 结果 | 前置条件 |
|---|---|---|
开启插件后获得 cua 工具 |
通过 | 打开 Computer Use bundle |
系统权限检查 getCapabilities |
通过 | 辅助功能开、屏幕录制关仍可查 |
应用发现 listApps / findApps |
通过 | 辅助功能 |
应用授权 getApp |
通过(先要应用级授权) | 用户在弹窗确认 allow |
窗口列表 listWindows |
通过 | appHandle |
辅助功能树 getState |
通过,返回结构化树 + snapshotId | 辅助功能 |
token 点击 performAction |
派发成功,结果需新快照确认 | snapshotId + elementId |
CUA 截图 screenshot |
通过(权限开启后) | 给 helper 授权 + 重启 DSH + 新 appHandle |
| 绝对坐标滚动/点击 | 依赖截图,权限开启后可用 | 同截图权限 |
一句话总结:Computer Use 的核心操作链(发现应用 → 拿窗口 → 读 AX 树 → 按 token 后台点击 → 截图)全部跑通。唯一的硬门槛是给 DSH Computer Use.app(不是 DSH NEXT)开屏幕录制权限;这一步 Agent 做不了,必须由用户在系统设置里手动完成。
四、注意事项
- 系统权限由用户手动授予,插件不会自动打开系统授权弹窗。
- 首次访问某个应用会单独询问,授权按 profile 隔离保存。
- 目标应用授权只在该会话中生效;可以在权限页面撤销。
- CUA 操作共享同一桌面,其他会话/应用可能改变状态;动作后务必读新状态验证。
- 取消不会回滚已发送的输入,重试前先看当前状态。
- macOS 上光标覆盖层操作可能返回
facility_unavailable,但截图与后台输入仍可用。 - 截图权限未开时,可用系统
screencapture -l <windowId>离屏抓窗口,不会把窗口切到前台。