dsh-zcode-cua 0.0.0-stage → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,133 @@
1
+ # Changelog
2
+
3
+ 本文件记录本仓库的重要变更。
4
+
5
+ ## 1.3.1 — 2026-11-25
6
+
7
+ 修复 `awesome-dsh-plugin` 维护者在合并 #17754 时指出的安全问题:开关的路由没有访问校验。
8
+
9
+ ### 修复
10
+
11
+ - **开关的路由可以被任意网页调用。** `/plugins/dsh-zcode-cua/access` 会**写入**授权,但它原先不校验来源,于是用户浏览器里开着的任何页面都能 `POST` 它,把自己变成有权移动鼠标的一方。现在 `handleAccess` 第一步就问 `ctx.connection.requestRejection(req)`,在读取任何其它内容之前答 `401`/`403` —— 这是 DSH 自己的 Host/Origin 栅栏加浏览器身份验证,外来页面在来源与凭据两道都过不去。
12
+ - **栅栏失败即拒绝。** 服务缺失、服务抛错、或返回值不在文档的 `401 | 403 | undefined` 之内,一律当 `403`。失败后放行的栅栏**读起来**仍然像设了防,缺陷会一直隐形到有人利用它为止。
13
+ - **`webServer` 与 `connection` 改为 `inject` 里的硬要求。** 原先 `webServer` 用 `ctx.inject(["webServer"], ...)` 做可选注入,于是提供不了栅栏的宿主仍会把路由无保护地挂上。现在两者都是硬要求:拿不到栅栏的宿主根本走不到注册那一行 —— 开关消失、守卫保留。
14
+ - **`connection` 按每次挂载捕获,不用模块级变量。** 模块级绑定会被同一进程里的多次 `apply` 共用,第二个挂载会静默地用另一个实例的服务来把关(写这条测试时就撞到了)。
15
+
16
+ ### 新增
17
+
18
+ - **`test/fence.mjs`**:15 项检查。被拒的请求到不了开关、放行的到得了、栅栏先于参数校验执行(`403` 优先于 `400`,不向未认证方确认路由存在),以及四种异常服务形态(缺失 / 无该方法 / 抛错 / 返回未文档化的值)全部答 `403`。
19
+
20
+ ### 修复(测试)
21
+
22
+ - **`test/overlay.mjs` 的短调用断言此前会误报失败。** 它用 `execFileSync` 单次采样,而每次采样都要新起一个 PowerShell 重新 `Add-Type` 编译(实测约 700ms),比它要观测的 900ms 最短可见窗口还长;而且同步调用会阻塞事件循环,探针跑完才开始发工具调用,采到的其实是空闲期。改为**异步** spawn 一个进程内部轮询,断言看整段窗口的峰值窗口数。这条测试此前一直失败,与浮层功能无关。
23
+
24
+ ## 1.3.0 — 2026-11-22
25
+
26
+ 新增按会话的电脑控制开关:新会话默认**不能**操作桌面,由用户在输入框下方自己打开。
27
+
28
+ ### 新增
29
+
30
+ - **按会话的开关。** 输入框下方那一行最右边多一枚胶囊:`电脑控制 · 已关闭` / `电脑控制 · 已开启`,点一下切换,只对当前会话生效。宿主侧由 `index.js` 注册 `ctx.tools.guard()` 实现,客户端是 `client.js`(浏览器模块),状态由 `GET/POST /plugins/dsh-zcode-cua/access` 读写。
31
+ - **`server/access.js`**:授权表(模块级 `Set`,按会话 id)与守卫本体。守卫只对 `mcp__zcode-cua__js` 作答,其它工具一律放行;未授权时返回带 `COMPUTER_USE_DISABLED` 码的拒绝,文案直接告诉模型去开哪个开关。
32
+ - **`test/access.mjs`**:13 项单元检查,覆盖默认拒绝、放行非本插件工具、授权按会话隔离、无会话一律拒绝、撤销后重新拒绝、`clearGrants` 清空、空 id 不产生授权。
33
+ - **`cordis.patch.yml` 增加第二行** `zcode-cua-access`(本包自己的宿主入口)。原来只有 `zcode-cua`(MCP server)一行。
34
+
35
+ ### 设计取舍
36
+
37
+ - **默认拒绝,而不是默认允许 + 事后撤销。** 这个工具会点击、会往当前持有键盘的窗口里打字。新会话先拿到它,等于用户只是问了个问题却得到一个握着鼠标的 agent。
38
+ - **用 `ctx.tools.guard()` 而不是 `ctx.tools.restrict()`。** 后者把工具从 schema 里摘掉,读起来像「插件没装」,模型无法告诉用户该开哪个开关;守卫保留工具可见性,并把「为什么被拒、去哪里开」写进拒绝文案。
39
+ - **授权状态不写进 session log。** Harness 会拒绝重开会话里它不认识的 `type`(除非信封带 `ignorable: true`,而运行时 `Session.append()` 设不了这个标记)。把权限记录写进日志会让会话重启后打不开——一个把对话弄坏的插件比一个默认关闭的开关糟得多。
40
+ - **授权不跨 Host 重启。** 重启后所有会话回到关闭。对会移动鼠标的能力来说这是安全方向,所以是刻意的,文档里写明。
41
+ - **没有会话可归属的调用一律拒绝**,即使别的会话已授权。「没有会话」不等于「会话说了可以」。
42
+ - **开关有第三种状态 `状态未知`。** 宿主路由够不着时显示它而不是「已关闭」——「关闭」和「问不到」不能长得一样,否则坏掉的开关看起来跟好的一样。
43
+
44
+ ### 变更
45
+
46
+ - `package.json`:`main` 与 `"."` 导出改指 `./index.js`(宿主入口);新增 `"./client"` 导出、`"./server"` 导出(MCP server 的显式路径)、`files` 补 `index.js` / `client.js`;新增 `dsh.client` 段(`platform: "web"`、`immediately: true`、`inject: ["@deepseek-ai/dsh-client-ui-conversation"]`)。
47
+ - README 中英文各新增「按会话开关 / The per-session switch」一节,开发清单与测试命令同步。
48
+
49
+ ## 1.2.1 — 2026-11-22
50
+
51
+ 三个实测反馈的修复:浮层文字乱码、短调用看不到浮层、ZCode 自带的幽灵光标还在。
52
+
53
+ ### 修复
54
+
55
+ - **横幅中文乱码。** Node 以 UTF-8 写 stdin,而 PowerShell 5.1 的 `[Console]::In.ReadLine()` 按系统 OEM 代码页(中文 Windows 是 936/GBK)解码,中文全变成乱码。`server/overlay/host.ps1` 改用显式 UTF-8 流:`New-Object System.IO.StreamReader([Console]::OpenStandardInput(), $utf8)` 与对应的 `StreamWriter`,`$utf8 = New-Object System.Text.UTF8Encoding($false)`(不能带 BOM,否则 JSON 行解析失败)。
56
+ - **短调用看不到浮层。** `enter()` 同步把「已显示」置位,而真正的 `show` 是异步的,首次调用还要先编译 C#(约 1–2 秒)。比编译更短的调用会在窗口建好之前就发出 `hide`,于是浮层永远没机会出现——这就是「有时候被控制了但没有浮层」。现在 `leave()` 会等未回话的 `show` 再拆,并保证最短可见时间 `MIN_VISIBLE_MS = 900`;新调用到达时取消待执行的 `hide`,避免上一轮的延迟关闭打断下一轮。
57
+ - **横幅不更新为本次动作。** 浮层已经在屏幕上时再次 `enter()` 会重绘,让第二行显示**这一次**调用做的事,而不是上一次留下的文字。
58
+ - **ZCode 的幽灵光标又出现了。** 上游 `node-repl-host` 启动原生 helper 时**无条件**追加 `--ghost-cursor-overlay`(`server.js:121868`,没有任何设置或环境变量能关掉),helper 于是自带一个常驻指针浮层。新增 `server/helper-launcher.js`:helper recipe 的 `entryPath` 指向它,它剥掉这个参数后再 exec 真 helper。不改任何上游文件;`DSH_ZCODE_CUA_KEEP_GHOST_CURSOR=1` 可恢复原状。
59
+
60
+ ### 变更
61
+
62
+ - `test/overlay.mjs` 从 7 项增到 9 项,新增「极短调用也要出现浮层」与「之后要消失」两条回归。
63
+ - 环境变量表新增 `DSH_ZCODE_CUA_KEEP_GHOST_CURSOR`。
64
+
65
+ ## 1.2.0 — 2026-11-22
66
+
67
+ 新增屏幕上的操作提示浮层:`js` 调用执行期间,用户能看到 AI 正在操作这台电脑,而模型截的图里看不到它。
68
+
69
+ ### 新增
70
+
71
+ - **提示浮层。** 四边蓝色光晕 + 顶部居中横幅 + 光标周围柔光。横幅第一行固定「DSH 正在控制电脑」,第二行显示**本次调用正在做的事**(取 `js` 工具必填的 `title` 参数);没给 title 时回落成「正在执行操作…」。视觉规格移植自 [windows-mcp](https://github.com/CursorTouch/Windows-MCP) 的 `control_overlay`,实现是完全独立的 C# Win32 分层窗口(`server/overlay/Overlay.cs`),由 Windows 自带的 PowerShell 5.1 在运行时用 `Add-Type` 编译,所以插件仍然不带二进制、不需要构建步骤。
72
+ - **截图排除。** 每个窗口都标 `SetWindowDisplayAffinity(WDA_EXCLUDEFROMCAPTURE)`,Windows 会把它从任何截图路径中排除。本机实测:调用进行中抓全屏,画面里找不到浮层;把 affinity 关掉再抓同一张,完整图案都在。
73
+ - **不吃输入。** 窗口样式 `WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE`,点击穿透、不抢焦点、不进任务栏与 Alt-Tab。
74
+ - **`server/overlay.js`**:浮层的宿主管理器。常驻一个 `host.ps1` 进程(编译 C# 与建窗口要几百毫秒,只付一次),把工具调用包成「进入 / 离开」,并用嵌套计数保证两个重叠的调用不会互相把浮层关掉。
75
+ - **`test/overlay.mjs`**:端到端验证三件事——空闲时无窗口、`js` 调用期间六个窗口全部可见、调用结束后全部消失。7 项检查。
76
+ - 环境变量 `DSH_ZCODE_CUA_NO_OVERLAY=1` 可完全关掉浮层。
77
+
78
+ ### 设计取舍
79
+
80
+ - **失败一律降级,绝不阻断调用。** 浮层是装饰:PowerShell 缺失、C# 编译失败、宿主进程挂掉,全部退化成「没有提示」并照常调用。一个因为状态徽标坏掉就不能用的电脑控制插件是坏交易。宿主在启动后一秒内死亡会被标记为不可用而不再重试,避免每次调用都去撞同一个编译错误。
81
+ - **只对 `js` 这个工具亮。** 上游只有这一个工具,Computer Use 的每个动作都在它里面;写成「任何工具调用都亮」会让以后新增的非桌面工具也顶着「正在操作电脑」的横幅。
82
+ - **DPI 感知必须在建窗口之前设。** 否则进程是 DPI-unaware,`GetSystemMetrics` 报的是虚拟化后的小尺寸、合成器又把窗口放大,横幅会偏到右半边、被屏幕边缘截断(实测踩到)。
83
+ - **`RegisterClassEx` / `CreateWindowEx` 两侧都要 `CharSet.Unicode`。** 缺了会以 ANSI 名字注册、再以 UTF-16 查找,每次创建都返回 1411 `ERROR_CLASS_DOES_NOT_EXIST`,而 `RegisterClassEx` 明明成功(实测踩到)。
84
+ - **C# 里的类必须是 `public`。** `Add-Type` 发到动态程序集,只能访问导出类型;`internal` 编译得过,然后 PowerShell 报「找不到类型」(实测踩到)。
85
+
86
+ ### 变更
87
+
88
+ - 限制一节里「没有屏幕上的操作提示」改为「没有幽灵光标,也没有画中画」,并说明新浮层替代了这两者、且保证不进截图。幽灵光标那段的成因分析保留。
89
+ - 开发一节补充 `server/overlay.js`、`server/overlay/`、`test/overlay.mjs` 与两条测试命令。
90
+
91
+ ## 1.1.0 — 2026-11-22
92
+
93
+ 稳定性加固。没有新增能力,改的全是「出问题时会发生什么」。
94
+
95
+ ### 修复
96
+
97
+ - **取消信号被丢弃。** 原来 `handleMessage` 对所有 `id === undefined` 的消息直接 `return`,于是 DSH 取消工具调用时发来的 `notifications/cancelled` 根本到不了上游——用户按下中断之后,原生点击仍在继续落、键盘仍在继续打字。现在转发 `notifications/cancelled`、`notifications/progress`、`notifications/roots/list_changed` 三类通知。
98
+ - **上游崩溃被当成正常退出。** 原来上游一退出就 `process.exit(0)`,DSH 的 `reconnect` 策略因此永不触发,工具静默消失且不会自己回来,只能重启 DSH。现在区分「主动关闭」与「异常退出」:异常(被信号杀死、或父进程还活着时自行退出)报 `exit(1)`,让重连生效。
99
+ - **请求可能永久悬挂。** `upstreamRequest` 的 Promise 没有超时,应答一旦丢失就永远挂着,直到 DSH 自己的超时。现在有 240 秒上限(高于 `js` cell 的 120 秒上限与 `toolCallTimeoutMs` 的 180 秒),只用来兜住「答案丢了」,不干预正常的长调用。
100
+ - **崩溃时在途请求不清理。** 上游退出后,`pending` 里的 Promise 一直悬着。现在退出时全部 reject,并带上退出码/信号作为原因。
101
+ - **版本目录只取最新一个。** 最新版目录若损坏(更新中断、杀软隔离、磁盘写满),原来直接判定「Computer Use 不可用」,而旁边完好的旧版本明明能用。现在从新到旧逐个探测,取第一个真正完整的。
102
+
103
+ ### 新增
104
+
105
+ - `test/smoke.mjs`:端到端冒烟测试,走真实的 legacy 握手 + 一次真实的 `js` 调用(枚举应用),5 项检查。改完代码跑 `node test/smoke.mjs` 就能确认主链路没被破坏。
106
+
107
+ ### 文档
108
+
109
+ - 限制一节新增「不要用两个会话同时操作桌面」:每个 DSH 会话各自启动一个 helper,而 helper 的输入串行化(`windowsInputDispatchLease`)是进程内队列、不是全机互斥,两个会话同时点击会让鼠标键盘事件交错。
110
+ - 更正幽灵光标那段的原因说明。原来写「只有短命进程,浮层画不出来」是错的;真正原因是上游在 cua-broker 路径上从不填 `pip_session_context`,helper 收到 null 会话后主动抑制浮层。同时说明为什么不在本插件里绕开它。
111
+
112
+ ### 更正
113
+
114
+ - 上面「文档」第一条把并发限制的原因写错了。原文说「每个 DSH 会话各自启动一个 helper、`windowsInputDispatchLease` 是进程内队列」,这不是实情:`@deepseek-ai/dsh-mcp-client` 是 profile 级插件,整个 DSH 只有一份 helper、一个子进程。真正的原因是桥接层给所有 DSH 会话传同一个进程级 `session_id`(`dsh-<uuid>`),上游 `server.js` 用 `serialized(sessionKey, ...)` 据此把它们排成一队——两个会话因此不会同时操作桌面,代价是一个会话的长调用会阻塞其它会话的 `js` 调用。结论不变;README 与 `skills/zcode-computer-use/SKILL.md` 的表述已同步更正。
115
+
116
+ ## 1.0.0 — 2026-11-22
117
+
118
+ 首个版本。
119
+
120
+ ### 新增
121
+
122
+ - 一个 MCP 工具 `mcp__zcode-cua__js`,把 ZCode 的 Computer Use 运行时接进 DSH。每次调用在全新的 Node.js 内核里跑顶层 `await`,模型用代码点击、打字、读无障碍树、截图。
123
+ - 自动解析 ZCode 的三处安装位置:`node-repl-host`(上游 MCP server)、`computer-use`(客户端 SDK 与文档)、`cua-helper`(Windows 原生 helper)。ZCode 不在默认位置时按卸载注册表的 `InstallLocation`、`ZCODE_HOME`、常见安装目录依次探测,三者都支持环境变量覆盖。
124
+ - MCP 1.x 与现代协议(`2026-07-28`)双向适配:legacy 客户端本地应答握手,工具列表与调用转发上游,并剥掉现代协议独有的 `resultType` / `ttlMs` / `cacheScope` 字段。
125
+ - 插件展示元数据(中英双语):`locale/en.json` 指向 `docs/DETAIL.md`,`locale/zh.json` 指向 `docs/DETAIL.zh.md`,两份文档各有自己语言的替代文本、共用同一张无文字插图。
126
+ - `skills/zcode-computer-use/SKILL.md`:Computer Use 的完整操作指南(无障碍优先、元素索引优先、坐标兜底、错误与重试语义)。
127
+
128
+ ### 说明
129
+
130
+ - Windows 专用。依赖 ZCode 安装目录里的原生 helper,不重新分发 ZCode 的任何二进制。
131
+ - 没有屏幕上的操作提示(幽灵光标)——上游在 cua-broker 路径上从不填 `pip_session_context`,helper 收到 null 会话后主动抑制浮层。画中画小窗同理不可用(`ax_native.node` 没有 `pip*` 导出)。
132
+ - Browser Use 未接入:上游需要宿主提供 `browserBroker`,本插件只接了 Computer Use 桥。
133
+ - 注册行用相对路径 `node_modules/dsh-zcode-cua/server/index.js`,所以插件必须按包名 `dsh-zcode-cua` 安装(不带 scope)。从本地目录安装时 DSH 会建软链接,源码改动即时生效。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wkylnj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,209 @@
1
- # Temporary Holding Version
1
+ # dsh-zcode-cua
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Brings [ZCode](https://zcode.ai)'s Computer Use into [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness).
4
+
5
+ The model can click, type, read the accessibility tree and take screenshots of native desktop apps through a single `js` tool. DSH's own `dsh-cua-bundle` reports `unsupported-platform` on Windows, so this is the route that works there.
6
+
7
+ [中文](README.zh.md) · [Changelog](CHANGELOG.md)
8
+
9
+ ## What it adds
10
+
11
+ One MCP tool, `mcp__zcode-cua__js`. Every call runs top-level `await` in a **fresh Node.js kernel**; the model drives the desktop with code:
12
+
13
+ ```js
14
+ const root =
15
+ process.env.ZCODE_CUA_PLUGIN_ROOT ??
16
+ process.env.ZCODE_PLUGIN_ROOT ??
17
+ process.env.CLAUDE_PLUGIN_ROOT;
18
+ const { join } = await import("node:path");
19
+ const { pathToFileURL } = await import("node:url");
20
+ const { setupComputerUseRuntime } = await import(
21
+ pathToFileURL(join(root, "scripts", "computer-use-client.mjs")).href
22
+ );
23
+ await setupComputerUseRuntime({ globals: globalThis });
24
+
25
+ const app = await agent.computerUse.getApp({ pid: 1234 });
26
+ await app.getAXState(); // read the accessibility tree
27
+ await app.click(12); // click by element index
28
+ await app.typeText("hello");
29
+ await app.getScreenshot();
30
+ ```
31
+
32
+ `agent.computerUse` exposes `getState` / `getApp` / `listApps` / `requestAccess` / `stop`, plus fourteen low-level `computer.*` tools. The ordered path is: `getAXState()` first, find the element by role and name, then act on its index. Coordinates are the last resort, for canvas and Electron content accessibility cannot see.
33
+
34
+ The full API reference is `agent.documentation.get("computer-use")`, fetched on demand.
35
+
36
+ ## The per-session switch
37
+
38
+ **A new session cannot drive the desktop.** The `js` tool stays visible in the tool list, but every call is denied until the session opts in:
39
+
40
+ > Computer control is off for this session. Ask the user to switch it on with the "Computer control" toggle under the message box, then call this tool again.
41
+
42
+ The switch is a pill at the right end of the row under the message box — `电脑控制 · 已关闭` / `电脑控制 · 已开启`. One click flips it, and only for the session you are looking at.
43
+
44
+ Why a switch rather than a setting: this tool clicks and types into whatever holds the keyboard. A profile-wide setting would mean one yes turns it on for every conversation, including the one that just asked a question and got an agent holding the mouse. Why a denial rather than hiding the tool: a tool missing from the schema reads as "the plugin is not installed", and the model would have no way to tell you which switch to flip.
45
+
46
+ Three details worth knowing:
47
+
48
+ - **The grant is per session and lives in memory.** Restarting DSH puts every session back to off. That is the safe direction for a capability that moves your mouse, so it is deliberate rather than a missing feature.
49
+ - **A call with no session attached is denied**, even while another session is on. "No session" is not a session that said yes.
50
+ - **Other tools are unaffected.** The guard only answers for `mcp__zcode-cua__js`; a guard that denied tools it does not own would quietly break unrelated plugins.
51
+
52
+ The switch shows a third state — `电脑控制 · 状态未知` — when the host route cannot be reached. "Off" and "could not ask" must not look alike, or a broken switch reads as a working one.
53
+
54
+ ### The route is fenced by the connection service
55
+
56
+ The switch's route (`/plugins/dsh-zcode-cua/access`) **writes** the grant, so an unfenced route would be worse than no switch at all: any page the user has open in a browser could `POST` it and hand itself the ability to move the mouse. The route therefore asks `ctx.connection.requestRejection(req)` first and answers `401`/`403` before reading anything else — that is DSH's own Host/Origin fence plus browser authentication, so a foreign page is refused on both the origin and the credential.
57
+
58
+ Two properties of that fence are deliberate:
59
+
60
+ - **It fails closed.** A missing service, a throwing service, or a return value outside the documented `401 | 403 | undefined` all resolve to `403`. A fence that falls open still *reads* as guarded, so the defect would stay invisible until someone abused it.
61
+ - **`webServer` and `connection` are hard requirements** in the plugin's `inject` list, not optional injections. A Host that cannot supply the fence does not get the route at all — the switch disappears and the guard stays, rather than the route being served unprotected.
62
+
63
+ `test/fence.mjs` pins all of it: refused requests never reach the switch, allowed ones do, and every unexpected service shape answers `403`.
64
+
65
+ ## The on-screen indicator
66
+
67
+ While a `js` call is running, a click-through overlay tells the user the computer is being driven: a blue glow around every screen edge, a banner, and a soft ring around the pointer. The banner's first line is always *DSH 正在控制电脑*; the second line is **what this call is doing**, taken from the `js` tool's required `title` argument — the same sentence the model already writes for the user.
68
+
69
+ The point is that it is **invisible to the model**. Every window is marked `WDA_EXCLUDEFROMCAPTURE`, so Windows omits it from any screenshot — `PrintScreen`, `Graphics.CopyFromScreen`, and the GDI/DWM path the CUA helper itself uses. Verified on this machine: a full-screen capture taken mid-tool-call contains no trace of the overlay, while the same capture with the affinity cleared shows the full artwork.
70
+
71
+ Nothing about it takes input or focus: the windows are `WS_EX_TRANSPARENT | WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW`, so clicks pass straight through, focus is never stolen, and it never appears in the taskbar or Alt-Tab.
72
+
73
+ Turn it off with `DSH_ZCODE_CUA_NO_OVERLAY=1`. The indicator is decoration — if PowerShell is missing, the C# fails to compile, or the host process dies, every path degrades to "no indicator" and tool calls keep working unchanged.
74
+
75
+ The visual design is ported from [windows-mcp](https://github.com/CursorTouch/Windows-MCP)'s `control_overlay`; the implementation is a standalone Win32 layered window in C#, compiled at runtime by Windows PowerShell 5.1 so the plugin ships no binaries and needs no build step.
76
+
77
+ ## How it is wired
78
+
79
+ ```
80
+ DSH ──MCP stdio──▶ this plugin's server/index.js
81
+ ├─ injects ZCODE_CUA_PERMISSION_BROKER_SOCKET and friends
82
+ └──▶ node-repl-host (ZCode's official MCP server, one `js` tool)
83
+ └──▶ cua-helper (native Windows process, ax_native.node)
84
+ └──▶ Win32 UI Automation / input injection
85
+ ```
86
+
87
+ This plugin does exactly two things: **resolve ZCode's installation layout**, and **translate between MCP 1.x and the modern protocol**. The CUA execution logic is ZCode's own runtime, unmodified, which is why behaviour matches ZCode.
88
+
89
+ The upstream `js` tool is strict — anything beyond `code`, `timeout_ms` and `title` is refused — and this plugin passes it through untouched, adding no parameters.
90
+
91
+ ## Install
92
+
93
+ ### Prerequisites
94
+
95
+ 1. **Windows**
96
+ 2. **ZCode installed and launched at least once** — this plugin reuses the native helper in ZCode's install directory and redistributes none of it.
97
+ 3. **DeepSeek Harness** (this is a DSH bundle)
98
+
99
+ ### Into DSH
100
+
101
+ Option 1 (recommended): inside DSH, **Plugins → Add plugin**, then pick this directory. DSH links the checkout, so source edits take effect immediately.
102
+
103
+ Option 2: install from the checkout with the same command this was verified with:
104
+
105
+ ```powershell
106
+ cd "D:\path\to\dsh-zcode-cua"
107
+ dsh plugin --profile desktop add "link:$PWD"
108
+ ```
109
+
110
+ Restart DSH afterwards. The tool appears as `mcp__zcode-cua__js`, and the plugin row reads **ZCode computer control**.
111
+
112
+ > **The package name must stay `dsh-zcode-cua`**, unscoped. The registration row points at the relative path `node_modules/dsh-zcode-cua/server/index.js`; that is what makes one file work on every machine, and it assumes the package is installed under the profile's `node_modules` under exactly that directory name.
113
+
114
+ ### Skill (optional, strongly recommended)
115
+
116
+ The tool works on its own, but the model will not know how to use it well. The skill lives at `skills/zcode-computer-use/SKILL.md` in this repository; install it into a DSH skill directory:
117
+
118
+ ```powershell
119
+ # user level (every project)
120
+ Copy-Item -Recurse .\skills\zcode-computer-use "$env:USERPROFILE\.dsh\skills\zcode-computer-use"
121
+
122
+ # or project level (only that project)
123
+ Copy-Item -Recurse .\skills\zcode-computer-use "D:\your-project\.dsh\skills\zcode-computer-use"
124
+ ```
125
+
126
+ DSH does **not** load skills from a plugin directory — it scans `<project>/.dsh/skills`, `<project>/.agents/skills` and `~/.dsh/skills` only, so this step is manual. Restart DSH afterwards.
127
+
128
+ ## Configuration
129
+
130
+ To change anything, find the `zcode-cua` row in the profile's `cordis.patch.yml`:
131
+
132
+ ```yaml
133
+ - id: zcode-cua
134
+ name: '@deepseek-ai/dsh-mcp-client'
135
+ config:
136
+ serverName: zcode-cua
137
+ transport: stdio
138
+ command: 'node'
139
+ args: ['node_modules/dsh-zcode-cua/server/index.js']
140
+ toolCallTimeoutMs: 180000
141
+ ```
142
+
143
+ `command` defaults to `node`, which needs Node 18.17+ on PATH. The DSH desktop app ships its own Node; point `command` at it if you prefer an absolute path.
144
+
145
+ ### Environment variables
146
+
147
+ When layout resolution fails — ZCode installed somewhere unusual — override the three probes:
148
+
149
+ | Variable | Points at |
150
+ |---|---|
151
+ | `ZCODE_BRIDGE_SERVER` | `node-repl-host`'s `dist/mcp/server.js` |
152
+ | `ZCODE_CUA_PLUGIN_ROOT` | the `computer-use` plugin root (holds `scripts/computer-use-client.mjs`) |
153
+ | `ZCODE_BRIDGE_HELPER_ROOT` | the `cua-helper` directory (holds `build/Release/ax_native.node`) |
154
+ | `DSH_ZCODE_CUA_NO_OVERLAY` | set to `1` to disable the on-screen indicator entirely |
155
+ | `DSH_ZCODE_CUA_KEEP_GHOST_CURSOR` | set to `1` to keep ZCode's own pointer overlay; by default it is suppressed so only the indicator above is on screen |
156
+
157
+ Usually none are needed: the plugin looks for ZCode in the **uninstall registry** (`InstallLocation`), in `ZCODE_HOME`, and in the conventional install locations.
158
+
159
+ ## Limitations
160
+
161
+ - **Windows only.** It needs `resources/tools/cua-helper` from ZCode's install directory (the `ax_native.node` native module). ZCode currently has peer-identity verification disabled on Windows (`WINDOWS_PEER_IDENTITY_GATE_TEMPORARILY_OPEN = true` in `windows-helper.js`) — **this plugin did not open that gate**; the day ZCode closes it, this plugin stops working.
162
+ - **No picture-in-picture.** `ax_native.node` exports no `pip*` functions at all and `pipSessionEnabled` is always false on Windows, so there is nothing to enable. The banner and screen glow described above stand in for the missing visual feedback, and unlike a cursor overlay they are guaranteed absent from screenshots.
163
+ - **ZCode's own pointer overlay is suppressed on purpose.** The upstream launches the native helper with `--ghost-cursor-overlay` unconditionally — no setting or environment variable turns it off — so `server/helper-launcher.js` strips that flag before exec'ing the real helper. Two indicators disagreeing about what is happening is worse than one, and the ZCode overlay is a plain top-level window that any full-screen capture picks up. Set `DSH_ZCODE_CUA_KEEP_GHOST_CURSOR=1` to keep it. (Even when kept, it only paints inside a request scope that this path never supplies, for the reason recorded in 1.1.0.)
164
+ - **No Browser Use.** Upstream `node-repl-host` implements a Browser Use bridge, but it needs a `browserBroker` from the host and this plugin only wires the Computer Use bridge. Use DSH's own Browser Use for web pages.
165
+ - **Every `js` call is a fresh kernel.** Variables do not survive between calls, so bootstrap every time.
166
+ - **Do not drive the desktop from two sessions at once.** There is only one helper in the whole chain: `@deepseek-ai/dsh-mcp-client` is a profile-level plugin, so DSH runs a single instance and a single child process. What actually keeps two sessions apart is the upstream serialisation lock — the bridge passes the same process-wide `session_id` (`dsh-<uuid>`, generated once at startup) for every DSH session, and upstream `server.js` wraps each `js` execution in `serialized(sessionKey, ...)` keyed on that id, so calls from different sessions queue behind one another. Two sessions therefore cannot click at the same time, but a long call in one session blocks every other session's `js` calls until it returns. Keep desktop work in a single session; run other sessions in a different DSH window without Computer Use, or wait for the first one to finish.
167
+ - **The model really clicks and types on your desktop.** That is the capability, not a defect; disable the plugin row when you do not need it.
168
+
169
+ ## Security notes
170
+
171
+ - The helper's permission broker socket is created inside this plugin's own process under a random name (`\\.\pipe\zcode-cua-helper-<uuid>`) and disappears with the process.
172
+ - This plugin reads, stores and forwards no ZCode or WorkBuddy credentials. It only drives a runtime already installed on the machine.
173
+ - Tool calls are governed by DSH's tool permission system; use a DSH permission preset for tighter limits.
174
+
175
+ ## Development
176
+
177
+ ```
178
+ server/paths.js resolves ZCode's three install locations
179
+ index.js the Host half: the per-session tool guard and the switch's routes
180
+ client.js the composer switch (browser module)
181
+ server/index.js the MCP stdio server; spawns upstream and translates the protocol
182
+ server/access.js the grant table and the guard body
183
+ server/overlay.js owns the indicator's host process and brackets tool calls with it
184
+ server/overlay/ Overlay.cs (the Win32 layered window) and host.ps1 (its resident driver)
185
+ server/helper-launcher.js drops the upstream's forced --ghost-cursor-overlay, then execs the helper
186
+ test/smoke.mjs end-to-end: handshake, tools/list, one real js call, cancellation
187
+ test/overlay.mjs end-to-end: the indicator appears during a call and leaves afterwards
188
+ test/access.mjs unit: the guard denies, allows, and scopes grants per session
189
+ test/fence.mjs unit: the switch's route refuses unauthenticated callers and fails closed
190
+ skills/ the skill (installed manually into a DSH skill directory)
191
+ locale/ plugin display metadata
192
+ docs/ detail page image
193
+ cordis.patch.yml the two registration rows
194
+ ```
195
+
196
+ No build step, no runtime dependencies, pure ESM. Restart DSH after a change.
197
+
198
+ ```sh
199
+ node test/access.mjs # 13 checks
200
+ node test/fence.mjs # 15 checks
201
+ node test/smoke.mjs # 5 checks
202
+ node test/overlay.mjs # 9 checks
203
+ ```
204
+
205
+ ## License
206
+
207
+ MIT. See [LICENSE](LICENSE).
208
+
209
+ This plugin contains no ZCode binaries or source. It drives a ZCode installation already present on your machine; those rights belong to their respective owners.
package/README.zh.md ADDED
@@ -0,0 +1,209 @@
1
+ # dsh-zcode-cua
2
+
3
+ 把 [ZCode](https://zcode.ai) 的电脑控制(Computer Use)接进 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)。
4
+
5
+ 模型可以通过一个 `js` 工具点击、打字、读无障碍树、截图,操作本机的原生桌面应用。DSH 自带的 `dsh-cua-bundle` 在 Windows 上报告 `unsupported-platform`,所以这是 Windows 上能用的一条路。
6
+
7
+ [English](README.md) · [更新日志](CHANGELOG.md)
8
+
9
+ ## 它做什么
10
+
11
+ 增加一个 MCP 工具 `mcp__zcode-cua__js`。每次调用在一个**全新的 Node.js 内核**里跑顶层 `await`,模型用代码驱动桌面:
12
+
13
+ ```js
14
+ const root =
15
+ process.env.ZCODE_CUA_PLUGIN_ROOT ??
16
+ process.env.ZCODE_PLUGIN_ROOT ??
17
+ process.env.CLAUDE_PLUGIN_ROOT;
18
+ const { join } = await import("node:path");
19
+ const { pathToFileURL } = await import("node:url");
20
+ const { setupComputerUseRuntime } = await import(
21
+ pathToFileURL(join(root, "scripts", "computer-use-client.mjs")).href
22
+ );
23
+ await setupComputerUseRuntime({ globals: globalThis });
24
+
25
+ const app = await agent.computerUse.getApp({ pid: 1234 });
26
+ await app.getAXState(); // 读无障碍树
27
+ await app.click(12); // 按元素索引点击
28
+ await app.typeText("你好");
29
+ await app.getScreenshot();
30
+ ```
31
+
32
+ `agent.computerUse` 暴露 `getState` / `getApp` / `listApps` / `requestAccess` / `stop`,以及底层 `computer.*` 十四个工具。顺路的做法是:先 `getAXState()` 拿树,按 role/name 找到元素索引再动手;只有 canvas 或无障碍看不见的内容才退到坐标。
33
+
34
+ 完整 API 参考在 `agent.documentation.get("computer-use")`,按需取。
35
+
36
+ ## 按会话开关
37
+
38
+ **新会话不能操作桌面。** `js` 工具在工具列表里照常可见,但每一次调用都会被拒绝,直到这个会话自己打开开关:
39
+
40
+ > Computer control is off for this session. Ask the user to switch it on with the "Computer control" toggle under the message box, then call this tool again.
41
+
42
+ 开关是输入框下方那一行最右边的一枚胶囊:`电脑控制 · 已关闭` / `电脑控制 · 已开启`。点一下切换,只对当前这个会话生效。
43
+
44
+ 为什么是开关而不是设置项:这个工具会点击、会往当前持有键盘的窗口里打字。做成全局设置意味着一次同意就对所有对话生效——包括那个只是问了个问题、却拿到一个会动鼠标的 agent 的对话。为什么是拒绝而不是把工具藏起来:工具从 schema 里消失会被读成「插件没装」,模型就没法告诉你该去开哪个开关。
45
+
46
+ 三点值得知道:
47
+
48
+ - **授权按会话、存在内存里。** 重启 DSH 后所有会话回到关闭。对一个会移动你鼠标的能力来说这是安全的方向,所以是刻意的,不是缺功能。
49
+ - **没有会话可归属的调用一律拒绝**,即使别的会话已经开着。「没有会话」不等于「会话说了可以」。
50
+ - **其它工具不受影响。** 守卫只对 `mcp__zcode-cua__js` 作答;一个连别人工具一起拒的守卫会悄悄弄坏无关插件。
51
+
52
+ 宿主路由够不着时开关会显示第三种状态 `电脑控制 · 状态未知`。「关闭」和「问不到」不能长得一样,否则一个坏掉的开关看起来跟好的一样。
53
+
54
+ ### 这条路由由连接服务把关
55
+
56
+ 开关的这条路由(`/plugins/dsh-zcode-cua/access`)**会写入授权**,所以一条不设防的路由比没有开关更糟:你浏览器里开着的任何网页都能 `POST` 它,把自己变成有权移动鼠标的一方。因此这条路由第一步就问 `ctx.connection.requestRejection(req)`,在读取任何其它内容之前先答 `401`/`403` —— 那是 DSH 自己的 Host/Origin 栅栏加浏览器身份验证,外来页面在来源和凭据两道都过不去。
57
+
58
+ 栅栏的两个性质是刻意的:
59
+
60
+ - **失败即拒绝。** 服务缺失、服务抛错、或返回值不在文档的 `401 | 403 | undefined` 之内,一律当 `403`。一个失败后放行的栅栏**读起来**仍然像设了防,于是这个缺陷会一直隐形,直到有人利用它。
61
+ - **`webServer` 与 `connection` 是 `inject` 里的硬要求**,不是可选注入。提供不了这道栅栏的宿主根本拿不到这条路由 —— 开关消失、守卫保留,而不是把路由无保护地挂上去。
62
+
63
+ `test/fence.mjs` 钉住了全部:被拒的请求到不了开关,放行的到得了,以及每一种异常的服务形态都答 `403`。
64
+
65
+ ## 屏幕上的提示浮层
66
+
67
+ `js` 调用执行期间,屏幕上会出现一层可穿透的提示:四边蓝色光晕、顶部居中横幅,以及光标周围一圈柔光。横幅第一行固定是「DSH 正在控制电脑」,第二行是**这次调用正在做的事**——取自 `js` 工具必填的 `title` 参数,模型本来就要用它写一句面向用户的说明。
68
+
69
+ 关键在于它**对模型不可见**。每个窗口都标了 `WDA_EXCLUDEFROMCAPTURE`,Windows 会把它从任何截图中排除——`PrintScreen`、`Graphics.CopyFromScreen`,以及 CUA helper 自己走的 GDI/DWM 路径都算在内。本机实测:在调用进行中抓全屏,画面里找不到浮层的任何痕迹;把 affinity 关掉再抓同一张,完整图案就都在。
70
+
71
+ 它也不吃输入、不抢焦点:窗口样式是 `WS_EX_TRANSPARENT | WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW`,点击直接穿透,不会出现在任务栏或 Alt-Tab 里。
72
+
73
+ 要关掉它,设 `DSH_ZCODE_CUA_NO_OVERLAY=1`。这层提示纯属装饰——PowerShell 缺失、C# 编译失败、宿主进程挂掉,任何一条路径都退化成「没有提示」并继续正常调用,不会拖累工具本身。
74
+
75
+ 视觉设计移植自 [windows-mcp](https://github.com/CursorTouch/Windows-MCP) 的 `control_overlay`;实现是一个独立的 C# Win32 分层窗口,由 Windows 自带的 PowerShell 5.1 在运行时编译,所以插件不带任何二进制、也不需要构建步骤。
76
+
77
+ ## 它是怎么接的
78
+
79
+ ```
80
+ DSH ──MCP stdio──▶ 本插件 server/index.js
81
+ ├─ 注入 ZCODE_CUA_PERMISSION_BROKER_SOCKET 等环境变量
82
+ └──▶ node-repl-host(ZCode 官方 MCP server,只暴露一个 js 工具)
83
+ └──▶ cua-helper(Windows 原生进程,ax_native.node)
84
+ └──▶ Win32 UI Automation / 输入注入
85
+ ```
86
+
87
+ 本插件只做两件事:**解析 ZCode 的安装布局**,以及**在 MCP 1.x 与现代协议之间翻译**。CUA 的执行逻辑完全来自 ZCode 自己的运行时,未做任何改动,所以行为与在 ZCode 里一致。
88
+
89
+ 上游的 `js` 工具是严格的(`code` / `timeout_ms` / `title` 之外一律拒绝),本插件原样透传,不额外加参数。
90
+
91
+ ## 安装
92
+
93
+ ### 前提
94
+
95
+ 1. **Windows**
96
+ 2. **ZCode 已安装并至少登录/启动过一次** —— 本插件复用 ZCode 安装目录里的原生 helper,不重新分发它。
97
+ 3. **DeepSeek Harness**(本插件是 DSH bundle)
98
+
99
+ ### 装进 DSH
100
+
101
+ 方式一(推荐):在 DSH 里 **插件 → 添加插件**,选中这个目录。DSH 会建一个软链接,之后改源码即时生效。
102
+
103
+ 方式二:从源码目录安装,与你机器上已验证的效果一致:
104
+
105
+ ```powershell
106
+ cd "D:\path\to\dsh-zcode-cua"
107
+ dsh plugin --profile desktop add "link:$PWD"
108
+ ```
109
+
110
+ 装完重启 DSH。工具以 `mcp__zcode-cua__js` 出现,插件列表里是 **ZCode 电脑控制**。
111
+
112
+ > **包名必须是 `dsh-zcode-cua`**,不能带 scope。注册行里写的是相对路径 `node_modules/dsh-zcode-cua/server/index.js`,这是让同一个文件在别人机器上也能用的代价——它假定包被装在 profile 的 `node_modules` 下且目录名就是包名。
113
+
114
+ ### 技能(可选,强烈建议)
115
+
116
+ 工具本身能用,但模型不知道该怎么用。技能文件在这个仓库的 `skills/zcode-computer-use/SKILL.md`,把它装到 DSH 的技能目录:
117
+
118
+ ```powershell
119
+ # 用户级(所有项目可用)
120
+ Copy-Item -Recurse .\skills\zcode-computer-use "$env:USERPROFILE\.dsh\skills\zcode-computer-use"
121
+
122
+ # 或者项目级(只在某个项目里可用)
123
+ Copy-Item -Recurse .\skills\zcode-computer-use "D:\your-project\.dsh\skills\zcode-computer-use"
124
+ ```
125
+
126
+ DSH **不会**从插件目录自动加载技能——它只扫描 `<项目>/.dsh/skills`、`<项目>/.agents/skills` 和 `~/.dsh/skills`,所以这一步得手动做。装完重启 DSH。
127
+
128
+ ## 配置
129
+
130
+ 想改的时候,在 profile 的 `cordis.patch.yml` 里找 `zcode-cua` 那一行:
131
+
132
+ ```yaml
133
+ - id: zcode-cua
134
+ name: '@deepseek-ai/dsh-mcp-client'
135
+ config:
136
+ serverName: zcode-cua
137
+ transport: stdio
138
+ command: 'node'
139
+ args: ['node_modules/dsh-zcode-cua/server/index.js']
140
+ toolCallTimeoutMs: 180000
141
+ ```
142
+
143
+ `command` 默认是 `node`,需要 Node 18.17+ 在 PATH 上。DSH 桌面端自带一份 Node,也可以用绝对路径指向它。
144
+
145
+ ### 环境变量
146
+
147
+ 解析 ZCode 位置失败时(比如 ZCode 装在很偏的地方),用这三个变量覆盖:
148
+
149
+ | 变量 | 指向 |
150
+ |---|---|
151
+ | `ZCODE_BRIDGE_SERVER` | `node-repl-host` 的 `dist/mcp/server.js` |
152
+ | `ZCODE_CUA_PLUGIN_ROOT` | `computer-use` 插件根目录(含 `scripts/computer-use-client.mjs`) |
153
+ | `ZCODE_BRIDGE_HELPER_ROOT` | `cua-helper` 目录(含 `build/Release/ax_native.node`) |
154
+ | `DSH_ZCODE_CUA_NO_OVERLAY` | 设为 `1` 即完全关闭屏幕提示浮层 |
155
+ | `DSH_ZCODE_CUA_KEEP_GHOST_CURSOR` | 设为 `1` 保留 ZCode 自带的指针浮层;默认会被抑制,屏幕上只留上面这层提示 |
156
+
157
+ 平时不需要设——插件会从**卸载注册表**(`InstallLocation`)、`ZCODE_HOME`、以及常见安装位置三处去找 ZCode。
158
+
159
+ ## 限制
160
+
161
+ - **Windows 专用。** 依赖 ZCode 安装目录里的 `resources/tools/cua-helper`(`ax_native.node` 原生模块)。ZCode 在 Windows 上暂时关闭了对端签名校验(`windows-helper.js` 的 `WINDOWS_PEER_IDENTITY_GATE_TEMPORARILY_OPEN = true`),**这不是本插件打开的门**;ZCode 一旦把这道门关上,本插件也随之失效。
162
+ - **没有画中画小窗。** `ax_native.node` 没有导出任何 `pip*` 函数,helper 在 Windows 上的 `pipSessionEnabled` 恒为 false,没有可开启的东西。上面说的横幅与四边光晕补上了这块视觉反馈,而且它们保证不会出现在截图里。
163
+ - **ZCode 自带的指针浮层是被主动抑制的。** 上游启动原生 helper 时**无条件**追加 `--ghost-cursor-overlay`,没有任何设置或环境变量能关掉,所以 `server/helper-launcher.js` 在 exec 真 helper 之前把这个参数剥掉。两个提示对「正在发生什么」说法不一致比只有一个更糟,而且 ZCode 那个浮层是普通顶层窗口,任何全屏抓图都会带上它。设 `DSH_ZCODE_CUA_KEEP_GHOST_CURSOR=1` 可以保留。即使保留,它也只在「请求作用域」内绘制,而这条路径从不提供该作用域(原因记在 1.1.0)。
164
+ - **Browser Use 不可用。** 上游 `node-repl-host` 实现了 Browser Use 桥,但它需要宿主提供 `browserBroker`,本插件只接了 Computer Use 桥。要浏览器操作请用 DSH 自己的 Browser Use。
165
+ - **每个 `js` 调用都是新内核。** 变量不跨调用存活,所以每次都要重新 bootstrap。
166
+ - **不要用两个会话同时操作桌面。** 整条链路上只有一份 helper:`@deepseek-ai/dsh-mcp-client` 是 **profile 级**插件,DSH 只起一个实例、一个子进程。真正把两个会话隔开的是上游的串行锁——桥接层给所有 DSH 会话传的是同一个进程级 `session_id`(`dsh-<uuid>`,进程启动时生成一次),上游 `server.js` 用 `serialized(sessionKey, ...)` 把每次 `js` 执行按这个 id 排队,所以不同会话的调用只能一个接一个地跑。好处是两个会话不会同时操作桌面,代价是一个会话的长调用会把其它会话的 `js` 调用全堵在后面,直到它返回。桌面操作请集中在单个会话里做;其它会话在另一个 DSH 窗口里跑别的事、不要用 Computer Use,或者等第一个会话做完。
167
+ - **模型能在你的桌面上真实点击和打字。** 这是能力本身,不是缺陷;不需要时把这条插件行停用即可。
168
+
169
+ ## 安全说明
170
+
171
+ - helper 的权限 broker socket 建在本插件进程内,名字是随机的(`\\.\pipe\zcode-cua-helper-<uuid>`),随进程退出消失。
172
+ - 本插件不读、不存、不转发任何 ZCode 或 WorkBuddy 的凭据。它只调用本机已经安装的运行时。
173
+ - 工具调用由 DSH 的工具权限体系约束;要更严的限制,用 DSH 的权限预设。
174
+
175
+ ## 开发
176
+
177
+ ```
178
+ server/paths.js 解析 ZCode 三处安装位置
179
+ index.js 宿主侧:按会话的工具守卫与开关的两条路由
180
+ client.js 输入栏下方的开关(浏览器模块)
181
+ server/index.js MCP stdio 服务端;spawn 上游并翻译协议
182
+ server/access.js 授权表与守卫本体
183
+ server/overlay.js 管理提示浮层的宿主进程,并用它包住每次工具调用
184
+ server/overlay/ Overlay.cs(Win32 分层窗口)与 host.ps1(常驻驱动)
185
+ server/helper-launcher.js 剥掉上游强加的 --ghost-cursor-overlay 后再 exec 真 helper
186
+ test/smoke.mjs 端到端:握手、tools/list、一次真实 js 调用、取消通知
187
+ test/overlay.mjs 端到端:调用期间浮层出现,结束后消失
188
+ test/access.mjs 单元:守卫会拒绝、会放行,且授权按会话隔离
189
+ test/fence.mjs 单元:开关的路由会拒绝未认证调用,且失败即拒绝
190
+ skills/ 技能(手动安装到 DSH 技能目录)
191
+ locale/ 插件展示元数据
192
+ docs/ 详情页图片
193
+ cordis.patch.yml 两条注册行
194
+ ```
195
+
196
+ 没有构建步骤,没有运行时依赖,纯 ESM。改完重启 DSH 生效。
197
+
198
+ ```sh
199
+ node test/access.mjs # 13 项检查
200
+ node test/fence.mjs # 15 项检查
201
+ node test/smoke.mjs # 5 项检查
202
+ node test/overlay.mjs # 9 项检查
203
+ ```
204
+
205
+ ## 许可
206
+
207
+ MIT。见 [LICENSE](LICENSE)。
208
+
209
+ 本插件不含 ZCode 的任何二进制或源码。它调用的是你机器上已安装的 ZCode,相关权利归其各自所有者。