dsh-cua-driver: Background Windows Desktop and Browser Control for DSH

前言

在 DeepSeek Harness(DSH)里做智能体时,若要让模型操作本机 GUI 或浏览器,常见做法是再接一套桌面自动化服务或 MCP,并在机器上单独安装驱动与守护进程。步骤多、环境杂,也容易和 DSH 会话里的工具表脱节。dsh-cua-driver 是一条「自带驱动、按 DSH profile 装配」的路径:把 trycua/cua 的 cua-driver(仓库内 vendored 为 v0.46.1)通过 MCP 挂进 DSH,以 cua_ 前缀暴露约 63 个工具,主打后台输入(UIA / PostMessage)与 CDP 浏览器操作,且除插件本身外无需在主机再装二进制。

这是什么

dsh-cua-driver 是 maintainer internettrollwatt 发布的自包含 DSH profile 插件(npm 包名 dsh-cua-driver,当前 package.json 版本 0.1.1,MIT)。主机侧为 Node 模块 index.js,配合 cordis.patch.yml 向 DSH profile 插入 bundle;vendor/ 内打包 Windows 版 cua-driver.exe 及相关 DLL,插件启动时拉起 cua-driver.exe mcp --direct(stdio、换行分隔 JSON-RPC 2.0),不依赖额外 daemon。

核心功能

下面按 README 已列能力归纳,不写未在资料中出现的行为。

驱动与工具面

  1. 插件管理 vendored 的 cua-driver.exe,经 MCP 与 DSH 通信。
  2. 驱动工具以 cua_ 前缀注册到 DSH,类别包括:
    - 观测:cua_list_windows、cua_get_window_state(UIA 树 + 截图)、cua_get_desktop_state、cua_zoom、cua_get_accessibility_tree 等。
    - 后台输入:cua_click、cua_type_text、cua_press_key、cua_hotkey、cua_scroll、剪贴板、cua_set_value 等,经 UIA / PostMessage,不占焦点、不移动真实鼠标。
    - 浏览器(CDP):cua_browser_prepare、cua_get_browser_state、cua_browser_click / type / navigate / download 等。
    - 批处理:cua_run_steps、cua_run_script、cua_start_session / cua_end_session。
    - 校验与诊断:cua_verify_state、cua_check_permissions、cua_health_report、cua_get_guide。
    - Agent 光标叠层:cua_move_cursor、cua_set_agent_cursor_motion / theme(视觉化假光标,真实指针不动)。
    - 录制回放:cua_start_recording、cua_stop_recording、cua_replay_trajectory。

懒加载与技能

启动时默认只注册 cua_activate;调用后展开完整工具表并返回简短手册,以控制 prompt 体积。若要在启动时全量注册,在 bundle 配置里设 eager: true。

仓库自带中文技能 /cua-driver(skills/cua-driver/SKILL.md),在 DSH 会话里可用斜杠命令加载。

CDP 与 bundle 补丁

cordis.patch.yml 为驱动传入 mcpArgs 默认 ['--grant','existing-profile'],便于附着到已在运行的 Edge / Chrome profile,减少同意弹窗流程(资料表述为 pre-authorization)。

环境与要求

  • DSH Desktop,运行在 Windows x86_64(package.json 中 os: ["win32"],vendored 仅为 Windows 套件)。
  • Node >= 22(插件主机侧 JS)。
  • 除 profile 依赖安装外,无需在系统上单独安装 cua-driver;SDK、嵌入式 Node runtime 均在 vendor/。

插件在 当前 DSH 进程权限 下操作本机桌面与浏览器;安装前建议阅读仓库源码、LICENSE 及 vendor/.../THIRD_PARTY_NOTICES.md,确认许可与工具范围(含标记为 destructive 的浏览器下载等,DSH 侧可能要求 destructive approval)。

安装与启用

官方 README 未使用 dsh plugin add github:... 形式,而是改 profile 的 package.json 并加入 bundle,然后安装依赖并重启 DSH Desktop。

方式 A:npm 包(README 推荐)

