前言¶
在 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。
- 目錄頁:https://www.skillhub.cn/plugins/internettrollwatt/dsh-cua-driver
- 源碼:https://github.com/internettrollwatt/dsh-cua-driver
核心功能¶
下面按 README 已列能力歸納,不寫未在資料中出現的行爲。
驅動與工具面¶
- 插件管理 vendored 的
cua-driver.exe,經 MCP 與 DSH 通信。 - 驅動工具以
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。
- 在
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" ] } }
- 在 profile 目錄執行
pnpm install(或由 DSH 自動安裝依賴)。 - 重啓 DSH Desktop(bundle 在啓動時加載)。
- 新會話中執行
/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 用一段話概括的可復現路徑如下,按順序操作即可。
- 用
cua_list_windows定位目標窗口。 - 用
cua_get_window_state讀取 UIA 樹與截圖;query可收窄樹,element_token形如<snapshot_id>:N,新快照會使舊 token 失效。 - 執行動作:
cua_click、cua_type_text、cua_set_value等,默認後臺投遞。 - 用
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;工具表由 MCPtools/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 發行說明。