dsh-windows-parallel-mcp 0.0.1 → 0.1.0
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/INSTALL.md +84 -0
- package/README.md +114 -7
- package/cordis.patch.yml +15 -0
- package/docs/refusals.md +67 -0
- package/dsh.plugin.json +18 -0
- package/lib/config.js +125 -0
- package/lib/engine.js +225 -0
- package/lib/host-tools.js +138 -0
- package/lib/index.js +330 -0
- package/lib/peers-schemastery.js +17 -0
- package/lib/peers-tools.js +6 -0
- package/package.json +46 -11
- package/src/engine/decide.ps1 +155 -0
- package/src/engine/engine.ps1 +313 -0
- package/src/engine/overlay.ps1 +368 -0
- package/src/engine/win.ps1 +581 -0
- package/src/engine/worker.ps1 +156 -0
- package/src/schema/tools.json +205 -0
package/INSTALL.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Install
|
|
2
|
+
|
|
3
|
+
## Requirements
|
|
4
|
+
|
|
5
|
+
- Windows (the engine is a Windows PowerShell sidecar; there is no portability story and none is claimed)
|
|
6
|
+
- Windows PowerShell 5.1 — ships with Windows 10/11. `pwsh` also works if you set `powershellPath`
|
|
7
|
+
- A DSH host `>=0.1.7-0 <0.3.0-0`
|
|
8
|
+
|
|
9
|
+
No Python, no `uv`, no MSVC runtime, no native module, no build step. The engine is four `.ps1` files
|
|
10
|
+
driven over a JSON line protocol by one long-lived STA process, started on the first tool call.
|
|
11
|
+
|
|
12
|
+
## Install into a profile
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
dsh plugin --profile <profile> add dsh-windows-parallel-mcp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The host adds the package to the profile's `dsh.profile.bundles`; the bundle patch
|
|
19
|
+
(`cordis.patch.yml`) inserts one row (`id: windows-parallel`). Nothing else is mounted or replaced.
|
|
20
|
+
|
|
21
|
+
To install from a local build, pack first and install the tarball -- this is also how the
|
|
22
|
+
profile's other local-development plugins are mounted, and it matters for more than tidiness:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm pack --ignore-scripts # -> dsh-windows-parallel-mcp-0.1.0.tgz
|
|
26
|
+
dsh plugin --profile <profile> add /abs/path/to/dsh-windows-parallel-mcp-0.1.0.tgz
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
A `link:` install keeps the package's REAL path outside the profile tree, and Node resolves bare
|
|
30
|
+
peer specifiers (`@deepseek-ai/schemastery`) upward from the real path -- so the peers never
|
|
31
|
+
resolve, the settings form silently disappears, and the plugin falls to its shim. A `file:` tarball
|
|
32
|
+
installs as a real directory inside the profile and the peers resolve exactly like every other
|
|
33
|
+
plugin. This was measured, not inferred: `link:` -> `config schema: local-standard-schema-shim`,
|
|
34
|
+
`file:` -> `config schema: @deepseek-ai/schemastery`.
|
|
35
|
+
|
|
36
|
+
The desktop profile is managed by the Electron app; `dsh plugin --profile desktop ...` only works
|
|
37
|
+
through the desktop-bundled CLI (`resources/runtime/cli/bin/dsh.cmd`), and a profile with a pinned
|
|
38
|
+
lockfile should be changed surgically rather than by any command that re-resolves the whole graph.
|
|
39
|
+
|
|
40
|
+
## Verify it actually activated
|
|
41
|
+
|
|
42
|
+
Installing is not the same as activating, and a plugin that fails to activate prints one warning into
|
|
43
|
+
a busy log while its tool silently does not exist. From the package directory:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
node scripts/verify-install.mjs
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
It creates a throwaway profile, installs the package, boots the host, asserts the plugin is **not**
|
|
50
|
+
named in the "did not activate" block, and removes the profile again. `--keep` leaves it for
|
|
51
|
+
inspection, `--profile <name>` uses a different name (it only ever deletes profiles it created).
|
|
52
|
+
|
|
53
|
+
## Settings
|
|
54
|
+
|
|
55
|
+
Settings live in the bundle patch / profile config. On hosts where `@deepseek-ai/schemastery` is
|
|
56
|
+
resolvable from the plugin, the fields also appear in the settings form; where it is not, the plugin
|
|
57
|
+
falls back to a built-in standard-schema shim, the values still work, and **the form is not rendered**.
|
|
58
|
+
The fallback is reported in the host log as `config schema: local-standard-schema-shim`.
|
|
59
|
+
|
|
60
|
+
| key | default |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `enabled` | `true` |
|
|
63
|
+
| `settleMs` | `350` |
|
|
64
|
+
| `requestTimeoutMs` | `20000` |
|
|
65
|
+
| `powershellPath` | `""` |
|
|
66
|
+
| `logWorkerStderr` | `false` |
|
|
67
|
+
|
|
68
|
+
## Uninstall
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
dsh plugin --profile <profile> remove dsh-windows-parallel-mcp
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The worker process is a child of the host and exits when stdin closes; there is no daemon, no service,
|
|
75
|
+
no scheduled task, nothing left behind.
|
|
76
|
+
|
|
77
|
+
## Troubleshooting
|
|
78
|
+
|
|
79
|
+
| symptom | cause |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `wpm` tool missing | the plugin did not activate — check the boot output for `windows-parallel`, then run `node scripts/verify-install.mjs` |
|
|
82
|
+
| every action returns `paused` | `enabled` is false, or the engine is paused by the owner |
|
|
83
|
+
| `unreachable` on a terminal | by design: terminal text surfaces expose neither a child window nor a `Document` element (`terminal_no_door` when recognised as a terminal) |
|
|
84
|
+
| `engine worker unavailable` | the sidecar could not start; set `logWorkerStderr` to `true` and re-run — the worker's own message is the diagnostic |
|
package/README.md
CHANGED
|
@@ -1,18 +1,125 @@
|
|
|
1
1
|
# dsh-windows-parallel-mcp
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **0.1.0 — first usable package.** The name was reserved earlier under a weaker claim; the claim
|
|
4
|
+
> below is the measured one. See [What measurement established](#what-measurement-established) for
|
|
5
|
+
> what did **not** survive.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
A DSH plugin that lets an agent drive **its own** Windows windows without moving your cursor. Where
|
|
8
|
+
a window accepts a window message, you never lose focus at all. Where it only exposes UI Automation,
|
|
9
|
+
you lose focus for one bounded flash that is reversed automatically. Everywhere else it refuses, with
|
|
10
|
+
a code and a reason.
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
Not affiliated with `dsh-windows-mcp`. Different plugin, different trade-off: that one is a carrier
|
|
13
|
+
bundle with a broad tool surface; this one is a single action tool whose entire design is about
|
|
14
|
+
*not* disturbing the desktop.
|
|
8
15
|
|
|
9
|
-
|
|
16
|
+
## What it does
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
One tool, five actions:
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
| action | what it returns |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
|
|
23
|
+
| `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
|
|
24
|
+
| `click` | click at a screen coordinate inside the named window |
|
|
25
|
+
| `type` | write text into the target (a classic edit child, or a named UIA element) |
|
|
26
|
+
| `focus` | move keyboard focus to a named control inside the target |
|
|
14
27
|
|
|
15
|
-
|
|
28
|
+
The engine picks the cheapest available door per call:
|
|
29
|
+
|
|
30
|
+
- **quiet tier** — a classic child window receives the click/text as a window message. Measured:
|
|
31
|
+
0 foreground changes in 6 of 6 rounds, effect verified by the app's own state, cursor moved 0 px.
|
|
32
|
+
- **bounded-flash tier** — only UI Automation can reach the control, which raises the target. The
|
|
33
|
+
engine records the focus table *before* acting, reverses it **once** afterwards, and never pulls
|
|
34
|
+
focus from a window you chose. Measured net return **15–95 ms** from three independent
|
|
35
|
+
measurements (the 120 ms budget was never approached).
|
|
36
|
+
|
|
37
|
+
## What you see while it works
|
|
38
|
+
|
|
39
|
+
After a successful `click` a small marker is placed at the point that was clicked. It is a
|
|
40
|
+
click-through, always-on-top window with `WS_EX_TOPMOST | WS_EX_NOACTIVATE | WS_EX_TRANSPARENT`:
|
|
41
|
+
measured that `Show()` does not change `GetForegroundWindow`, that `WindowFromPoint` at the marker's
|
|
42
|
+
centre returns the window *underneath*, and that a real click through the shipped plugin puts the
|
|
43
|
+
marker over the point it hit (physical pixels; the process declares DPI awareness, because using
|
|
44
|
+
WPF's device-independent units put the marker at half scale on a 150% display). It hides itself
|
|
45
|
+
1.5 s after the last placement. Cost: ~19 ms per placement, fired after the action has already
|
|
46
|
+
answered; the first action pays a one-time ~875 ms while the overlay starts.
|
|
47
|
+
|
|
48
|
+
**The pause key is not a fixed key.** `Ctrl+Alt+Q` is the first candidate, but it can already be
|
|
49
|
+
owned by another app — on the machine this was measured on it was (Win32 1409), and seven of the
|
|
50
|
+
other eight measured candidates were free. The engine walks a candidate list, registers the first
|
|
51
|
+
free chord, and **reports what it actually registered** in `status` as `pauseHotkey=...`. It never
|
|
52
|
+
silently claims the documented key works. `overlay=true` in settings controls the marker; the pause
|
|
53
|
+
flag itself is engine-side and refuses actions with `paused`.
|
|
54
|
+
|
|
55
|
+
Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
|
|
56
|
+
`terminal_no_door`, `needs_facts`, `action_failed`, `restore_failed`. Each carries a reason and a
|
|
57
|
+
next step — see [docs/refusals.md](docs/refusals.md).
|
|
58
|
+
|
|
59
|
+
## What it does not do
|
|
60
|
+
|
|
61
|
+
- **No synthetic input.** There is no `physical` option: it is absent from the schema, not disabled
|
|
62
|
+
by default. No `SendInput`, no `keybd_event`, no `mouse_event`.
|
|
63
|
+
- **No forged-Alt foreground trick.** That route works and other plugins use it, but it injects a
|
|
64
|
+
real key event — a keystroke you make in that window can land in whichever window the trick just
|
|
65
|
+
raised.
|
|
66
|
+
- **No OCR / Set-of-Marks / pixel fallback.** Not part of this claim, and already done well elsewhere.
|
|
67
|
+
- **No watchdog.** The restore is one-shot and happens inline. A watchdog that keeps chasing the
|
|
68
|
+
foreground would fight you.
|
|
69
|
+
- **Terminals are refused** (`terminal_no_door`): their text surface exposes neither a child window
|
|
70
|
+
nor a `Document` element. That is the target a developer most wants driven quietly, and it is the
|
|
71
|
+
one that cannot be.
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
dsh plugin --profile <profile> add dsh-windows-parallel-mcp
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Requires Windows with Windows PowerShell 5.1 (it ships with Windows) — **no Python, no uv, no MSVC
|
|
80
|
+
runtime, no native module**. The engine is a PowerShell sidecar started lazily on the first tool
|
|
81
|
+
call, not at plugin load.
|
|
82
|
+
|
|
83
|
+
`engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
|
|
84
|
+
degradation.
|
|
85
|
+
|
|
86
|
+
## Settings
|
|
87
|
+
|
|
88
|
+
| key | default | effect |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| `enabled` | `true` | server-side gate: when off, every action refuses with `paused` before the engine is reached |
|
|
91
|
+
| `settleMs` | `350` | how long the app gets to commit state before the effect is judged |
|
|
92
|
+
| `requestTimeoutMs` | `20000` | a worker that stops answering is killed and restarted on the next call |
|
|
93
|
+
| `powershellPath` | `""` | override the interpreter (pwsh accepted) |
|
|
94
|
+
| `logWorkerStderr` | `false` | forward worker diagnostics to the host log |
|
|
95
|
+
|
|
96
|
+
## What measurement established
|
|
97
|
+
|
|
98
|
+
The hard gate was run on a real Windows desktop before any of this shipped, and part of the original
|
|
99
|
+
goal statement did not survive it. Kept here rather than quietly dropped:
|
|
100
|
+
|
|
101
|
+
- **Cursor: true.** Every channel tested produced 0 px of cursor displacement across 24 action
|
|
102
|
+
rounds, against a control arm that made no call.
|
|
103
|
+
- **"Keyboard focus never changes": false as a general property.** UIA pattern actions raised their
|
|
104
|
+
own target in 12/12 and 6/6 rounds with no mouse button down, no modifier key down and the cursor
|
|
105
|
+
outside the target rect; a no-call control arm raised 0/6 in the same conditions.
|
|
106
|
+
- **Window messages: true but narrow.** 6/6 effective, 0/6 raising. But a message needs an
|
|
107
|
+
*address*: only 17 of 57 live windows here have one, and the two largest families (UWP/WinUI,
|
|
108
|
+
Chromium/Electron) have none.
|
|
109
|
+
- **The complementary-exclusive catch:** on the toolkit where messages work (WinForms/classic),
|
|
110
|
+
UIA exposes no patterns at all; on the toolkits where UIA works (WPF/UWP/Chromium), there is no
|
|
111
|
+
message door. The identifiable door and the quiet door are never on the same window.
|
|
112
|
+
- **Restoration is measured, not assumed.** After a raise, the widget that held focus came back
|
|
113
|
+
6/6 and 6/6 in two independent runs, and internal focus (not just the window) returned 4/4.
|
|
114
|
+
- **The engine is often quieter than the budget suggests.** Under its real operating condition,
|
|
115
|
+
UIA `Invoke` was foreground-neutral in 0 of 12 rounds — the earlier 6/6 and 12/12 were measured
|
|
116
|
+
under a construction that first took the foreground away. The flash tier is a fuse, not a promise
|
|
117
|
+
of disturbance.
|
|
118
|
+
|
|
119
|
+
`elevated_target` is measured live: the engine compares the target's integrity RID against its own
|
|
120
|
+
and refuses before acting (verified on an elevated Task Manager; 19 medium windows, zero
|
|
121
|
+
misrefusals). The **restore-failure path on an elevated target** (`restore_failed`) remains
|
|
122
|
+
unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.md).
|
|
16
123
|
|
|
17
124
|
## License
|
|
18
125
|
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# dsh-windows-parallel-mcp bundle patch.
|
|
2
|
+
#
|
|
3
|
+
# 形态 A(DSH 原生插件)的装配行:把本包作为一行追加进 profile 装配树,由宿主直接
|
|
4
|
+
# 注册 `wpm` 工具。这里**没有 bridge row、没有 transport: stdio、没有 MCP server**——
|
|
5
|
+
# 那是形态 B。所有者 2026-11-19 选了 A,见 spec.md R3.1′。
|
|
6
|
+
#
|
|
7
|
+
# 纯新增行,不替换任何官方 entry。唯一子进程是 PowerShell 引擎 worker,两种形态都需要它,
|
|
8
|
+
# 且只在第一次工具调用时才启动(lib/engine.js 的 lazy start)。
|
|
9
|
+
#
|
|
10
|
+
# 出厂不写 disabled:用户装上这个包就是想要这个工具。开关在设置面(`enabled` 配置项,
|
|
11
|
+
# volatile → 热生效),而不是靠装配行把它藏起来——藏起来的结果是「装了但模型看不见」,
|
|
12
|
+
# 那是最难诊断的一类故障。
|
|
13
|
+
- insert:
|
|
14
|
+
- id: windows-parallel
|
|
15
|
+
name: dsh-windows-parallel-mcp
|
package/docs/refusals.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 拒绝码词典
|
|
2
|
+
|
|
3
|
+
本文件是引擎拒绝语义的**对外文档形态**,也是 `src/schema/tools.json` 里 `refusals` 数组的人工可读版。
|
|
4
|
+
两侧由 `scripts/check-refusals.mjs` 强制对齐:代码里的字面量 ⊆ 本表,本表 ⊆ schema 数组。
|
|
5
|
+
|
|
6
|
+
## 为什么需要这本词典
|
|
7
|
+
|
|
8
|
+
R2′ 把「拒绝」当成本产品的**正常结果**(`engine.ps1` 首段注释),而不是异常路径。既然如此,
|
|
9
|
+
拒绝就必须携带两样东西才能用:
|
|
10
|
+
|
|
11
|
+
1. **一个封闭的码**——让调用方可以分支,而不是读一句人话去猜;
|
|
12
|
+
2. **一个可执行的下一步**——否则就变成 R3.2 明确禁止的「底噪式套话」:报了错,但没人知道该做什么。
|
|
13
|
+
|
|
14
|
+
所以下表每一行都写「下一步」,而不是只写「为什么失败」。
|
|
15
|
+
|
|
16
|
+
## 两层,不是一个集合
|
|
17
|
+
|
|
18
|
+
代码里实际有两个层,历史注释只描述了一层,这是本词典要显式化的第一件事:
|
|
19
|
+
|
|
20
|
+
| 层 | 出处 | 数量 | 语义 |
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| 决定层 | `src/engine/decide.ps1` 的 `$WpmRefusals` | 6 | 动作**在执行之前**被合法否决,目标本身没被碰过 |
|
|
23
|
+
| 运行时失败层 | `src/engine/engine.ps1` 执行/回还段 | 2 | 决定说「能做」,做的过程中通道炸了或回还没成 |
|
|
24
|
+
|
|
25
|
+
混在一起会让人以为「8 个码都是设计好的分支」,实际后 2 个是**兜底**:它们出现就意味着
|
|
26
|
+
引擎的判断与实际能力不一致,属于需要调查的信号,不该被当成正常分支来轮询。
|
|
27
|
+
|
|
28
|
+
## 决定层(6 码)
|
|
29
|
+
|
|
30
|
+
| 码 | 触发条件(代码位置) | 语义 | 下一步动作 | 实测状态 |
|
|
31
|
+
|---|---|---|---|---|
|
|
32
|
+
| `no_hwnd` | `engine.ps1:109`(hwnd 不是活窗口)/`decide.ps1:73`(未给 hwnd) | 没有可用目标 | 先调 `wpm_windows` 拿 hwnd,再重试;不要用屏幕坐标猜 | **REAL** — `test/refusals-test.ps1` R1:`hwnd=1` 直接返回该码 |
|
|
33
|
+
| `paused` | `decide.ps1:69`(`$script:WpmPaused`) | 所有者按了暂停 | 停手。这是**服务端**拒绝,不是提示层建议;不要换目标绕过 | **REAL** — R2:真实桌面上把 paused 打开,`status` 返回该码 |
|
|
34
|
+
| `elevated_target` | `decide.ps1:77`(`facts.elevatedTarget`);flag 由 `win.ps1` 的 `WpmWin::IsElevatedTarget` 实测置真 | 目标完整性级别更高,当前进程写不进去 | 让所有者用非提权方式重开该程序;不要提权重试 | **REAL** — 2026-11-20 `test/integrity-probe.ps1`:桌面上任务管理器(0x3000 high)被识别,`Get-WpmFacts` → `elevatedTarget=True`,决策 `refuse/elevated_target`;其余 19 个 medium 窗零误判 |
|
|
35
|
+
| `unreachable` | `decide.ps1:111`(测过:无消息门、无可用 pattern);运行时窄路 `engine.ps1:150,159,165,185,195` | 目标没有任何可在不注入物理输入的前提下使用的门 | 换目标;或让目标暴露可寻址子窗(原生 Win32/WinForms) | **REAL** — R3:WinForms 目标按名字取控件 → 消息门被抑制、WinForms 无 pattern → 该码 |
|
|
36
|
+
| `terminal_no_door` | `decide.ps1:84`(family=terminal 且两门皆无) | 终端文字面既不暴露子 HWND,也没有 Document 元素 | 换目标(浏览器地址栏/记事本等),终端不在可驱动面内 | **SIMULATED** — 判定层注入。真实终端窗实测刻意推迟,理由见下 |
|
|
37
|
+
| `needs_facts` | `decide.ps1:65,107` | 调用方没给这个目标的实测事实 | 先测量再决定。**拒绝,而不是默认走安静档** | **REAL(表级)** — 引擎内不可达:`facts` 恒被测量,本码只在表被单独使用时出现 |
|
|
38
|
+
|
|
39
|
+
## 运行时失败层(2 码)
|
|
40
|
+
|
|
41
|
+
| 码 | 触发条件 | 语义 | 下一步动作 | 实测状态 |
|
|
42
|
+
|---|---|---|---|---|
|
|
43
|
+
| `action_failed` | `engine.ps1:218`(通道调用抛异常) | 决定说能做,实际调用炸了 | 报给所有者并附异常原文;同一目标不要自动重试第二次 | **NOT-COVERED** — 需要可稳定抛错的真实目标,本轮未构造 |
|
|
44
|
+
| `restore_failed` | `engine.ps1:266`(表判 restore、OS 拒绝 SetForegroundWindow) | 所有者被留在了一个不是他选的窗口里 | 立刻上报;不要静默重试,也不要启动看门狗抢第三次 | **NOT-COVERED** — 需提权窗配合,属 task_52 |
|
|
45
|
+
|
|
46
|
+
## 三个诚实的缺口(写在文档里,而不是留白)
|
|
47
|
+
|
|
48
|
+
1. **`elevated_target` 已接线(2026-11-20,task_52 的识别半边)。** 检测是只读的 token 比较
|
|
49
|
+
(`OpenProcess(QUERY_LIMITED)` → `TokenIntegrityLevel` → 最后一个子授权 RID),读不到一律按
|
|
50
|
+
未知→不拒绝——猜「已提权」会把每个句柄读取失败的窗口都拒掉,那是反向的错检测。
|
|
51
|
+
接线过程中被实测抓出三个「静默恒 false」缺陷:size-probe 的返回值语义(文档规定该调用**必然
|
|
52
|
+
返回 FALSE**)、`GetLengthSid` 在本机返回 TRUE+len=0、SID 头未校验就索引。三者都让检查「看起来
|
|
53
|
+
在工作」而实际全部 unknown——这正是「错的检测比没有更糟」的具体形态。
|
|
54
|
+
**仍缺的**:`restore_failed` 兜底路径(提权窗 + 抬前台被 OS 拒绝的端到端)需要提权窗口在跑
|
|
55
|
+
battery 时在场;本轮 Task Manager 在场时测到了识别与拒绝,恢复兜底未触发。
|
|
56
|
+
2. **`action_failed` / `restore_failed` 没有实测样例。** 表中标 NOT-COVERED,不写「已支持」。
|
|
57
|
+
3. **`terminal_no_door` 只有判定层实测。** 本轮不拉真实终端窗口,是因为 `findings.md:311-316` 记录过一次
|
|
58
|
+
`wt --headless` 残留 Error 弹窗事故(单实例转发 + 弹窗归属真实宿主,`Stop-Process` 够不到)。
|
|
59
|
+
真实证据是覆盖率普查:`findings-G0-VERDICT.md` 的 `uap-framed` 30 窗 0 门。
|
|
60
|
+
|
|
61
|
+
## 与工具 schema 的关系
|
|
62
|
+
|
|
63
|
+
- `src/schema/tools.json` 的 `refusals` 数组是机器可读形态;每个动作型工具(`wpm_click` / `wpm_type` /
|
|
64
|
+
`wpm_focus`)列出它可能返回的码,并带**可执行**的拒绝路径用例。
|
|
65
|
+
- `wpm_windows` / `wpm_status` 是只读查询,**不产生拒绝码**。与其编造一条假分支,不如在 schema 里写
|
|
66
|
+
`noRefusalReason` 并让门禁检查它非空。
|
|
67
|
+
- `test/schema-test.mjs` 校验:码集合三方一致、用例参数能通过该工具的 inputSchema、每个动作型工具至少一条用例。
|
package/dsh.plugin.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "dsh-external/dsh-windows-parallel-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "./lib/index.js",
|
|
5
|
+
"description": "One tool, five actions: drive a Windows window without moving the cursor or stealing the keyboard. Prefers window messages (zero foreground change); falls back to UI Automation with a bounded, self-reversing focus flash (measured net return 15-95 ms).",
|
|
6
|
+
"engines": {
|
|
7
|
+
"dsh": ">=0.1.7-0 <0.3.0-0"
|
|
8
|
+
},
|
|
9
|
+
"contributes": {
|
|
10
|
+
"tools": [
|
|
11
|
+
{
|
|
12
|
+
"name": "wpm",
|
|
13
|
+
"description": "Drive a Windows window without moving the cursor or stealing the keyboard (actions: windows, status, click, type, focus)."
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"skills": []
|
|
17
|
+
}
|
|
18
|
+
}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// config.js — the settings surface, built on the host's schema library when it is reachable and on a
|
|
2
|
+
// standard-schema shim when it is not.
|
|
3
|
+
//
|
|
4
|
+
// WHY THIS FILE EXISTS AT ALL. The first version exported `Config` as a factory function. Cordis
|
|
5
|
+
// requires a *standard-schema value* — it calls `Config['~standard'].validate(config)` — so the
|
|
6
|
+
// plugin failed to activate with `Cannot read properties of undefined (reading 'validate')`, and the
|
|
7
|
+
// only reason it was found is that the profile was actually booted (`dsh --profile wpm-dev headless`)
|
|
8
|
+
// instead of being assumed good from a passing unit test. A plugin that never activates is the worst
|
|
9
|
+
// failure mode available: it registers no tool, prints one warning into a busy log, and looks
|
|
10
|
+
// installed.
|
|
11
|
+
//
|
|
12
|
+
// WHY NOT A HARD DEPENDENCY. `@deepseek-ai/schemastery` is a host-provided peer. Declaring it as a
|
|
13
|
+
// dependency would drag a second copy of the schema library into the profile, and declaring it as a
|
|
14
|
+
// peer would make install fail wherever the host resolves peers differently than it does here. So the
|
|
15
|
+
// import is attempted, and the shim is the documented fallback.
|
|
16
|
+
//
|
|
17
|
+
// WHAT THE SHIM IS. A standard-schema implementation over a flat, explicitly typed field list. It
|
|
18
|
+
// applies defaults, rejects wrong types and out-of-range values, and reports issues in the shape
|
|
19
|
+
// Cordis renders. It is NOT schemastery: the settings FORM is rendered from schemastery's field
|
|
20
|
+
// metadata, so a host that cannot resolve schemastery gives the user no form — the values still work
|
|
21
|
+
// from the bundle patch. That limitation is stated in the README rather than papered over.
|
|
22
|
+
const FIELDS = [
|
|
23
|
+
{ key: 'enabled', type: 'boolean', default: true, volatile: true,
|
|
24
|
+
description: 'Master switch. When off, every action refuses with `paused` before the engine is reached.' },
|
|
25
|
+
{ key: 'settleMs', type: 'number', default: 350, min: 0, max: 2000, volatile: true,
|
|
26
|
+
description: 'How long the target app gets to commit its state before the effect is judged.' },
|
|
27
|
+
{ key: 'requestTimeoutMs', type: 'number', default: 20000, min: 1000, max: 600000,
|
|
28
|
+
description: 'A worker that stops answering is killed and restarted on the next call.' },
|
|
29
|
+
{ key: 'powershellPath', type: 'string', default: '',
|
|
30
|
+
description: 'Override the PowerShell executable. Windows PowerShell 5.1 is the floor; pwsh is accepted.' },
|
|
31
|
+
{ key: 'overlay', type: 'boolean', default: true, volatile: true,
|
|
32
|
+
description: 'Show the click-through AI marker at the point each action touched. It never takes '
|
|
33
|
+
+ 'the foreground and never intercepts a click (measured). The first action pays a one-time '
|
|
34
|
+
+ 'worker round-trip while the overlay starts; after that a placement costs ~19ms and does not '
|
|
35
|
+
+ 'gate the action result.' },
|
|
36
|
+
{ key: 'logWorkerStderr', type: 'boolean', default: false, volatile: true,
|
|
37
|
+
description: 'Forward the sidecar’s stderr diagnostics to the host log.' },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
/** Defaults, for documentation and for tests that must not depend on a resolver. */
|
|
41
|
+
export const CONFIG_DEFAULTS = Object.fromEntries(FIELDS.map((f) => [f.key, f.default]));
|
|
42
|
+
|
|
43
|
+
/** Validate one raw config object against FIELDS. Returns `{ value, issues }` standard-schema style. */
|
|
44
|
+
function validateWithShim(raw) {
|
|
45
|
+
const input = raw && typeof raw === 'object' ? raw : {};
|
|
46
|
+
const value = {};
|
|
47
|
+
const issues = [];
|
|
48
|
+
for (const field of FIELDS) {
|
|
49
|
+
const given = input[field.key];
|
|
50
|
+
if (given === undefined || given === null) { value[field.key] = field.default; continue; }
|
|
51
|
+
if (field.type === 'boolean') {
|
|
52
|
+
if (typeof given !== 'boolean') issues.push({ message: `expected a boolean`, path: [field.key] });
|
|
53
|
+
else value[field.key] = given;
|
|
54
|
+
} else if (field.type === 'number') {
|
|
55
|
+
if (typeof given !== 'number' || !Number.isFinite(given)) {
|
|
56
|
+
issues.push({ message: `expected a finite number`, path: [field.key] });
|
|
57
|
+
} else if ((field.min !== undefined && given < field.min) || (field.max !== undefined && given > field.max)) {
|
|
58
|
+
issues.push({ message: `expected ${field.min}..${field.max}`, path: [field.key] });
|
|
59
|
+
} else {
|
|
60
|
+
value[field.key] = given;
|
|
61
|
+
}
|
|
62
|
+
} else if (typeof given !== 'string') {
|
|
63
|
+
issues.push({ message: `expected a string`, path: [field.key] });
|
|
64
|
+
} else {
|
|
65
|
+
value[field.key] = given;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (const key of Object.keys(input)) {
|
|
69
|
+
if (!FIELDS.some((f) => f.key === key)) {
|
|
70
|
+
// Unknown keys are an issue, not silence: a typo in the bundle patch would otherwise take the
|
|
71
|
+
// default and leave the user wondering why their setting did nothing.
|
|
72
|
+
issues.push({ message: `unknown setting`, path: [key] });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return issues.length ? { issues } : { value };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const shimSchema = {
|
|
79
|
+
'~standard': {
|
|
80
|
+
version: 1,
|
|
81
|
+
vendor: 'dsh-windows-parallel-mcp',
|
|
82
|
+
validate: validateWithShim,
|
|
83
|
+
},
|
|
84
|
+
/** Marker parity with schemastery so `typeof field.volatile === 'function'` probes behave. */
|
|
85
|
+
fields: FIELDS,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Build the Config value. Tries the host's schema library first; falls back to the shim.
|
|
90
|
+
* Returns `{ schema, source }` so the caller can log which one is active -- a silent fallback is how
|
|
91
|
+
* "works on my machine" diverges from "works on the host".
|
|
92
|
+
*/
|
|
93
|
+
export async function createConfigSchema() {
|
|
94
|
+
try {
|
|
95
|
+
// Static-import bridge (see lib/peers-schemastery.js): a dynamic bare specifier does not
|
|
96
|
+
// resolve for a `link:`-installed package under the host, which is exactly why the desktop
|
|
97
|
+
// profile fell to the shim and rendered no settings form.
|
|
98
|
+
const mod = await import('./peers-schemastery.js');
|
|
99
|
+
const z = mod?.z;
|
|
100
|
+
if (z && typeof z.object === 'function') {
|
|
101
|
+
const shape = {};
|
|
102
|
+
for (const field of FIELDS) {
|
|
103
|
+
let s;
|
|
104
|
+
if (field.type === 'boolean') s = z.boolean();
|
|
105
|
+
else if (field.type === 'number') s = z.number();
|
|
106
|
+
else s = z.string();
|
|
107
|
+
if (field.min !== undefined || field.max !== undefined) {
|
|
108
|
+
if (typeof s.min === 'function' && field.min !== undefined) s = s.min(field.min);
|
|
109
|
+
if (typeof s.max === 'function' && field.max !== undefined) s = s.max(field.max);
|
|
110
|
+
}
|
|
111
|
+
if (field.description) s = s.description(field.description);
|
|
112
|
+
s = s.default(field.default);
|
|
113
|
+
// `.volatile()` marks a field as hot-reloadable on 0.1.7+. Guarded because older schema
|
|
114
|
+
// lines in the same major do not have it.
|
|
115
|
+
if (field.volatile && typeof s.volatile === 'function') s = s.volatile();
|
|
116
|
+
shape[field.key] = s;
|
|
117
|
+
}
|
|
118
|
+
const schema = z.object(shape);
|
|
119
|
+
return { schema: typeof schema.prefault === 'function' ? schema.prefault({}) : schema, source: '@deepseek-ai/schemastery' };
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
// Documented fallback, reported through `source`.
|
|
123
|
+
}
|
|
124
|
+
return { schema: shimSchema, source: 'local-standard-schema-shim' };
|
|
125
|
+
}
|