默认 profile 路径示例:C:\Users\<you>\.dsh\profiles\desktop\package.json。

  1. 在 dependencies 与 dsh.profile.bundles 中加入插件(README 示例版本为 ^0.1.0,与 npm 上 0.1.1 并存时以你实际安装的版本为准):
"dependencies": { "dsh-cua-driver": "^0.1.0" },
"dsh": { "profile": { "bundles": [ "…existing…", "dsh-cua-driver" ] } }
  1. 在 profile 目录执行 pnpm install(或由 DSH 自动安装依赖)。
  2. 重启 DSH Desktop(bundle 在启动时加载)。
  3. 新会话中执行 /cua-driver 加载技能,并调用 cua_activate(也可直接调用;返回工具列表与简短说明)。

方式 B:本地或 git 依赖

README 给出将 dsh-cua-driver 指到 file: 或 git+https://github.com/internettrollwatt/dsh-cua-driver.git 的写法,profile 编辑步骤与上相同,同样需要 pnpm install 与重启 DSH。

Bundle 配置项

配置写在 bundle 行,对应 cordis.patch.yml 中的键(资料原文表格):

key 默认值 含义
exe 自动:首个 vendor/cua-driver-rs-*/cua-driver.exe 显式指定 cua-driver.exe 路径
toolPrefix cua_ 工具名前缀
toolTimeoutMs 120000 单次 MCP 调用超时
eager false 是否在启动时注册全部工具
mcpArgs patch 中为 ['--grant','existing-profile'] 传给 mcp --direct 的额外参数

典型用法(README 工作流)

README 用一段话概括的可复现路径如下,按顺序操作即可。

  1. 用 cua_list_windows 定位目标窗口。
  2. 用 cua_get_window_state 读取 UIA 树与截图;query 可收窄树,element_token 形如 <snapshot_id>:N,新快照会使旧 token 失效。
  3. 执行动作:cua_click、cua_type_text、cua_set_value 等,默认后台投递。
  4. 用 cua_verify_state 或重新读取做校验。

若返回 background_unavailable,对同一调用加 delivery_mode:"foreground"(短暂抢焦点后恢复)。

网页内容优先走 CDP:cua_browser_prepare → cua_get_browser_state(绑定 + semantic_v2 快照)→ cua_browser_* 变更;浏览器对象与会话 session 标签绑定,同一工作流复用同一短 session 名。若浏览器调用被拒绝,响应中的 next_call 给出重试参数;CDP 不可用时 README 建议回退 UIA 路线读 Web 内容。

适用场景与注意

适合谁:在 Windows 上使用 DSH Desktop,需要让智能体在不打扰当前焦点的前提下操作原生窗口,并在同一套工具里覆盖 Chromium 系浏览器自动化的人。

注意(来自 README):

  • Agent 光标为叠层动画,真实指针不移动;可通过 cua_set_agent_cursor_motion / cua_set_agent_cursor_theme / cua_set_config 运行时调整。
  • 驱动在用户目录维护 %USERPROFILE%\.cua-driver\(配置、匿名 telemetry id、版本检查等),可用 cua_get_config / cua_set_config 查看或修改。
  • 破坏性工具(如 cua_browser_download)需主机侧批准;关闭审批的 DSH 会话会拒绝调用,属设计行为。
  • 升级驱动:用 trycua/cua releases 中较新的 Windows kit 替换 vendor/cua-driver-rs-*,保留上游 LICENSE 与 THIRD_PARTY_NOTICES.md,重启 DSH;工具表由 MCP tools/list 动态读取,无需改插件 JS。

许可:插件本体 MIT;vendored cua-driver 为 MIT(Copyright (c) 2025 Cua AI, Inc.)。DSH 社区插件目录(如 skillhub.cn)为生态站点,与 DeepSeek / 幻方无 README 所述的官方从属关系。

结尾

经过上面的步骤,dsh-cua-driver 把 cua-driver 打进 DSH profile:一次配置 bundle、重启会话,即可从 cua_activate 展开全套 cua_* 工具,在 Windows 上做后台桌面与 CDP 浏览器自动化。进一步细节见仓库 README.zh.md、目录页与 GitHub 发行说明。

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

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

Xiaoye