dsh-computer-use-linux:在 DSH 里用原生工具控制 Linux 桌面

前言

在 DeepSeek Harness(DSH)里做本地自动化时,常见做法是单独起一个 MCP 服务,再在配置里挂工具名。桌面侧还要处理 AT-SPI、窗口管理、截图和 Wayland/X11 输入,引擎本身往往已经是一套完整的 MCP 实现。若每次都在 DSH 里重复对接,升级上游修复也会拖慢。

下面介绍社区插件 @brucezhang1993/dsh-computer-use-linux:把上游 computer-use-linux MCP 服务通过 DSH 内置的 @deepseek-ai/dsh-mcp-client 桥接成 mcp__cul__* 原生工具,并附带 bundled skill。不修改 DSH 本体,也不额外引入运行时依赖。

这是什么

  • 维护者:BruceZhang1993(GitHub:BruceZhang1993/dsh-computer-use-linux)
  • 分类:客户端(社区目录 SkillHub 条目)
  • 许可证:MIT(见仓库 README)
  • 定位:Linux 桌面 computer use —— 智能体可观察本地桌面(AT-SPI 无障碍树、窗口列表、截图),并执行聚焦/移动/缩放窗口、点击、拖拽、滚动、输入、按键、无障碍语义动作等;Wayland 与 X11 共用同一套工具命名,与上游 Claude Code / Codex 插件暴露的能力对齐。

架构上,DSH agent 调用 mcp__cul__* → 内置 MCP 客户端(stdio、JSON-RPC 2.0)→ 本包 launcher bin/computer-use-linux-mcp.mjs → 固定版本的 Rust 上游二进制(约 9 MB)。插件只负责解析/校验/启动二进制,桌面能力由上游维护。

核心功能

暴露的工具(18 个默认)

工具名统一为 mcp__cul__<原名>,与上游默认工具一一对应:

分组 工具
诊断 doctor、setup_accessibility、setup_window_targeting
发现 list_apps、list_windows、focused_window
观察 get_app_state、screenshot
输入 click、drag、scroll、press_key、type_text
语义 perform_action、set_value
窗口 activate_window、move_window、resize_window

另有 2 个条件工具默认关闭,需环境变量显式开启:run_shell(COMPUTER_USE_LINUX_ENABLE_SHELL=1,无沙箱,文档说明 DSH 已有沙箱 shell)和 complete_interaction(COMPUTER_USE_LINUX_NOTIFY_ON_COMPLETE=1)。

上游能力概览(经 launcher 转发)

  • AT-SPI:无障碍树与语义动作
  • Compositor 后端:窗口列表与聚焦(README 列举 GNOME、KWin、Hyprland、niri、i3、COSMIC、X11/EWMH 等)
  • Portals / Shell:截图
  • ydotool / portal / xdotool:输入合成

二进制解析顺序

launcher 按「先命中先用」解析可执行文件:

  1. 环境变量 COMPUTER_USE_LINUX_BIN(绝对路径)
  2. ~/.cache/computer-use-linux/plugin/v<version>/computer-use-linux(与上游 Claude/Codex 插件同布局,一台机器一份缓存)
  3. 已安装的 @agent-sh/computer-use-linux npm 包
  4. PATH 上的 computer-use-linux
  5. 从 GitHub release 下载并校验 .sha256

可通过 COMPUTER_USE_LINUX_VERSION、COMPUTER_USE_LINUX_DOWNLOAD_BASE、COMPUTER_USE_LINUX_SKIP_DOWNLOAD 覆盖版本与镜像行为。细节见仓库 docs/installation.md。

环境与要求

  • 平台:Linux(x86_64 或 arm64);非 Linux 平台插件不启用
  • DSH:需自带 @deepseek-ai/dsh-mcp-client(官方 README 称各 shipped profile 已包含)
  • Node:20+(launcher;DSH Desktop 内通过 ELECTRON_RUN_AS_NODE=1 在 Electron 下运行)
  • 会话:需有图形桌面;无障碍、窗口与输入后端因 compositor 而异。安装后应优先调用 mcp__cul__doctor,并按 skill 内 skills/computer-use-linux/references/setup.md 排查

