dsh-computer-use-macos:在 Harness 对话中操控 macOS 应用与网页

前言

在 DeepSeek Harness(DSH)里做智能体时,模型往往只能读写对话内的文本与附件,难以像人一样「看见」计算器窗口、在表单里敲字,或在已登录的浏览器里点按钮读表格。手写无障碍桥接、截图管道和浏览器 CDP 连接,工作量大,且要与 Harness 的授权、日志和附件管线对齐。

dsh-computer-use-macos 是社区维护者 yw5579358 发布的工作流类插件,把 Harness 在 macOS 上的原生 Computer Use 能力与可选的浏览器 DOM 控制收拢到一套应用/窗口 API 里,供 PTC 会话跨多次调用持久使用。交互模式参考 Codex Computer Use:选中应用或标签页 → 观察状态与截图 → 执行操作 → 再观察。

这是什么

插件全名 Computer Use for DeepSeek Harness on macOS(npm 包名 dsh-computer-use-macos,当前资料记载版本 0.1.1)。它依赖 DeepSeek Harness 实验性的 macOS CUA 提供方(@deepseek-ai/dsh-cua、@deepseek-ai/dsh-experimental-cua-macos)做无障碍树、窗口捕获与输入;浏览器侧通过 Playwright 经 CDP 连接专用 Chrome 配置,按 role、label、文本定位元素。插件本身负责应用/窗口 API、PTC 下的模块加载、观察新鲜度校验、浏览器连接管理与截图投递,调用走 Harness 既有授权与附件流程。

仓库:https://github.com/yw5579358/dsh-computer-use-macos。社区目录页:https://www.skillhub.cn/plugins/yw5579358/dsh-computer-use-macos。许可证为 MIT。

核心能力

资料中明确列出的能力如下,不扩写未出现的特性。

macOS 原生应用: 选择应用与窗口;读取无障碍树;捕获窗口截图;点击;输入 Unicode 文本;发送快捷键;滚动;选中文本与粘贴。

网页(需单独启用浏览器 DOM 控制): 读取页面内容;填写输入框;点击按钮;提取表格;定位 DOM 元素;捕获当前视口。任务空闲时浏览器连接会释放供下一会话使用;标记为交付物或 handoff 的页面可为用户保留打开状态。

版本 0.1.1 曾在 Harness Desktop 中实测(含中文表单输入、按钮点击、结果回读、截图及跨会话浏览器复用)。README 记载本地与 GitHub CI 共 44 项自动化测试通过,另有 12 项原生桌面检查;细节见仓库内 test report。

环境与依赖

安装前对照 README 核对:

  • macOS 14+
  • DeepSeek Harness 0.2.2-rc.1
  • Node.js 24.9+;需要具备图像能力的模型以处理截图
  • 为 DSH Computer Use.app 授予「辅助功能」与「屏幕录制」权限

每个 profile 宜只使用一个原生 Computer Use 提供方。

安装与启用

Harness Desktop(推荐路径)

  1. 打开 Plugins,启用实验项 Custom plugin indexes。
  2. 打开 Discover,添加下面的 JSON 索引地址。
  3. 选择 Computer Use for macOS,核对版本与来源后 Install → Enable now。
  4. 在 Settings → Agent presets 中选择 PTC mode,再新建对话。

索引 URL(须与资料原文一致):

https://raw.githubusercontent.com/yw5579358/dsh-computer-use-macos/codex/initial-release/plugin-index.json

Desktop 的 Add plugin 对话框也接受 Releases 中的 tarball;索引版本指向特定 Git 提交,仓库内包含构建好的 lib/。

更新第三方插件时,建议先备份 profile 配置,卸载旧版再安装新版;已有对话仍使用当时的 preset。

CLI 独立 profile

若使用单独 CLI profile,安装命令来自 README 示例(需先取得对应版本的 .tgz,例如 Releases 产物):

dsh plugin --profile computer-demo add ./dsh-computer-use-macos-0.1.1.tgz
dsh --profile computer-demo --dump-config

Desktop 通过应用内插件页管理自带的 desktop profile,与上述 CLI profile 分开。

在对话里怎么用

以下示例摘自 README,替换应用名、URL 和任务即可复现思路。需要任务结束后保留页面时,可明确要求 Harness leave the tab open for review。

原生应用:

Use Computer Use to open Calculator, calculate 123 × 456, and report the result shown in the window.
Open TextEdit with Computer Use. Create a document titled “Weekly plan” with three action items. Leave the window open for me to review.

浏览器 DOM:

Use browser DOM control to open http://localhost:3000, check the navigation links and main buttons, and capture the result. Leave the tab open for review.
Use browser DOM control to open the dashboard I specify. After I sign in, read the visible table and count records by status.

启用浏览器 DOM 控制

浏览器不会默认全开;按文档 opt-in 配置。

先启动专用 Chrome 实例:

"$HOME/.dsh/profiles/desktop/node_modules/dsh-computer-use-macos/scripts/start-browser.command"

启动器将用户数据放在 $HOME/.dsh/browser-dom/profile,调试端点为 127.0.0.1:9222。需在独立窗口登录站点时,在该 Chrome 中完成;关闭浏览器后再次运行启动器。

在 profile 的 cordis.patch.yml 中增加(字段名与资料一致):

- id: macos-computer-use-compat
  name: dsh-computer-use-macos
  config:
    configuredCDPEndpoint: http://127.0.0.1:9222
    browserTimeoutMs: 15000
    browserMaxElements: 400

保存后新建 PTC 对话。连接保留页、故障排查见仓库 browser guide。

PTC 中调用 API(进阶)

需要在 PTC 脚本里直接编排时,README 给出原生与浏览器桥接示例。要点:每次输入后读取新鲜状态;跨空闲边界恢复时要重新选择浏览器标签;截图经 Harness 附件管道交给模型。

原生应用片段:

const entry = await tools.computer_use_bootstrap({})
const { connectComputerUse } = await import(entry.nativeBridgeUrl)
const cua = connectComputerUse(() => tools.cua, {
  text: value => console.log(value),
})
const app = await cua.getApp('Calculator')
await app.getAXState()
await app.click(elementIndex)
await app.getAXState()

浏览器片段:

const { connectBrowser } = await import(entry.browserBridgeUrl)
const browser = connectBrowser(() => tools.computer_browser)
const tab = await browser.createBrowserTab('chromium', 'http://localhost:3000')
await tab.playwright.getByRole('button', { name: 'Continue', exact: true }).click()
await tab.getAXState()
await tab.markHandoff()

更完整的 API 说明见 docs/capabilities.md。

适用场景与注意

适合在 macOS 上用 Harness PTC 做桌面自动化验证、本地化表单操作、需要「看窗口再点」的重复性任务,以及在专用 Chrome 配置里做 DOM 级网页操作(含登录后读表)。不适合非 macOS 环境;也不应把插件当成无需审核即可任意操控整机的黑盒——操作范围受系统权限与 Harness 授权约束。

安装与启用前建议通读仓库源码与 Security 文档。插件在用户当前 DSH 进程权限下运行,辅助功能与屏幕录制授权范围决定模型能接触哪些界面。社区目录(如 SkillHub)与 DeepSeek / 幻方无官方从属关系,索引与 tarball 均来自第三方仓库,自行核对 commit 与版本。

卸载:Desktop 在插件详情选 Uninstall;CLI profile 可用:

dsh plugin --profile computer-demo remove dsh-computer-use-macos

系统「隐私与安全性」中的 macOS 权限,以及 Harness Computer Use 权限页中的授权,需单独管理。

结尾

dsh-computer-use-macos 把 macOS 原生 Computer Use 与可选的 CDP 浏览器控制接到 Harness 已有 PTC、日志与附件链路上,用统一的应用/窗口抽象降低「对话里操控本机」的集成成本。若要浏览简介或跳转安装说明,可用目录页 skillhub.cn/plugins/yw5579358/dsh-computer-use-macos;技术细节与发行包以 GitHub 仓库为准:github.com/yw5579358/dsh-computer-use-macos。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