安装与启用

包发布在 GitHub Packages(scope @brucezhang1993),安装前需让 profile 可见 registry 并完成一次认证。

CLI profile(以 web 为例)

先把 scope 写入 profile 的 .npmrc,再用 legacy 方式登录(npm 9+ 需 --auth-type=legacy;密码为带 read:packages 的 classic PAT,不是 gh auth login 存的 token):

printf '@brucezhang1993:registry=https://npm.pkg.github.com\n' \
  >> "${DSH_HOME:-$HOME/.dsh}/profiles/web/.npmrc"
npm login --scope=@brucezhang1993 --auth-type=legacy \
  --registry=https://npm.pkg.github.com

安装 bundle(dsh plugin 会校验与当前 DSH 版本兼容性,成功后写入 profile 的 dsh.profile.bundles 并选中该 bundle):

dsh plugin --profile web add @brucezhang1993/dsh-computer-use-linux          # latest
dsh plugin --profile web add @brucezhang1993/dsh-computer-use-linux@0.1.0    # pin a version

安装完成后 重启 harness,模型工具列表中会出现 mcp__cul__doctor、mcp__cul__get_app_state、mcp__cul__list_windows、mcp__cul__click 等。

完整步骤(含 token scope、公开包选项)见仓库 docs/installation.md。

DSH Desktop

在插件管理器中从 registry 搜索并安装 @brucezhang1993/dsh-computer-use-linux。Desktop profile 仅由应用管理,不能使用 dsh plugin --profile desktop add …(设计上会拒绝)。

本地开发目录

在仓库目录上直接 link,无需 pack/publish:

dsh plugin --profile web add /absolute/path/to/dsh-computer-use-linux

修改在下次重启后生效。

典型用法

会话内自检

在 DSH 会话中,先让智能体调用 mcp__cul__doctor。返回平台、portals、无障碍、窗口与输入后端及就绪摘要,再决定是否继续 list_windows、screenshot、click 等操作。

源码或已安装包上的命令行验证

在 checkout 根目录:

node scripts/check-package.mjs   # 静态:patch、exports、skill 一致性
node --test                      # 单元测试与 launcher 测试
node scripts/doctor.mjs          # 桌面就绪报告,无需 DSH
node scripts/selftest.mjs        # 经 launcher 的 MCP 握手与 tools/list

已安装副本也可运行包内 shipped 的 selftest.mjs、doctor.mjs,路径见 installation.md#verify-the-install。

适用场景与注意

适合:在 Linux 工作站上,希望 DSH 智能体以与上游 computer-use-linux 相同语义观察并操作本机 GUI(含无障碍树驱动的语义点击/填表),且愿意通过 GitHub Packages 安装社区 bundle 的开发者。

注意:

  1. 权限边界:工具以 当前 DSH 进程的用户与权限 运行,可聚焦窗口、合成输入、读屏幕内容。安装前应阅读源码与 MIT 许可证,并理解 run_shell 仅在显式开启环境变量时可用且 deliberately unsandboxed。
  2. 桌面差异:Wayland/X11、各 compositor 对 AT-SPI、截图 portal、输入后端支持不一;以 doctor 输出和 setup 文档为准,不要假设某一发行版默认可用。
  3. 生态关系:DSH 社区插件目录(如 SkillHub)为独立站点,与 DeepSeek / 幻方无官方从属;本插件为社区维护的桥接层,上游引擎版本由插件 pin 与解析逻辑决定。
  4. 包版本:package.json 当前版本为 0.1.1;CLI 示例中 pin 示例为 @0.1.0,按实际需要选择 latest 或显式版本号。

结尾

dsh-computer-use-linux 的价值在于 桥接而非重写:上游 MCP 负责桌面引擎,DSH 内置 MCP 客户端负责命名空间、重连与图像投影;你在 DSH 里得到的是统一的 mcp__cul__* 工具面。若你在 Linux 上跑 DSH 并需要 GUI 级 computer use,可按上文完成 GitHub Packages 认证与 dsh plugin add,重启后用 mcp__cul__doctor 确认环境再继续自动化。

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

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

Xiaoye