dsh-windows-parallel-mcp 0.8.2 → 0.9.0-rc.2

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.
Files changed (53) hide show
  1. package/CHANGELOG.de.md +444 -419
  2. package/CHANGELOG.es.md +444 -419
  3. package/CHANGELOG.fr.md +444 -419
  4. package/CHANGELOG.it.md +444 -419
  5. package/CHANGELOG.ja.md +444 -419
  6. package/CHANGELOG.ko.md +444 -419
  7. package/CHANGELOG.md +965 -940
  8. package/CHANGELOG.pt.md +444 -419
  9. package/CHANGELOG.ru.md +444 -419
  10. package/CHANGELOG.zh.md +444 -419
  11. package/INSTALL.de.md +126 -126
  12. package/INSTALL.es.md +126 -126
  13. package/INSTALL.fr.md +126 -126
  14. package/INSTALL.it.md +126 -126
  15. package/INSTALL.ja.md +126 -126
  16. package/INSTALL.ko.md +126 -126
  17. package/INSTALL.md +122 -122
  18. package/INSTALL.pt.md +126 -126
  19. package/INSTALL.ru.md +126 -126
  20. package/INSTALL.zh.md +126 -126
  21. package/README.de.md +684 -684
  22. package/README.es.md +684 -684
  23. package/README.fr.md +684 -684
  24. package/README.it.md +684 -684
  25. package/README.ja.md +684 -684
  26. package/README.ko.md +684 -684
  27. package/README.md +680 -680
  28. package/README.pt.md +684 -684
  29. package/README.ru.md +684 -684
  30. package/README.zh.md +684 -684
  31. package/cordis.patch.yml +15 -15
  32. package/docs/refusals.md +90 -90
  33. package/docs/takeover.md +128 -128
  34. package/dsh.plugin.json +18 -18
  35. package/lib/config.js +275 -275
  36. package/lib/engine.js +252 -252
  37. package/lib/host-tools.js +365 -338
  38. package/lib/index.js +1275 -1249
  39. package/lib/peers-schemastery.js +23 -23
  40. package/lib/peers-tools.js +15 -15
  41. package/lib/proof-window.mjs +427 -427
  42. package/package.json +122 -122
  43. package/server.json +110 -110
  44. package/src/engine/decide.ps1 +356 -356
  45. package/src/engine/engine.ps1 +1208 -1208
  46. package/src/engine/hud.ps1 +411 -411
  47. package/src/engine/input-inject.ps1 +176 -176
  48. package/src/engine/overlay.ps1 +389 -389
  49. package/src/engine/takeover.ps1 +144 -144
  50. package/src/engine/win.ps1 +1881 -1881
  51. package/src/engine/worker.ps1 +310 -310
  52. package/src/schema/tools.json +533 -533
  53. package/types/index.d.ts +190 -187
package/README.md CHANGED
@@ -1,680 +1,680 @@
1
- # dsh-windows-parallel-mcp
2
-
3
- **English** · [中文](README.zh.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Italiano](README.it.md) · [Español](README.es.md) · [Português](README.pt.md) · [Русский](README.ru.md)
4
- > **Current release: 0.8.2** — this document describes the contract as of that version. What
5
- > changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
6
-
7
- A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
8
- on request. Where a window accepts a window message, you never lose focus at all. Where it only
9
- exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
10
- explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
11
- HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason — never with
12
- silence: every refusal carries a code from a closed set of seventeen and the next step.
13
-
14
- **It ships in two forms over one engine, and 0.8.0 did not replace the first one.** Inside DSH it is a
15
- plugin (`apply()` on the host half, PowerShell sidecar underneath). Outside it, the same package is an
16
- MCP server over stdio (`bin: wpm-mcp`), whose tool list is generated from the same contract file — see
17
- "The second form" below.
18
-
19
- **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
20
- opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
21
- start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
22
- (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
23
- on this host's terminal, so the terminal stays refused rather than becoming a promise.
24
-
25
- Source, the measurement scripts behind every number below, and the release history live at
26
- **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
27
- "this target refused and I think it should not have".
28
-
29
- Not affiliated with `dsh-windows-mcp`. Different plugin, different trade-off: that one is a carrier
30
- bundle with a broad tool surface; this one is a single action tool whose entire design is about
31
- *not* disturbing the desktop.
32
-
33
- ## What it does
34
-
35
- One tool, eleven actions:
36
-
37
- | action | what it returns |
38
- |---|---|
39
- | `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
40
- | `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
41
- | `click` | click at a screen coordinate inside the named window, or at a snapshot `label` |
42
- | `type` | write text into the target (a classic edit child, a named UIA element, or a `label`) |
43
- | `focus` | move keyboard focus to a named control inside the target, or to a `label` |
44
- | `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
45
- | `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
46
- | `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
47
- | `launch` | start a whitelisted program; reports the pid, and the window only once it really exists |
48
- | `clipboard` | read or write the system clipboard — a read reports lengths and never the payload |
49
- | `window` | minimize / restore / move / resize / topmost ONE named window, verified by reading its state back |
50
-
51
- The engine picks the cheapest available door per call:
52
-
53
- - **quiet tier** — a classic child window receives the click/text as a window message. Measured:
54
- 0 foreground changes in 6 of 6 rounds, cursor moved 0 px. (Those 6 rounds also read the target
55
- app's own state to confirm the click landed — that was a *separate* experiment, not the `effect=`
56
- field, which says only who reported the call returned; see the table below.)
57
- - **bounded-flash tier** — only UI Automation can reach the control, which raises the target. The
58
- engine records the focus table *before* acting, reverses it **once** afterwards, and never pulls
59
- focus from a window you chose. Measured net return **15–95 ms** from three independent
60
- measurements (the 120 ms budget was never approached).
61
-
62
- ## What you see while it works
63
-
64
- After a successful `click` a small marker is placed at the point that was clicked. It is a
65
- click-through, always-on-top window with `WS_EX_TOPMOST | WS_EX_NOACTIVATE | WS_EX_TRANSPARENT`:
66
- measured that `Show()` does not change `GetForegroundWindow`, that `WindowFromPoint` at the marker's
67
- centre returns the window *underneath*, and that a real click through the shipped plugin puts the
68
- marker over the point it hit (physical pixels; the process declares DPI awareness, because using
69
- WPF's device-independent units put the marker at half scale on a 150% display). It hides itself
70
- 1.5 s after the last placement. Cost: ~19 ms per placement, fired after the action has already
71
- answered; the first action pays a one-time ~875 ms while the overlay starts.
72
-
73
- **The pause key is not a fixed key.** `Ctrl+Alt+Q` is the first candidate, but it can already be
74
- owned by another app — on the machine this was measured on it was (Win32 1409), and seven of the
75
- other eight measured candidates were free. The engine walks a candidate list, registers the first
76
- free chord, and **reports what it actually registered** in `status` as `pauseHotkey=...`. It never
77
- silently claims the documented key works. `overlay=true` in settings controls the marker; the pause
78
- flag itself is engine-side and refuses actions with `paused`.
79
-
80
- Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
81
- `uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `takeover_unavailable`,
82
- `keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`, `stale_ref`. Each
83
- carries a reason and a next step — see [docs/refusals.md](docs/refusals.md).
84
-
85
- ## Reading the frame instead of guessing
86
-
87
- The three read actions exist so the two halves of a click — *where the thing is* and *where the
88
- picture is* — stop being the caller's arithmetic.
89
-
90
- `label` is not a coordinate in disguise. It is resolved back to the UIA **element** by its runtime id
91
- (measured stable across queries, 71 of 71), so `click`/`type`/`focus` with `label` + `snapId` still
92
- take the silent pattern path. A labelled `click` keeps `x`/`y` required, and the point must fall
93
- inside the labelled element's rect — the point stays the contract. A label whose `snapId` was
94
- superseded is refused with `stale_ref`: element numbers only mean something in the frame that printed
95
- them.
96
-
97
- Image coordinates are never multiplied by the caller:
98
-
99
- ```jsonc
100
- {"action":"screenshot","hwnd":"1310720"}
101
- // -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm captureBackend=bitblt
102
- {"action":"click","hwnd":"1310720","space":"image","shotId":"shot-…","x":350,"y":250}
103
- // the ENGINE converts, then still asserts the point belongs to the target window
104
- ```
105
-
106
- The picture is not returned inline — a plugin cannot mint an inline image block without the host's
107
- attachment service — so the PNG is written to `%LOCALAPPDATA%\wpm\shots\` (newest `shotsKeep` kept)
108
- and read with the host's image reader. `preview` is the cheaper confirmation: it draws the marker at
109
- the point and answers, as text, which element the OS says is there. Confirming a point therefore
110
- never depends on looking at a picture, and a preview writes no input-queue entry, takes no focus and
111
- produces no proof window.
112
-
113
- ### The frame rule, and why 8px mattered
114
-
115
- One rectangle decides everything: `DwmGetWindowAttribute(EXTENDED_FRAME_BOUNDS)`. Measured here,
116
- `GetWindowRect` is **8px larger on every edge** — the invisible resize shadow — and the accessibility
117
- tree mixes the two spaces: its root element reports the shadow-inclusive rect while its children
118
- report the real one, so arithmetic that mixes them is 8px wrong and *looks right*. Labels and the
119
- captured picture therefore come from the same function. When DWM is unavailable (RDP, Basic theme)
120
- the fallback to `GetWindowRect` is **reported** as `frame=win32` rather than swallowed, and
121
- `frameInset` prints the shadow width as data.
122
-
123
- The plan for this release proposed a runtime invariant — "every element rect is inside `screenRect`" —
124
- and measurement refuted it: real Chromium/Electron trees report virtualized content far outside the
125
- viewport (overhangs of 3px, 18px, 287px and 2720px measured here). What replaced it: elements that do
126
- not overlap the capture are **excluded and counted** (`outsideFrame=…`, because a number you cannot
127
- point at would be a trap), the frame is cross-checked against the window rect the tree itself reports
128
- (`frameCheck=pass|fail|unknown`), and a structural gate pins the single-source rule by mutating a copy
129
- of the engine and requiring the corresponding red.
130
-
131
- ### Which capture path painted the picture
132
-
133
- `captureBackend` names the producer: `bitblt` is a direct GDI `BitBlt` off the screen DC, `gdiplus` is
134
- `Graphics.CopyFromScreen` — either the fallback after BitBlt was refused, or nothing else. The cheap
135
- path replaced the old one on measured grounds (16–21 ms against 22–33 ms for a 1920×1080 grab), and the
136
- encoder was deliberately left alone: the PNG encode is the bottleneck (37–39 ms), so JPEG (6 ms, and it
137
- smears text), WIC (158 ms) and 24bpp (7 % smaller) were each measured and each rejected.
138
-
139
- Equivalence was established on a **static** scene, not by file hash — two captures of a live desktop
140
- happen at different instants, so their bytes cannot match, and that difference says nothing about the
141
- paths: identical size, both non-blank, **0 maximum per-channel difference over 17 388 sampled points**,
142
- byte-identical PNGs (8940 = 8940), with the comparator's self-check (two reads of one HBITMAP) also at
143
- 0. The one difference is reported rather than assumed away: `FromHbitmap` yields `Format32bppRgb` where
144
- `CopyFromScreen` yields `Format32bppArgb`. A gate keeps both halves honest — the fallback reachable and
145
- `captureBackend` produced, forwarded and printed (`scripts/check-shot-backend.mjs`, seven mutations each
146
- seen red).
147
-
148
- ### Deciding outside the main context
149
-
150
- The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
151
- clean deciding side and take back one number:
152
-
153
- 1. `snapshot` with `intent:"close the settings dialog"` — the intent travels with the frame, and is
154
- written to `%LOCALAPPDATA%\wpm\last-snapshot.json`;
155
- 2. give the numbered table and the intent to a clean subagent;
156
- 3. it answers with a single `label` — not a selector, not a coordinate;
157
- 4. click with that `label` + `snapId`.
158
-
159
- `sinceSnapId` serves the same goal: an unchanged tree answers `no changes since <id>` instead of
160
- repeating itself, and a delta names only what actually moved (`added` / `removed` / `changed`, keyed
161
- by runtime id).
162
-
163
- **Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
164
- verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
165
- samples cursor position, foreground window, keyboard focus and last-physical-input age — in a short
166
- pre-action control window (when, by construction, nothing was running) and inside the settle wait it
167
- already pays. The judgment is one pure function (`lib/proof-window.mjs`, unit-tested against 40
168
- synthetic windows whose answers are known by construction). What it honestly can and cannot say:
169
- a switch of foreground on a quiet tier fails — the control shows the desktop was not doing it, so it
170
- is the action's to explain; a cursor jump is *reported*, never accused, because with nothing running
171
- this desktop's cursor showed multi-gap unexplained motion on its own (a re-runnable probe ships:
172
- `scripts/idle-baseline.mjs`). The cursor promise therefore lives where blame is decidable: a build
173
- gate confines `SetCursorPos` to `takeover.ps1` and `SendInput` to `input-inject.ps1`, bans
174
- `MOUSEEVENTF_*`/`mouse_event`/`keybd_event` everywhere, and a second gate asserts the structural
175
- promises around them (the HUD is checked before any primitive runs; the cursor move and its restore
176
- share one `try/finally`). A regression fails at build time with certainty instead of being hunted at
177
- runtime among ambient motion. In the takeover tier the cursor motion is **declared**, so it is
178
- reported rather than accused — but `cursorRestored=false` (borrowed and not returned) is a hard
179
- `proof=fail`.
180
-
181
- **And it says who reported the success.** Every action result carries `effect=` in the text and
182
- `effect` in the structured output. The four values are not degrees of confidence in the
183
- application — they name the speaker:
184
-
185
- | `effect` | who is speaking | it proves | it does **not** prove |
186
- |---|---|---|---|
187
- | `unverified` | nobody | nothing | anything |
188
- | `reported-by-send` | the window-message channel | the message was **delivered** | that the target app processed it |
189
- | `reported-by-pattern` | the UI Automation pattern call | the call **returned** without throwing | that the interface actually changed |
190
- | `readback-verified` | the control itself, read back | the value now in the field **equals the value predicted from the field's own measurements** | that the app is *happy* — only that its value is what we said |
191
-
192
- Since 0.1.3 the effect also enters the judgment, which closes the one honest gap 0.1.2 still had:
193
- a still desktop could outvote a total no-op. A call whose channel reported nothing is capped at
194
- `inconclusive` — never `pass`. A batch caller that passes its per-attempt results (`actions`) gets
195
- `fail` when **no** attempt took effect, however few pixels moved. Displacement proves we did not
196
- disturb you; it never proves we accomplished anything. A single `reported-by-*` stays a `pass` with
197
- the caveat spelled out in the reason field (`未独立验证` — nobody observed the app), because turning
198
- weak-but-real evidence into a red would train its readers to ignore the verdict.
199
-
200
- ### The fourth value has to be earned (0.6.0)
201
-
202
- `readback-verified` is granted only by the engine, and only when a **prediction** matches a **read**.
203
- The prediction is computed from measurements the control itself reported — the value it held before,
204
- its own `WM_GETTEXTLENGTH`, its own `EM_GETSEL` answer for where a typed character lands — and the read
205
- happens *after* the settle window, so an app that commits its text asynchronously is not judged against
206
- a half-written buffer:
207
-
208
- ```jsonc
209
- {"action":"type","hwnd":"…","text":"XY","caretPosition":"start"}
210
- // -> type ok channel=message tier=quiet effect=readback-verified
211
- // detail=msg=char|2 child=… caret=start asked=0 applied=0,0 readback=XYabc readbackLen=5 focusMoved=false
212
- ```
213
-
214
- Three things it refuses to do, each measured rather than assumed:
215
-
216
- * **it does not upgrade what it cannot read.** A masked field (`ES_PASSWORD`) returns an empty string
217
- while `WM_GETTEXTLENGTH` still reports the real length. That is "the control hides its text", not
218
- "the field is empty": the result says `readback=unavailable`, the effect keeps whatever the write
219
- earned, and no value is printed anywhere.
220
- * **a mismatch is data, not a failure.** A read-only WinForms edit silently refuses `WM_CHAR` — every
221
- character is accepted by the API and the value never moves — while honouring `WM_SETTEXT`. On the
222
- refusal the result is still `ok:true` with `readbackMismatch=true` and no upgrade; on the write that
223
- lands it is `readback-verified`. No refusal code changed for this batch, on purpose: "the application
224
- formatted my input" is not an error in the call. `test/readback-truth.mjs` asserts both arms against
225
- the value the *application* wrote about itself, from inside its own process — a readback test that
226
- compared our write to our read would be grading homework in our own class, and this repo has already
227
- been caught doing exactly that.
228
- * **the naive guess is not the model.** Text is not appended: it lands at the caret, and a field that
229
- never held focus has its caret at 0 (so `abc` + `XY` is `XYabc`). That is why `caretPosition` exists
230
- and why the result prints `asked=` and `applied=` separately — `EM_SETSEL(-1,-1)` is documented as
231
- "document end" and measured as a no-op on WinForms EDIT, so `end` is `EM_SETSEL(len,len)` with `len`
232
- read from the control. On a buffer containing newlines that numeric end can land inside the text
233
- (`asked=6 applied=4,4`), which is reported instead of hidden; `idle` touches nothing at all. The UIA
234
- `value` channel replaces the whole value and has no caret to move, so it answers
235
- `caretIgnored=value-pattern` rather than pretending to honour it.
236
-
237
- Two more facts ride in the same `detail`, both warnings and neither a refusal: `focusMoved=true` when
238
- the foreground or the focused control differs between the two measurements taken around the send, and
239
- `disabled=true` for a target window that is greyed out — Windows keeps answering our messages while
240
- throwing the input away, so a disabled target loses the right to an `effect` claim
241
- (`effect=unverified`) without becoming an error.
242
-
243
- ## The takeover tier (opt-in)
244
-
245
- Off by default (`takeoverAllowed=false`, `keyInjectAllowed=false`), because moving someone's pointer
246
- is not something an upgrade should switch on. When you turn it on and pass `takeover:true`:
247
-
248
- 1. **arming** — **amber** HUD (`#3A2C0C` surface, `#F0AD18` accent bar). Says what is about to be
249
- borrowed (cursor / keyboard / focus), with the interrupt key that actually registered. Default
250
- 800 ms; this is the cancellation window.
251
- 2. **active** — **red** HUD (`#3A1212` / `#E84040`). The cursor is placed on the action point, the
252
- action runs through the cheapest existing door, and the HUD counts elapsed/limit and characters
253
- injected.
254
- 3. **done** — **green** HUD (`#0E2E1E` / `#34C77B`). The cursor is restored (read-back verified), the
255
- focus is returned through the same one-shot table, and the HUD says so.
256
-
257
- The colour is not decoration: while an agent borrows the pointer the owner is looking at the *target*
258
- window, so the phase is encoded twice — the whole surface tint **and** a 5px accent bar — and
259
- `test/hud-test.ps1` reads the real pixels to assert the three are distinct (C18). Amber = not yet
260
- (cancellable), red = holding something of yours right now, green = returned.
261
-
262
- **The keys, which are easy to mix up:**
263
-
264
- | | key |
265
- |---|---|
266
- | interrupt the running takeover | **`Ctrl+Alt+X`** (the one that registered; candidates `X→Z→C→V→B→N` then `Ctrl+Shift+X`, displayed as `abortChord=`) |
267
- | same thing, no keyboard | the HUD's 取消 / 停止 button (same flag, no priority) |
268
- | pause the whole engine (also aborts a running takeover) | **`Ctrl+Alt+Q`**, here **`Ctrl+Alt+W`** because another app owns Q; `status` reports `pauseHotkey=` |
269
-
270
- The abort chord lives only while the HUD exists (its window owns the registration); the pause key is a
271
- permanent server-side switch. Three interruption paths, all writing the same flag/file: HUD button,
272
- abort chord, and the host's cancellation (`exec.signal` → a latch file the engine polls, because the
273
- worker is single-threaded and cannot read a request while an action is running). Interruption returns
274
- `takeover_aborted` **with** `cursorRestored` and `injectedChars` — it is not a fault, it is the feature.
275
-
276
- Keyboard injection (`keyInput:"inject"`) exists only inside this tier, because `SendInput` writes to
277
- the **foreground** window: measured, text sent while another window was in front landed in that
278
- window and not in the intended one. The engine therefore asserts `GetForegroundWindow() == target`
279
- before sending, re-asserts at send time, and refuses with `keyinject_unavailable` otherwise. It never
280
- injects mouse events — `MOUSEEVENTF_*` is banned repo-wide, so the module is structurally unable to
281
- click. Success is reported as `effect=reported-by-send`, never as "verified". Unicode injection
282
- carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
283
- not a bug.
284
-
285
- ## Desktop actions: launch, clipboard, window (0.7.0)
286
-
287
- Three capabilities that were missing outright — "you cannot even start a program" was the honest answer
288
- — and none of them is a door action. They choose no channel, cost no tier, and produce no proof window,
289
- so they live beside `Invoke-WpmAction` rather than inside it, and the door discipline (point ownership,
290
- the restore table, the proof window) is not widened by any of them.
291
-
292
- **`launch` — two switches, neither of which implies the other.** `appLaunchAllowed` opens the
293
- capability; `appLaunchAllow` lists the exact program names or absolute paths that may run, and an
294
- **empty list means nothing may launch even with the gate on**. Matching is exact and case-folded: there
295
- is no wildcard, and `notepad` does not authorise `notepad-helper.exe` — a whitelist that grows by prefix
296
- is a whitelist that authorises more than it says. A refusal is `app_launch_denied` and is raised before
297
- any worker request, so a refused launch started nothing (asserted with a request counter in
298
- `test/plugin-test.mjs` and re-checked inside the engine against the same table). The engine's own
299
- vocabulary for the window is the interesting part: `Process.Start` returns while the app is still
300
- loading (measured: `MainWindowHandle=0` for 1348 ms on a cold notepad), so a program that has not
301
- published a window yet answers `ok:true` with `hwnd=""` and `detail=window-not-yet` — neither a fake
302
- failure nor a fake readiness. Arguments are passed through as given and written to the audit log,
303
- because listing a program does not vouch for what it is told to do.
304
-
305
- **`clipboard` — the most private read in this product.** What is on the clipboard may be a password or
306
- a token the owner copied seconds ago, so a text read reports its **length**, its result text never
307
- contains the payload, the audit line records `op`/`format`/`chars`, and values are capped at 64 KB with
308
- `truncated` stated rather than silently cut. An image write accepts a `shotId`, so a screenshot can go
309
- straight into the clipboard without the caller handling pixels; the read-back compares the size the
310
- clipboard reports against the size the shot recorded. A clipboard holding neither is refused with the
311
- format names it did find — an empty success would be indistinguishable from "the clipboard is empty".
312
-
313
- **`window` — one named window, five ops, each verified by reading the window back.** `IsIconic`,
314
- `GetWindowRect`, the `WS_EX_TOPMOST` bit — not `ShowWindow`'s return value, because a syscall's answer
315
- describes the CALL and this product has been burned repeatedly by reporting that as a state. `move` and
316
- `resize` pass `SWP_NOACTIVATE`, and the result carries `foregroundTaken=true|false` measured on both
317
- sides of that specific call: `restore` activates by definition (that is what restoring is), and the
318
- honest answer is to report it, not to hide it or to refuse the op the caller asked for. There is no
319
- "all windows" op and no `#32770` discovery: acting on a window nobody named is not a convenience.
320
-
321
- ### One ceiling, eleven actions
322
-
323
- The old shape of this problem was a boolean per capability, which does not scale past the number of
324
- settings anyone will actually read. Instead the two axes are independent:
325
-
326
- ```
327
- the action declares the lowest rung it can ever need (src/schema/tools.json#requiresTier)
328
- the owner sets one ceiling (settings: policy)
329
-
330
- readonly < quiet < flash < takeover
331
- reads message bounded-UIA real cursor / held focus / launch
332
- door flash
333
- ```
334
-
335
- | `policy` | permits | refuses |
336
- |---|---|---|
337
- | `readonly` | `windows`, `status`, `snapshot`, `screenshot`, `preview`, `clipboard` read | every write |
338
- | `quiet` | + `click` / `type` / `focus` through the message door | the flash tier, `clipboard` write, `window`, `launch` |
339
- | `balanced` *(default)* | + the bounded-flash tier, `clipboard` write, `window` ops | `takeover:true`, `keyInput:"inject"`, `launch` |
340
- | `full` | + the takeover tier and `launch` | nothing extra |
341
-
342
- Above the ceiling a call is refused with **`policy_denied`** and the reason names both numbers (what the
343
- action needed, what the policy allows), because the correct next step is a settings change and the wrong
344
- one is a retry. The gate order is `paused → policy → takeoverAllowed/keyInjectAllowed → launch gate +
345
- whitelist → idle check → the door table`, and every step in it is tested by making two gates disagree
346
- about which one spoke (`test/plugin-test.mjs`). Two consequences are worth stating plainly rather than
347
- leaving to discovery: **`takeover:true` now needs `policy:'full'` as well as `takeoverAllowed`** (0.7.0
348
- raised the bar for the loudest tier on purpose), and `clipboard`'s halves are graded separately
349
- (`requiresTierFor`), so a `readonly` owner can still read.
350
-
351
- **Idle instead of a dialog.** When the last *physical* input is younger than `policyIdleMs` (default
352
- 3000 ms) and the action needs the takeover tier, it is refused with **`user_active`** and nothing is
353
- clicked — no popup, no countdown. The upstream design asks the owner to consent by interrupting them;
354
- an interrupt presented as consent is just a second disturbance. The escape hatch is explicit
355
- (`forceUserActive:true`), it does not bypass any other gate, and the audit line records `forced:true` so
356
- an interruption caused on purpose stays distinguishable from one caused by accident. An unattended run
357
- is never blocked by this: with nobody typing, the age grows past the window and the call goes through.
358
-
359
- ### The audit log
360
-
361
- Every action appends one JSONL line to `%LOCALAPPDATA%\wpm\audit.log` — allow **and** deny, because a
362
- trail that records only refusals documents the times the guard worked and is silent about the times it
363
- had nothing to do with. Fields: `ts, action, hwnd, tier, policy, decision, code, userActiveAgeMs,
364
- effect, latencyMs`, plus `target`/`args` for a launch and `op`/`format`/`chars` for a clipboard call.
365
- What is deliberately absent is content: no typed text, no clipboard payload — the second copy of a
366
- secret is the one nobody protects. `auditKeep` (default 2000) bounds the file, pruning oldest-first when
367
- a write pushes it past budget. An audit that cannot be written is reported (`auditNote=n write(s)
368
- failed`) rather than swallowed: a log that looks complete and is not is worse than one that admits it
369
- is missing lines. This is the only artifact that survives a call, and it is the one thing that can
370
- answer "what did the agent do to this machine" after the fact.
371
-
372
- ## The second form: MCP over stdio (0.8.0)
373
-
374
- The same plugin is also an MCP server, and it is the same code rather than a re-implementation of it.
375
- `lib/mcp-server.mjs` registers the tool by calling the very `apply()` the DSH host calls, and forwards
376
- `tools/call` into the same `toRequest()` / gate order / `format()` path, so the eleven actions, the
377
- seventeen refusal codes, the policy ceiling and the audit line are identical in both forms. That is why
378
- the engine files were not touched to add it: a second implementation of a permission is a permission
379
- that can be reached around by using the other copy.
380
-
381
- **One tool, not eleven.** `tools/list` exposes `wpm` with an `action` discriminator, generated from
382
- `src/schema/tools.json` — one `oneOf` branch per action, whose `properties`, `required` and
383
- `additionalProperties` are that action's declaration copied field for field. Nothing in the server
384
- spells out an action name, a parameter name or a code, and `scripts/check-mcp-schema.mjs` is the reason
385
- that stays true: it starts the real server, reads what a client would read, and compares it to the file.
386
- Its self-test mutates both sides on purpose — four edits to the generator must turn the gate red, and two
387
- edits to the *contract* (rename a parameter, flip `additionalProperties`) must stay green AND move,
388
- because an arm that only breaks the generator cannot tell a generated schema from a transcribed one that
389
- happens to agree today.
390
-
391
- **Settings come from the environment, never from the call.** `WPM_POLICY`, `WPM_TAKEOVER_ALLOWED`,
392
- `WPM_APP_LAUNCH_ALLOWED`, `WPM_APP_LAUNCH_ALLOW` and the rest of the `WPM_*` set are read at start-up
393
- and only if present — the defaults stay in `lib/index.js`, because a second copy of a default is a
394
- default that drifts. A client that could raise its own ceiling or add itself to the launch whitelist
395
- would make the authorization model decorative, which is the same reason the DSH form reads settings
396
- from the profile rather than from the prompt.
397
-
398
- **A picture is attached as pixels, because a path is not portable.** The DSH form renders the screenshot
399
- file it wrote; a caller on the other end of a pipe cannot open it, so `tools/call` returns the PNG as
400
- base64 `image` content alongside the text. The text is never replaced by it — `screenRect`, `scale`,
401
- `identity`, `frame` and `captureBackend` stay in the first block, and across the DSH bridge, where a
402
- host that cannot accept image input projects the picture into a text diagnostic, those numbers still
403
- arrive. `WPM_MCP_NO_IMAGE=1` opts out.
404
-
405
- **Refusals survive the trip.** A refused call comes back with `isError` and the code as the first token
406
- of the text, unsoftened. Over the DSH bridge the refusal is re-raised as an error whose message is that
407
- text, so `policy_denied` still reads as `policy_denied` at the far end — asserted, not assumed, in
408
- `test/mcp-bridge.mjs`, which drives the SDK and the bridge code the host actually ships.
409
-
410
- **The transport is the only new attack surface, and it is a pipe.** JSON-RPC 2.0 over stdin/stdout with
411
- Node built-ins and zero dependencies: one JSON object per line, replies keyed by `id` because the worker
412
- is asynchronous, notifications answered with nothing, a non-JSON line answered with `-32700` and a null
413
- `id` without killing the loop, an unknown method answered `-32601` without killing the loop, and stdin
414
- closing meaning "dispose the sidecar and exit 0". Everything that is not a protocol line goes to stderr
415
- — `console.log` in the plugin half would otherwise print into the JSON stream and corrupt it.
416
-
417
- ## What it does not do
418
-
419
- - **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
420
- shipped file. The takeover tier moves the cursor instead of clicking synthetically — that is why
421
- "the agent can type into the foreground" does not become "the agent can click anything".
422
- - **No takeover without the HUD.** `takeover_unavailable` is a refusal, not a warning, and the
423
- request is never downgraded silently into the quiet tier.
424
- - **No forged-Alt foreground trick.** That route works and other plugins use it, but it injects a
425
- real key event — a keystroke you make in that window can land in whichever window the trick just
426
- raised.
427
- - **No OCR / Set-of-Marks / pixel fallback.** Not part of this claim, and already done well elsewhere.
428
- - **No watchdog.** The restore is one-shot and happens inline. A watchdog that keeps chasing the
429
- foreground would fight you.
430
- - **No HTTP, no SSE, no OAuth, no TLS.** Two forms exist and neither has a network face: in-process for
431
- DSH, stdio for MCP. "No network surface" is not a hardening claim, it is the absence of one — there is
432
- nothing to authenticate against, nothing to listen on, and nothing that keeps running when the caller
433
- goes away.
434
- - **Terminals are still refused** (`terminal_no_door`), and now for a measured reason. The 0.2.0 plan
435
- was to drive one by typing into it; two probes say otherwise on this host: 242 `KEYEVENTF_UNICODE`
436
- events with the terminal in the foreground and Enter sent produced nothing, and a scan-code arm
437
- (262 events, layout-correct) produced nothing either. Their text surface also exposes no writable
438
- child and no `Document` element. The code stays, the reason names what does work (a target with a
439
- real door), and the claim is withdrawn rather than shipped as a promise.
440
-
441
- ## Install
442
-
443
- ```bash
444
- dsh plugin --profile <profile> add dsh-windows-parallel-mcp
445
- ```
446
-
447
- Requires Windows with Windows PowerShell 5.1 (it ships with Windows) — **no Python, no uv, no MSVC
448
- runtime, no native module**. The engine is a PowerShell sidecar started lazily on the first tool
449
- call, not at plugin load.
450
-
451
- `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
452
- degradation.
453
-
454
- Since 0.8.0 the same package is also an MCP server, and nothing about the install above changes — the
455
- two forms are parallel entries, not a migration:
456
-
457
- ```bash
458
- # stdio, configured by the environment of whoever starts it
459
- WPM_POLICY=balanced npx dsh-windows-parallel-mcp # via bin: wpm-mcp
460
- # or, from a checkout
461
- node lib/mcp-server.mjs
462
- ```
463
-
464
- Point any MCP client at that command; `server.json` (shipped in the tarball) is the MCP Registry
465
- manifest for it, with the namespace `io.github.drscrewdriver/dsh-windows-parallel-mcp` and the npm
466
- package as its ownership proof. A DSH profile can bridge it instead of loading the plugin directly
467
- (`@deepseek-ai/dsh-mcp-client`, stdio transport), which registers the tool as `mcp__<serverName>__wpm`;
468
- `test/mcp-bridge.mjs` drives that bridge with the host's own client SDK and tool-definition code.
469
-
470
- **The manifest is validated, not guessed.** `server.json` is checked against the Registry's own JSON
471
- Schema (2025-12-11) and `test/schema-test.mjs` keeps the limits in the gate: `description` at most 100
472
- characters, `title` at most 100, a reverse-DNS `name`, one concrete version rather than a range,
473
- `_meta` under 4 KB, and every environment variable declared that the server actually reads. The reason
474
- those lines exist is that 0.8.0 shipped an 800-character `description` and the validator refused it: a
475
- manifest a registry rejects is a form nobody can install from a listing, and 0.8.1 is that correction.
476
-
477
- ## Typed surface
478
-
479
- `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
480
- contract: the eleven actions, every argument including the takeover fields, the image-space / label
481
- surface, 0.6.0's `caretPosition` and 0.7.0's `target`/`op`/`format`/`forceUserActive`, all seventeen
482
- refusal codes as a closed union, and `effect` as its own four-value union (`WpmEffect`) beside
483
- `WpmCaptureBackend`, `WpmClipboardOp`, `WpmWindowOp`, `WpmPolicy` and `WpmFrameSource`.
484
-
485
- Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
486
- presence of a file:
487
-
488
- - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
489
- load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
490
- is the only entry point and the legacy field below is never consulted;
491
- - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
492
- consumer still type-checks.
493
-
494
- Neither field is decoration, so neither is removable on the assumption that the other covers it.
495
-
496
- The declarations are also checked against the implementation, in the direction that catches drift:
497
- `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
498
- renaming a field in one without the other fails a repo gate instead of a user's build. This stays
499
- inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
500
- when one is present, and the gate reports a named SKIP rather than a red when one is not.
501
-
502
- ## Settings
503
-
504
- | key | default | effect |
505
- |---|---|---|
506
- | `enabled` | `true` | server-side gate: when off, every action refuses with `paused` before the engine is reached |
507
- | `settleMs` | `350` | how long the app gets to commit state before the effect is judged |
508
- | `requestTimeoutMs` | `20000` | a worker that stops answering is killed and restarted on the next call |
509
- | `powershellPath` | `""` | override the interpreter (pwsh accepted) |
510
- | `logWorkerStderr` | `false` | forward worker diagnostics to the host log |
511
- | `takeoverAllowed` | `false` | allow `takeover:true`: cursor may move (always restored), focus held, HUD mandatory |
512
- | `keyInjectAllowed` | `false` | allow `keyInput:"inject"` inside the takeover tier (keyboard only, foreground asserted) |
513
- | `takeoverMaxMs` | `10000` | hard ceiling for one takeover action (500–60000); the HUD shows the clock |
514
- | `takeoverArmMs` | `800` | length of the arming phase: the window in which you can cancel before anything moves |
515
- | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
516
- | `screenshotMaxWidth` | `0` | downscale captures to this width; `0` means no scaling and `scale=1` — a resized image is a different coordinate system, so it is never chosen silently |
517
- | `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
518
- | `policy` | `balanced` | the ceiling over all eleven actions: `readonly` < `quiet` < `balanced` < `full`. Above it a call is refused with `policy_denied`, whose next step is to raise THIS setting and not to retry. An unrecognizable value falls back to `balanced`, never to `full` |
519
- | `policyIdleMs` | `3000` | how recently a physical input counts as "the owner is here". A takeover-tier call then refuses with `user_active` and opens no dialog; `0` disables the check |
520
- | `appLaunchAllowed` | `false` | allow `action=launch` at all. Independent of `takeoverAllowed`: being allowed to move a pointer is not being allowed to start a program |
521
- | `appLaunchAllow` | `[]` | the launch whitelist — exact names or absolute paths, matched case-insensitively and in full. Empty means nothing may launch even with the gate on; no wildcard, no prefix |
522
- | `auditKeep` | `2000` | how many lines `%LOCALAPPDATA%\wpm\audit.log` holds before the oldest are pruned |
523
-
524
- ## What measurement established
525
-
526
- The hard gate was run on a real Windows desktop before any of this shipped, and part of the original
527
- goal statement did not survive it. Kept here rather than quietly dropped:
528
-
529
- - **Cursor: true.** Every channel tested produced 0 px of cursor displacement across 24 action
530
- rounds, against a control arm that made no call.
531
- - **"Keyboard focus never changes": false as a general property.** UIA pattern actions raised their
532
- own target in 12/12 and 6/6 rounds with no mouse button down, no modifier key down and the cursor
533
- outside the target rect; a no-call control arm raised 0/6 in the same conditions.
534
- - **Window messages: true but narrow.** 6/6 effective, 0/6 raising. But a message needs an
535
- *address*: only 17 of 57 live windows here have one, and the two largest families (UWP/WinUI,
536
- Chromium/Electron) have none.
537
- - **The complementary-exclusive catch:** on the toolkit where messages work (WinForms/classic),
538
- UIA exposes no patterns at all; on the toolkits where UIA works (WPF/UWP/Chromium), there is no
539
- message door. The identifiable door and the quiet door are never on the same window.
540
- - **Restoration is measured, not assumed.** After a raise, the widget that held focus came back
541
- 6/6 and 6/6 in two independent runs, and internal focus (not just the window) returned 4/4.
542
- - **The engine is often quieter than the budget suggests.** Under its real operating condition,
543
- UIA `Invoke` was foreground-neutral in 0 of 12 rounds — the earlier 6/6 and 12/12 were measured
544
- under a construction that first took the foreground away. The flash tier is a fuse, not a promise
545
- of disturbance.
546
- - **An empty accessibility tree is a switch, not a delay.** The alternative reading — Chromium
547
- activates renderer accessibility on demand, so the tree might be merely slow — was tested, not
548
- assumed away: the same window was re-read in place three times (+0/+700/+1500 ms,
549
- `scripts/uia-tree-content.ps1`). uTools read **0/0/0** descendants, zero interactive content
550
- elements every time (one earlier peek the same day saw a single `Chrome Legacy Window` shell
551
- pane appear, content still 0); DSH on the same desktop read a real tree on the **first** query
552
- (514 at census time, 1019 raw / 85 content on re-read). Nothing ever trickled in. So the
553
- engine refuses with `uia_tree_empty` and does **not** poll — there is nothing to wait for — and
554
- the actual switch is a launch-time state (`--force-renderer-accessibility`) the engine cannot
555
- impose on a browser the user already has open. `unreachable` is the other world: the tree is
556
- alive and offers nothing at the named point or element.
557
-
558
- `elevated_target` is measured live: the engine compares the target's integrity RID against its own
559
- and refuses before acting (verified on an elevated Task Manager; 19 medium windows, zero
560
- misrefusals). The **restore-failure path on an elevated target** (`restore_failed`) remains
561
- unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.md).
562
-
563
- ### 0.2.0's four new measurements (all re-runnable from `scripts/`)
564
-
565
- - **The cursor can be placed exactly and put back** — `scripts/probe-setcursor-pos.ps1`:
566
- `SetCursorPos(+40,+20)` read back as exactly the requested point and the restore landed on the
567
- original point. The elevated-foreground arm could not be arranged (a non-elevated process cannot
568
- raise Task Manager), so it is recorded as unmeasured rather than guessed — the decision table
569
- refuses elevated targets before this primitive anyway.
570
- - **Injected characters go to the FOREGROUND window, not to the window you meant** —
571
- `scripts/probe-sendinput-unicode.ps1`: with window B in front, the text landed in B and window A
572
- received nothing; the reverse arm (A in front, including Chinese characters) landed in A. That is
573
- the measurement S1 rests on.
574
- - **The terminal cannot be typed into from here** — `scripts/probe-console-inject.ps1` and
575
- `scripts/probe-console-scan.ps1`: Unicode and scan-code arms both accepted by `SendInput`, both
576
- with the terminal in the foreground, neither executed. This is why the terminal claim is withdrawn.
577
- - **A WPF window can be click-through on empty space while its button stays clickable** —
578
- `scripts/probe-hittest-children.ps1`: the naive `HwndSource` hook received `WM_NCHITTEST` but its
579
- return value did not reach hit-testing (empty point still answered `HTCLIENT`); a `WNDPROC`
580
- subclass returning `HTTRANSPARENT` outside the button rect works — measured `-1` on empty space,
581
- `WindowFromPoint` no longer returning the HUD, and `HTCLIENT` on the button. That is what
582
- `hud.ps1` ships.
583
-
584
- ### 0.6.0's measurements (all re-runnable, probe scripts under `.tmp/` in the repository)
585
-
586
- - **The read-back exists and is truthful** — three window classes (`Edit`,
587
- `WindowsForms10.EDIT.app.*`, `WindowsForms10.RichEdit20W.app.*`) all return the written value through
588
- `WM_GETTEXT` cross-process, and in four cases the value equals what the *application* reported about
589
- itself from inside its own process (168–241 ms to observe, on the app's 400 ms timer).
590
- - **A password field reports a length but no text** — `ES_PASSWORD`: `WM_GETTEXT` returns the empty
591
- string while `WM_GETTEXTLENGTH` returns the real length. Hence `readback=unavailable`, never "empty".
592
- - **`EM_SETSEL(-1,-1)` does not mean "the end" on WinForms EDIT** — the selection stayed `0,0` and the
593
- typed character went to the front; `EM_SETSEL(len,len)` gave `abcY`. On a buffer holding `CRLF` the
594
- numeric end landed at `4,4` for a reported length of `6` — measured, therefore reported as
595
- `asked=`/`applied=` rather than papered over. A plain Win32 `EDIT` that never held focus accepts every
596
- `WM_CHAR` and changes nothing, even with `ES_NOHIDESEL`: the case the old `reported-by-send` was
597
- laundering, and the reason this batch exists.
598
- - **A read-only edit refuses `WM_CHAR` and honours `WM_SETTEXT`** — the falsification arm of
599
- `test/readback-truth.mjs`, chosen over two candidates that measurement eliminated (a bare `LF` is
600
- preserved verbatim, so it agrees; WinForms enforces `MaxLength` in its own `WM_CHAR` handler, so a
601
- programmatic `WM_SETTEXT` bypasses it, as does `EM_SETLIMITTEXT` set from outside).
602
- - **BitBlt halves the capture and leaves the bottleneck where it is** — 16–21 ms against 22–33 ms for a
603
- 1920×1080 grab, PNG encode 37–39 ms in both paths, capture+encode 12–16 ms on a 642×432 window. JPEG
604
- (6 ms) and WIC (158 ms) measured and rejected, 24bpp measured at 7 % of the size and rejected.
605
- - **`replace:true` threw on every target until 0.6.0** — the `WM_SETTEXT` binding was declared as
606
- `SendMessageStrW`, an export `user32.dll` does not have: the call raised
607
- `EntryPointNotFoundException` on first use and surfaced as `action_failed`. No test in the repository
608
- exercised `replace:true` through the message door, which is why the fix ships with an arm that does
609
- (`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
610
-
611
- ### 0.7.0's measurements
612
-
613
- - **A cold `Process.Start` has no window for over a second** — notepad: pid present,
614
- `MainWindowHandle=0`, **1348 ms**, and the window only reachable by polling the pid. Hence
615
- `waitMs`/`window-not-yet` rather than an hwnd claim at return time.
616
- - **The STA clipboard works in the worker and is not instant** — text write+read identical, first call
617
- **138 ms**; `SetDataObject`/`GetDataObject` for images (40×20 verified). `Clipboard.Flush()` does NOT
618
- exist on Windows PowerShell 5.1's runtime (.NET Framework): the first version of this branch threw
619
- "Clipboard does not contain a method named 'Flush'", which is a method present in the documentation
620
- people read and absent from the platform the product targets. `SetDataObject($v, $true)` is the
621
- supported way to make the data outlive the process.
622
- - **`SW_RESTORE` activates.** Measured around a restore on a real notepad window:
623
- `foregroundBefore=<other> foregroundAfter=<target>`. Reported as `foregroundTaken=true` on that call
624
- instead of being attributed to something else; `move`/`resize`/`topmost` measured
625
- `foregroundTaken=false` with `SWP_NOACTIVATE`.
626
- - **The whitelist is only a whitelist if it is exact.** `notepad` against `notepad-helper.exe`: a
627
- prefix or substring rule authorises the second one, so membership is a case-folded full-string test
628
- and `test/plugin-test.mjs` asserts the refusal for an unlisted name while the gate is on.
629
- - **The refusal vocabulary is unchanged in shape by `requiresTier`** — a rung comparison is arithmetic
630
- over one ordered list, so the cost of an action's classification is one number, not one new code per
631
- action. Three codes were added for the whole batch (`app_launch_denied`, `policy_denied`,
632
- `user_active`), each naming a setting rather than a symptom.
633
- - `Check-no-cursor-control` is still green with the same two whitelisted primitive uses and an
634
- unchanged whitelist file list: adding `launch`/`window` did not open a door to `MOUSEEVENTF_*`,
635
- `mouse_event` or `keybd_event`.
636
-
637
- ### 0.8.0's measurements
638
-
639
- - **A hand-written JSON-RPC loop over stdio is enough** (the 0.8.0 prerequisite probe): `initialize`,
640
- `tools/list` and `tools/call` all answer, an unknown method returns `-32601` and the process survives
641
- it, a notification produces no reply line, two requests in flight are matchable by id, a non-JSON line
642
- does not kill the transport, and closing stdin exits 0. Fifteen assertions, zero dependencies —
643
- `@modelcontextprotocol/sdk` is not needed and is not used.
644
- - **The host's SDK is the stricter judge than our own harness.** `test/mcp-bridge.mjs` connects
645
- `@modelcontextprotocol/client` 2.2.0 (the version the DSH install ships) to our server and validates
646
- the shapes we emit. Its negotiation throws when the server answers with a protocol revision the
647
- client does not list, which is why `PROTOCOL_VERSIONS` in `lib/mcp-server.mjs` is checked against that
648
- SDK's constants (latest `2025-11-25`) rather than guessed from a document.
649
- - **A picture the host cannot display still delivers its numbers.** Across the bridge with no attachment
650
- store mounted, a `screenshot` call does not throw: the bridge projects the image block into an
651
- `[image unavailable: …]` text diagnostic and the `screenRect` / `scale` / `identity` / `frame` /
652
- `captureBackend` line arrives regardless. Attaching pixels by default is safe because of that
653
- measurement, not in spite of it.
654
- - **`tools/list` follows the contract file, in both directions.** Renaming `caretPosition` in
655
- `src/schema/tools.json` changes what the running server reports, and flipping one
656
- `additionalProperties` changes it too — both are gate arms (`scripts/check-mcp-schema.mjs --self-test`),
657
- so the claim "generated, not copied" is exercised rather than asserted in prose.
658
- - **The install artifact is what was tested.** The 0.7.0 release was smoked from the unpacked tarball
659
- (`npm pack` → unpack → drive the policy ceiling, both launch gates, the clipboard length-not-payload
660
- rule and the audit rows: 17 assertions) and that run found two things the working tree could not show:
661
- the `clipboard` headline does not name which op ran, and the launch gate is only observable once the
662
- ceiling lets the call reach it. Both are recorded rather than papered over.
663
-
664
- ## Verifying the copy you actually installed
665
-
666
- Every test above imports the repository checkout, so a package that installs to the wrong place or ships
667
- a stale `lib/` would still pass all of them. `node test/smoke-installed.mjs <path-to-installed-package>`
668
- drives the **installed** copy: it lists a real window, runs a takeover click, asserts
669
- `takeover=on cursorRestored=true abortChord=…`, and checks that the HUD is torn down afterwards. Run once
670
- against the desktop profile after installing, as the last step of a release.
671
-
672
- The stdio form has the same discipline: unpack the tarball and start `lib/mcp-server.mjs` from the
673
- unpacked directory (not from the checkout). `scripts/check-mcp-schema.mjs` and `test/mcp-bridge.mjs` both
674
- spawn the server by path, so pointing them at the unpacked copy is the whole procedure. The 0.7.0 tag
675
- was pushed after that run; a release that skips it is asserting that the shipped bytes work by
676
- showing that the source does.
677
-
678
- ## License
679
-
680
- MIT
1
+ # dsh-windows-parallel-mcp
2
+
3
+ **English** · [中文](README.zh.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Italiano](README.it.md) · [Español](README.es.md) · [Português](README.pt.md) · [Русский](README.ru.md)
4
+ > **Current release: 0.9.0-rc.2** — this document describes the contract as of that version. What
5
+ > changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
6
+
7
+ A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
8
+ on request. Where a window accepts a window message, you never lose focus at all. Where it only
9
+ exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
10
+ explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
11
+ HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason — never with
12
+ silence: every refusal carries a code from a closed set of seventeen and the next step.
13
+
14
+ **It ships in two forms over one engine, and 0.8.0 did not replace the first one.** Inside DSH it is a
15
+ plugin (`apply()` on the host half, PowerShell sidecar underneath). Outside it, the same package is an
16
+ MCP server over stdio (`bin: wpm-mcp`), whose tool list is generated from the same contract file — see
17
+ "The second form" below.
18
+
19
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
20
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
21
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
22
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
23
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
24
+
25
+ Source, the measurement scripts behind every number below, and the release history live at
26
+ **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
27
+ "this target refused and I think it should not have".
28
+
29
+ Not affiliated with `dsh-windows-mcp`. Different plugin, different trade-off: that one is a carrier
30
+ bundle with a broad tool surface; this one is a single action tool whose entire design is about
31
+ *not* disturbing the desktop.
32
+
33
+ ## What it does
34
+
35
+ One tool, eleven actions:
36
+
37
+ | action | what it returns |
38
+ |---|---|
39
+ | `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
40
+ | `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
41
+ | `click` | click at a screen coordinate inside the named window, or at a snapshot `label` |
42
+ | `type` | write text into the target (a classic edit child, a named UIA element, or a `label`) |
43
+ | `focus` | move keyboard focus to a named control inside the target, or to a `label` |
44
+ | `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
45
+ | `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
46
+ | `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
47
+ | `launch` | start a whitelisted program; reports the pid, and the window only once it really exists |
48
+ | `clipboard` | read or write the system clipboard — a read reports lengths and never the payload |
49
+ | `window` | minimize / restore / move / resize / topmost ONE named window, verified by reading its state back |
50
+
51
+ The engine picks the cheapest available door per call:
52
+
53
+ - **quiet tier** — a classic child window receives the click/text as a window message. Measured:
54
+ 0 foreground changes in 6 of 6 rounds, cursor moved 0 px. (Those 6 rounds also read the target
55
+ app's own state to confirm the click landed — that was a *separate* experiment, not the `effect=`
56
+ field, which says only who reported the call returned; see the table below.)
57
+ - **bounded-flash tier** — only UI Automation can reach the control, which raises the target. The
58
+ engine records the focus table *before* acting, reverses it **once** afterwards, and never pulls
59
+ focus from a window you chose. Measured net return **15–95 ms** from three independent
60
+ measurements (the 120 ms budget was never approached).
61
+
62
+ ## What you see while it works
63
+
64
+ After a successful `click` a small marker is placed at the point that was clicked. It is a
65
+ click-through, always-on-top window with `WS_EX_TOPMOST | WS_EX_NOACTIVATE | WS_EX_TRANSPARENT`:
66
+ measured that `Show()` does not change `GetForegroundWindow`, that `WindowFromPoint` at the marker's
67
+ centre returns the window *underneath*, and that a real click through the shipped plugin puts the
68
+ marker over the point it hit (physical pixels; the process declares DPI awareness, because using
69
+ WPF's device-independent units put the marker at half scale on a 150% display). It hides itself
70
+ 1.5 s after the last placement. Cost: ~19 ms per placement, fired after the action has already
71
+ answered; the first action pays a one-time ~875 ms while the overlay starts.
72
+
73
+ **The pause key is not a fixed key.** `Ctrl+Alt+Q` is the first candidate, but it can already be
74
+ owned by another app — on the machine this was measured on it was (Win32 1409), and seven of the
75
+ other eight measured candidates were free. The engine walks a candidate list, registers the first
76
+ free chord, and **reports what it actually registered** in `status` as `pauseHotkey=...`. It never
77
+ silently claims the documented key works. `overlay=true` in settings controls the marker; the pause
78
+ flag itself is engine-side and refuses actions with `paused`.
79
+
80
+ Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
81
+ `uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `takeover_unavailable`,
82
+ `keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`, `stale_ref`. Each
83
+ carries a reason and a next step — see [docs/refusals.md](docs/refusals.md).
84
+
85
+ ## Reading the frame instead of guessing
86
+
87
+ The three read actions exist so the two halves of a click — *where the thing is* and *where the
88
+ picture is* — stop being the caller's arithmetic.
89
+
90
+ `label` is not a coordinate in disguise. It is resolved back to the UIA **element** by its runtime id
91
+ (measured stable across queries, 71 of 71), so `click`/`type`/`focus` with `label` + `snapId` still
92
+ take the silent pattern path. A labelled `click` keeps `x`/`y` required, and the point must fall
93
+ inside the labelled element's rect — the point stays the contract. A label whose `snapId` was
94
+ superseded is refused with `stale_ref`: element numbers only mean something in the frame that printed
95
+ them.
96
+
97
+ Image coordinates are never multiplied by the caller:
98
+
99
+ ```jsonc
100
+ {"action":"screenshot","hwnd":"1310720"}
101
+ // -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm captureBackend=bitblt
102
+ {"action":"click","hwnd":"1310720","space":"image","shotId":"shot-…","x":350,"y":250}
103
+ // the ENGINE converts, then still asserts the point belongs to the target window
104
+ ```
105
+
106
+ The picture is not returned inline — a plugin cannot mint an inline image block without the host's
107
+ attachment service — so the PNG is written to `%LOCALAPPDATA%\wpm\shots\` (newest `shotsKeep` kept)
108
+ and read with the host's image reader. `preview` is the cheaper confirmation: it draws the marker at
109
+ the point and answers, as text, which element the OS says is there. Confirming a point therefore
110
+ never depends on looking at a picture, and a preview writes no input-queue entry, takes no focus and
111
+ produces no proof window.
112
+
113
+ ### The frame rule, and why 8px mattered
114
+
115
+ One rectangle decides everything: `DwmGetWindowAttribute(EXTENDED_FRAME_BOUNDS)`. Measured here,
116
+ `GetWindowRect` is **8px larger on every edge** — the invisible resize shadow — and the accessibility
117
+ tree mixes the two spaces: its root element reports the shadow-inclusive rect while its children
118
+ report the real one, so arithmetic that mixes them is 8px wrong and *looks right*. Labels and the
119
+ captured picture therefore come from the same function. When DWM is unavailable (RDP, Basic theme)
120
+ the fallback to `GetWindowRect` is **reported** as `frame=win32` rather than swallowed, and
121
+ `frameInset` prints the shadow width as data.
122
+
123
+ The plan for this release proposed a runtime invariant — "every element rect is inside `screenRect`" —
124
+ and measurement refuted it: real Chromium/Electron trees report virtualized content far outside the
125
+ viewport (overhangs of 3px, 18px, 287px and 2720px measured here). What replaced it: elements that do
126
+ not overlap the capture are **excluded and counted** (`outsideFrame=…`, because a number you cannot
127
+ point at would be a trap), the frame is cross-checked against the window rect the tree itself reports
128
+ (`frameCheck=pass|fail|unknown`), and a structural gate pins the single-source rule by mutating a copy
129
+ of the engine and requiring the corresponding red.
130
+
131
+ ### Which capture path painted the picture
132
+
133
+ `captureBackend` names the producer: `bitblt` is a direct GDI `BitBlt` off the screen DC, `gdiplus` is
134
+ `Graphics.CopyFromScreen` — either the fallback after BitBlt was refused, or nothing else. The cheap
135
+ path replaced the old one on measured grounds (16–21 ms against 22–33 ms for a 1920×1080 grab), and the
136
+ encoder was deliberately left alone: the PNG encode is the bottleneck (37–39 ms), so JPEG (6 ms, and it
137
+ smears text), WIC (158 ms) and 24bpp (7 % smaller) were each measured and each rejected.
138
+
139
+ Equivalence was established on a **static** scene, not by file hash — two captures of a live desktop
140
+ happen at different instants, so their bytes cannot match, and that difference says nothing about the
141
+ paths: identical size, both non-blank, **0 maximum per-channel difference over 17 388 sampled points**,
142
+ byte-identical PNGs (8940 = 8940), with the comparator's self-check (two reads of one HBITMAP) also at
143
+ 0. The one difference is reported rather than assumed away: `FromHbitmap` yields `Format32bppRgb` where
144
+ `CopyFromScreen` yields `Format32bppArgb`. A gate keeps both halves honest — the fallback reachable and
145
+ `captureBackend` produced, forwarded and printed (`scripts/check-shot-backend.mjs`, seven mutations each
146
+ seen red).
147
+
148
+ ### Deciding outside the main context
149
+
150
+ The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
151
+ clean deciding side and take back one number:
152
+
153
+ 1. `snapshot` with `intent:"close the settings dialog"` — the intent travels with the frame, and is
154
+ written to `%LOCALAPPDATA%\wpm\last-snapshot.json`;
155
+ 2. give the numbered table and the intent to a clean subagent;
156
+ 3. it answers with a single `label` — not a selector, not a coordinate;
157
+ 4. click with that `label` + `snapId`.
158
+
159
+ `sinceSnapId` serves the same goal: an unchanged tree answers `no changes since <id>` instead of
160
+ repeating itself, and a delta names only what actually moved (`added` / `removed` / `changed`, keyed
161
+ by runtime id).
162
+
163
+ **Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
164
+ verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
165
+ samples cursor position, foreground window, keyboard focus and last-physical-input age — in a short
166
+ pre-action control window (when, by construction, nothing was running) and inside the settle wait it
167
+ already pays. The judgment is one pure function (`lib/proof-window.mjs`, unit-tested against 40
168
+ synthetic windows whose answers are known by construction). What it honestly can and cannot say:
169
+ a switch of foreground on a quiet tier fails — the control shows the desktop was not doing it, so it
170
+ is the action's to explain; a cursor jump is *reported*, never accused, because with nothing running
171
+ this desktop's cursor showed multi-gap unexplained motion on its own (a re-runnable probe ships:
172
+ `scripts/idle-baseline.mjs`). The cursor promise therefore lives where blame is decidable: a build
173
+ gate confines `SetCursorPos` to `takeover.ps1` and `SendInput` to `input-inject.ps1`, bans
174
+ `MOUSEEVENTF_*`/`mouse_event`/`keybd_event` everywhere, and a second gate asserts the structural
175
+ promises around them (the HUD is checked before any primitive runs; the cursor move and its restore
176
+ share one `try/finally`). A regression fails at build time with certainty instead of being hunted at
177
+ runtime among ambient motion. In the takeover tier the cursor motion is **declared**, so it is
178
+ reported rather than accused — but `cursorRestored=false` (borrowed and not returned) is a hard
179
+ `proof=fail`.
180
+
181
+ **And it says who reported the success.** Every action result carries `effect=` in the text and
182
+ `effect` in the structured output. The four values are not degrees of confidence in the
183
+ application — they name the speaker:
184
+
185
+ | `effect` | who is speaking | it proves | it does **not** prove |
186
+ |---|---|---|---|
187
+ | `unverified` | nobody | nothing | anything |
188
+ | `reported-by-send` | the window-message channel | the message was **delivered** | that the target app processed it |
189
+ | `reported-by-pattern` | the UI Automation pattern call | the call **returned** without throwing | that the interface actually changed |
190
+ | `readback-verified` | the control itself, read back | the value now in the field **equals the value predicted from the field's own measurements** | that the app is *happy* — only that its value is what we said |
191
+
192
+ Since 0.1.3 the effect also enters the judgment, which closes the one honest gap 0.1.2 still had:
193
+ a still desktop could outvote a total no-op. A call whose channel reported nothing is capped at
194
+ `inconclusive` — never `pass`. A batch caller that passes its per-attempt results (`actions`) gets
195
+ `fail` when **no** attempt took effect, however few pixels moved. Displacement proves we did not
196
+ disturb you; it never proves we accomplished anything. A single `reported-by-*` stays a `pass` with
197
+ the caveat spelled out in the reason field (`未独立验证` — nobody observed the app), because turning
198
+ weak-but-real evidence into a red would train its readers to ignore the verdict.
199
+
200
+ ### The fourth value has to be earned (0.6.0)
201
+
202
+ `readback-verified` is granted only by the engine, and only when a **prediction** matches a **read**.
203
+ The prediction is computed from measurements the control itself reported — the value it held before,
204
+ its own `WM_GETTEXTLENGTH`, its own `EM_GETSEL` answer for where a typed character lands — and the read
205
+ happens *after* the settle window, so an app that commits its text asynchronously is not judged against
206
+ a half-written buffer:
207
+
208
+ ```jsonc
209
+ {"action":"type","hwnd":"…","text":"XY","caretPosition":"start"}
210
+ // -> type ok channel=message tier=quiet effect=readback-verified
211
+ // detail=msg=char|2 child=… caret=start asked=0 applied=0,0 readback=XYabc readbackLen=5 focusMoved=false
212
+ ```
213
+
214
+ Three things it refuses to do, each measured rather than assumed:
215
+
216
+ * **it does not upgrade what it cannot read.** A masked field (`ES_PASSWORD`) returns an empty string
217
+ while `WM_GETTEXTLENGTH` still reports the real length. That is "the control hides its text", not
218
+ "the field is empty": the result says `readback=unavailable`, the effect keeps whatever the write
219
+ earned, and no value is printed anywhere.
220
+ * **a mismatch is data, not a failure.** A read-only WinForms edit silently refuses `WM_CHAR` — every
221
+ character is accepted by the API and the value never moves — while honouring `WM_SETTEXT`. On the
222
+ refusal the result is still `ok:true` with `readbackMismatch=true` and no upgrade; on the write that
223
+ lands it is `readback-verified`. No refusal code changed for this batch, on purpose: "the application
224
+ formatted my input" is not an error in the call. `test/readback-truth.mjs` asserts both arms against
225
+ the value the *application* wrote about itself, from inside its own process — a readback test that
226
+ compared our write to our read would be grading homework in our own class, and this repo has already
227
+ been caught doing exactly that.
228
+ * **the naive guess is not the model.** Text is not appended: it lands at the caret, and a field that
229
+ never held focus has its caret at 0 (so `abc` + `XY` is `XYabc`). That is why `caretPosition` exists
230
+ and why the result prints `asked=` and `applied=` separately — `EM_SETSEL(-1,-1)` is documented as
231
+ "document end" and measured as a no-op on WinForms EDIT, so `end` is `EM_SETSEL(len,len)` with `len`
232
+ read from the control. On a buffer containing newlines that numeric end can land inside the text
233
+ (`asked=6 applied=4,4`), which is reported instead of hidden; `idle` touches nothing at all. The UIA
234
+ `value` channel replaces the whole value and has no caret to move, so it answers
235
+ `caretIgnored=value-pattern` rather than pretending to honour it.
236
+
237
+ Two more facts ride in the same `detail`, both warnings and neither a refusal: `focusMoved=true` when
238
+ the foreground or the focused control differs between the two measurements taken around the send, and
239
+ `disabled=true` for a target window that is greyed out — Windows keeps answering our messages while
240
+ throwing the input away, so a disabled target loses the right to an `effect` claim
241
+ (`effect=unverified`) without becoming an error.
242
+
243
+ ## The takeover tier (opt-in)
244
+
245
+ Off by default (`takeoverAllowed=false`, `keyInjectAllowed=false`), because moving someone's pointer
246
+ is not something an upgrade should switch on. When you turn it on and pass `takeover:true`:
247
+
248
+ 1. **arming** — **amber** HUD (`#3A2C0C` surface, `#F0AD18` accent bar). Says what is about to be
249
+ borrowed (cursor / keyboard / focus), with the interrupt key that actually registered. Default
250
+ 800 ms; this is the cancellation window.
251
+ 2. **active** — **red** HUD (`#3A1212` / `#E84040`). The cursor is placed on the action point, the
252
+ action runs through the cheapest existing door, and the HUD counts elapsed/limit and characters
253
+ injected.
254
+ 3. **done** — **green** HUD (`#0E2E1E` / `#34C77B`). The cursor is restored (read-back verified), the
255
+ focus is returned through the same one-shot table, and the HUD says so.
256
+
257
+ The colour is not decoration: while an agent borrows the pointer the owner is looking at the *target*
258
+ window, so the phase is encoded twice — the whole surface tint **and** a 5px accent bar — and
259
+ `test/hud-test.ps1` reads the real pixels to assert the three are distinct (C18). Amber = not yet
260
+ (cancellable), red = holding something of yours right now, green = returned.
261
+
262
+ **The keys, which are easy to mix up:**
263
+
264
+ | | key |
265
+ |---|---|
266
+ | interrupt the running takeover | **`Ctrl+Alt+X`** (the one that registered; candidates `X→Z→C→V→B→N` then `Ctrl+Shift+X`, displayed as `abortChord=`) |
267
+ | same thing, no keyboard | the HUD's 取消 / 停止 button (same flag, no priority) |
268
+ | pause the whole engine (also aborts a running takeover) | **`Ctrl+Alt+Q`**, here **`Ctrl+Alt+W`** because another app owns Q; `status` reports `pauseHotkey=` |
269
+
270
+ The abort chord lives only while the HUD exists (its window owns the registration); the pause key is a
271
+ permanent server-side switch. Three interruption paths, all writing the same flag/file: HUD button,
272
+ abort chord, and the host's cancellation (`exec.signal` → a latch file the engine polls, because the
273
+ worker is single-threaded and cannot read a request while an action is running). Interruption returns
274
+ `takeover_aborted` **with** `cursorRestored` and `injectedChars` — it is not a fault, it is the feature.
275
+
276
+ Keyboard injection (`keyInput:"inject"`) exists only inside this tier, because `SendInput` writes to
277
+ the **foreground** window: measured, text sent while another window was in front landed in that
278
+ window and not in the intended one. The engine therefore asserts `GetForegroundWindow() == target`
279
+ before sending, re-asserts at send time, and refuses with `keyinject_unavailable` otherwise. It never
280
+ injects mouse events — `MOUSEEVENTF_*` is banned repo-wide, so the module is structurally unable to
281
+ click. Success is reported as `effect=reported-by-send`, never as "verified". Unicode injection
282
+ carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
283
+ not a bug.
284
+
285
+ ## Desktop actions: launch, clipboard, window (0.7.0)
286
+
287
+ Three capabilities that were missing outright — "you cannot even start a program" was the honest answer
288
+ — and none of them is a door action. They choose no channel, cost no tier, and produce no proof window,
289
+ so they live beside `Invoke-WpmAction` rather than inside it, and the door discipline (point ownership,
290
+ the restore table, the proof window) is not widened by any of them.
291
+
292
+ **`launch` — two switches, neither of which implies the other.** `appLaunchAllowed` opens the
293
+ capability; `appLaunchAllow` lists the exact program names or absolute paths that may run, and an
294
+ **empty list means nothing may launch even with the gate on**. Matching is exact and case-folded: there
295
+ is no wildcard, and `notepad` does not authorise `notepad-helper.exe` — a whitelist that grows by prefix
296
+ is a whitelist that authorises more than it says. A refusal is `app_launch_denied` and is raised before
297
+ any worker request, so a refused launch started nothing (asserted with a request counter in
298
+ `test/plugin-test.mjs` and re-checked inside the engine against the same table). The engine's own
299
+ vocabulary for the window is the interesting part: `Process.Start` returns while the app is still
300
+ loading (measured: `MainWindowHandle=0` for 1348 ms on a cold notepad), so a program that has not
301
+ published a window yet answers `ok:true` with `hwnd=""` and `detail=window-not-yet` — neither a fake
302
+ failure nor a fake readiness. Arguments are passed through as given and written to the audit log,
303
+ because listing a program does not vouch for what it is told to do.
304
+
305
+ **`clipboard` — the most private read in this product.** What is on the clipboard may be a password or
306
+ a token the owner copied seconds ago, so a text read reports its **length**, its result text never
307
+ contains the payload, the audit line records `op`/`format`/`chars`, and values are capped at 64 KB with
308
+ `truncated` stated rather than silently cut. An image write accepts a `shotId`, so a screenshot can go
309
+ straight into the clipboard without the caller handling pixels; the read-back compares the size the
310
+ clipboard reports against the size the shot recorded. A clipboard holding neither is refused with the
311
+ format names it did find — an empty success would be indistinguishable from "the clipboard is empty".
312
+
313
+ **`window` — one named window, five ops, each verified by reading the window back.** `IsIconic`,
314
+ `GetWindowRect`, the `WS_EX_TOPMOST` bit — not `ShowWindow`'s return value, because a syscall's answer
315
+ describes the CALL and this product has been burned repeatedly by reporting that as a state. `move` and
316
+ `resize` pass `SWP_NOACTIVATE`, and the result carries `foregroundTaken=true|false` measured on both
317
+ sides of that specific call: `restore` activates by definition (that is what restoring is), and the
318
+ honest answer is to report it, not to hide it or to refuse the op the caller asked for. There is no
319
+ "all windows" op and no `#32770` discovery: acting on a window nobody named is not a convenience.
320
+
321
+ ### One ceiling, eleven actions
322
+
323
+ The old shape of this problem was a boolean per capability, which does not scale past the number of
324
+ settings anyone will actually read. Instead the two axes are independent:
325
+
326
+ ```
327
+ the action declares the lowest rung it can ever need (src/schema/tools.json#requiresTier)
328
+ the owner sets one ceiling (settings: policy)
329
+
330
+ readonly < quiet < flash < takeover
331
+ reads message bounded-UIA real cursor / held focus / launch
332
+ door flash
333
+ ```
334
+
335
+ | `policy` | permits | refuses |
336
+ |---|---|---|
337
+ | `readonly` | `windows`, `status`, `snapshot`, `screenshot`, `preview`, `clipboard` read | every write |
338
+ | `quiet` | + `click` / `type` / `focus` through the message door | the flash tier, `clipboard` write, `window`, `launch` |
339
+ | `balanced` *(default)* | + the bounded-flash tier, `clipboard` write, `window` ops | `takeover:true`, `keyInput:"inject"`, `launch` |
340
+ | `full` | + the takeover tier and `launch` | nothing extra |
341
+
342
+ Above the ceiling a call is refused with **`policy_denied`** and the reason names both numbers (what the
343
+ action needed, what the policy allows), because the correct next step is a settings change and the wrong
344
+ one is a retry. The gate order is `paused → policy → takeoverAllowed/keyInjectAllowed → launch gate +
345
+ whitelist → idle check → the door table`, and every step in it is tested by making two gates disagree
346
+ about which one spoke (`test/plugin-test.mjs`). Two consequences are worth stating plainly rather than
347
+ leaving to discovery: **`takeover:true` now needs `policy:'full'` as well as `takeoverAllowed`** (0.7.0
348
+ raised the bar for the loudest tier on purpose), and `clipboard`'s halves are graded separately
349
+ (`requiresTierFor`), so a `readonly` owner can still read.
350
+
351
+ **Idle instead of a dialog.** When the last *physical* input is younger than `policyIdleMs` (default
352
+ 3000 ms) and the action needs the takeover tier, it is refused with **`user_active`** and nothing is
353
+ clicked — no popup, no countdown. The upstream design asks the owner to consent by interrupting them;
354
+ an interrupt presented as consent is just a second disturbance. The escape hatch is explicit
355
+ (`forceUserActive:true`), it does not bypass any other gate, and the audit line records `forced:true` so
356
+ an interruption caused on purpose stays distinguishable from one caused by accident. An unattended run
357
+ is never blocked by this: with nobody typing, the age grows past the window and the call goes through.
358
+
359
+ ### The audit log
360
+
361
+ Every action appends one JSONL line to `%LOCALAPPDATA%\wpm\audit.log` — allow **and** deny, because a
362
+ trail that records only refusals documents the times the guard worked and is silent about the times it
363
+ had nothing to do with. Fields: `ts, action, hwnd, tier, policy, decision, code, userActiveAgeMs,
364
+ effect, latencyMs`, plus `target`/`args` for a launch and `op`/`format`/`chars` for a clipboard call.
365
+ What is deliberately absent is content: no typed text, no clipboard payload — the second copy of a
366
+ secret is the one nobody protects. `auditKeep` (default 2000) bounds the file, pruning oldest-first when
367
+ a write pushes it past budget. An audit that cannot be written is reported (`auditNote=n write(s)
368
+ failed`) rather than swallowed: a log that looks complete and is not is worse than one that admits it
369
+ is missing lines. This is the only artifact that survives a call, and it is the one thing that can
370
+ answer "what did the agent do to this machine" after the fact.
371
+
372
+ ## The second form: MCP over stdio (0.8.0)
373
+
374
+ The same plugin is also an MCP server, and it is the same code rather than a re-implementation of it.
375
+ `lib/mcp-server.mjs` registers the tool by calling the very `apply()` the DSH host calls, and forwards
376
+ `tools/call` into the same `toRequest()` / gate order / `format()` path, so the eleven actions, the
377
+ seventeen refusal codes, the policy ceiling and the audit line are identical in both forms. That is why
378
+ the engine files were not touched to add it: a second implementation of a permission is a permission
379
+ that can be reached around by using the other copy.
380
+
381
+ **One tool, not eleven.** `tools/list` exposes `wpm` with an `action` discriminator, generated from
382
+ `src/schema/tools.json` — one `oneOf` branch per action, whose `properties`, `required` and
383
+ `additionalProperties` are that action's declaration copied field for field. Nothing in the server
384
+ spells out an action name, a parameter name or a code, and `scripts/check-mcp-schema.mjs` is the reason
385
+ that stays true: it starts the real server, reads what a client would read, and compares it to the file.
386
+ Its self-test mutates both sides on purpose — four edits to the generator must turn the gate red, and two
387
+ edits to the *contract* (rename a parameter, flip `additionalProperties`) must stay green AND move,
388
+ because an arm that only breaks the generator cannot tell a generated schema from a transcribed one that
389
+ happens to agree today.
390
+
391
+ **Settings come from the environment, never from the call.** `WPM_POLICY`, `WPM_TAKEOVER_ALLOWED`,
392
+ `WPM_APP_LAUNCH_ALLOWED`, `WPM_APP_LAUNCH_ALLOW` and the rest of the `WPM_*` set are read at start-up
393
+ and only if present — the defaults stay in `lib/index.js`, because a second copy of a default is a
394
+ default that drifts. A client that could raise its own ceiling or add itself to the launch whitelist
395
+ would make the authorization model decorative, which is the same reason the DSH form reads settings
396
+ from the profile rather than from the prompt.
397
+
398
+ **A picture is attached as pixels, because a path is not portable.** The DSH form renders the screenshot
399
+ file it wrote; a caller on the other end of a pipe cannot open it, so `tools/call` returns the PNG as
400
+ base64 `image` content alongside the text. The text is never replaced by it — `screenRect`, `scale`,
401
+ `identity`, `frame` and `captureBackend` stay in the first block, and across the DSH bridge, where a
402
+ host that cannot accept image input projects the picture into a text diagnostic, those numbers still
403
+ arrive. `WPM_MCP_NO_IMAGE=1` opts out.
404
+
405
+ **Refusals survive the trip.** A refused call comes back with `isError` and the code as the first token
406
+ of the text, unsoftened. Over the DSH bridge the refusal is re-raised as an error whose message is that
407
+ text, so `policy_denied` still reads as `policy_denied` at the far end — asserted, not assumed, in
408
+ `test/mcp-bridge.mjs`, which drives the SDK and the bridge code the host actually ships.
409
+
410
+ **The transport is the only new attack surface, and it is a pipe.** JSON-RPC 2.0 over stdin/stdout with
411
+ Node built-ins and zero dependencies: one JSON object per line, replies keyed by `id` because the worker
412
+ is asynchronous, notifications answered with nothing, a non-JSON line answered with `-32700` and a null
413
+ `id` without killing the loop, an unknown method answered `-32601` without killing the loop, and stdin
414
+ closing meaning "dispose the sidecar and exit 0". Everything that is not a protocol line goes to stderr
415
+ — `console.log` in the plugin half would otherwise print into the JSON stream and corrupt it.
416
+
417
+ ## What it does not do
418
+
419
+ - **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
420
+ shipped file. The takeover tier moves the cursor instead of clicking synthetically — that is why
421
+ "the agent can type into the foreground" does not become "the agent can click anything".
422
+ - **No takeover without the HUD.** `takeover_unavailable` is a refusal, not a warning, and the
423
+ request is never downgraded silently into the quiet tier.
424
+ - **No forged-Alt foreground trick.** That route works and other plugins use it, but it injects a
425
+ real key event — a keystroke you make in that window can land in whichever window the trick just
426
+ raised.
427
+ - **No OCR / Set-of-Marks / pixel fallback.** Not part of this claim, and already done well elsewhere.
428
+ - **No watchdog.** The restore is one-shot and happens inline. A watchdog that keeps chasing the
429
+ foreground would fight you.
430
+ - **No HTTP, no SSE, no OAuth, no TLS.** Two forms exist and neither has a network face: in-process for
431
+ DSH, stdio for MCP. "No network surface" is not a hardening claim, it is the absence of one — there is
432
+ nothing to authenticate against, nothing to listen on, and nothing that keeps running when the caller
433
+ goes away.
434
+ - **Terminals are still refused** (`terminal_no_door`), and now for a measured reason. The 0.2.0 plan
435
+ was to drive one by typing into it; two probes say otherwise on this host: 242 `KEYEVENTF_UNICODE`
436
+ events with the terminal in the foreground and Enter sent produced nothing, and a scan-code arm
437
+ (262 events, layout-correct) produced nothing either. Their text surface also exposes no writable
438
+ child and no `Document` element. The code stays, the reason names what does work (a target with a
439
+ real door), and the claim is withdrawn rather than shipped as a promise.
440
+
441
+ ## Install
442
+
443
+ ```bash
444
+ dsh plugin --profile <profile> add dsh-windows-parallel-mcp
445
+ ```
446
+
447
+ Requires Windows with Windows PowerShell 5.1 (it ships with Windows) — **no Python, no uv, no MSVC
448
+ runtime, no native module**. The engine is a PowerShell sidecar started lazily on the first tool
449
+ call, not at plugin load.
450
+
451
+ `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
452
+ degradation.
453
+
454
+ Since 0.8.0 the same package is also an MCP server, and nothing about the install above changes — the
455
+ two forms are parallel entries, not a migration:
456
+
457
+ ```bash
458
+ # stdio, configured by the environment of whoever starts it
459
+ WPM_POLICY=balanced npx dsh-windows-parallel-mcp # via bin: wpm-mcp
460
+ # or, from a checkout
461
+ node lib/mcp-server.mjs
462
+ ```
463
+
464
+ Point any MCP client at that command; `server.json` (shipped in the tarball) is the MCP Registry
465
+ manifest for it, with the namespace `io.github.drscrewdriver/dsh-windows-parallel-mcp` and the npm
466
+ package as its ownership proof. A DSH profile can bridge it instead of loading the plugin directly
467
+ (`@deepseek-ai/dsh-mcp-client`, stdio transport), which registers the tool as `mcp__<serverName>__wpm`;
468
+ `test/mcp-bridge.mjs` drives that bridge with the host's own client SDK and tool-definition code.
469
+
470
+ **The manifest is validated, not guessed.** `server.json` is checked against the Registry's own JSON
471
+ Schema (2025-12-11) and `test/schema-test.mjs` keeps the limits in the gate: `description` at most 100
472
+ characters, `title` at most 100, a reverse-DNS `name`, one concrete version rather than a range,
473
+ `_meta` under 4 KB, and every environment variable declared that the server actually reads. The reason
474
+ those lines exist is that 0.8.0 shipped an 800-character `description` and the validator refused it: a
475
+ manifest a registry rejects is a form nobody can install from a listing, and 0.8.1 is that correction.
476
+
477
+ ## Typed surface
478
+
479
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
480
+ contract: the eleven actions, every argument including the takeover fields, the image-space / label
481
+ surface, 0.6.0's `caretPosition` and 0.7.0's `target`/`op`/`format`/`forceUserActive`, all seventeen
482
+ refusal codes as a closed union, and `effect` as its own four-value union (`WpmEffect`) beside
483
+ `WpmCaptureBackend`, `WpmClipboardOp`, `WpmWindowOp`, `WpmPolicy` and `WpmFrameSource`.
484
+
485
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
486
+ presence of a file:
487
+
488
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
489
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
490
+ is the only entry point and the legacy field below is never consulted;
491
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
492
+ consumer still type-checks.
493
+
494
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
495
+
496
+ The declarations are also checked against the implementation, in the direction that catches drift:
497
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
498
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
499
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
500
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
501
+
502
+ ## Settings
503
+
504
+ | key | default | effect |
505
+ |---|---|---|
506
+ | `enabled` | `true` | server-side gate: when off, every action refuses with `paused` before the engine is reached |
507
+ | `settleMs` | `350` | how long the app gets to commit state before the effect is judged |
508
+ | `requestTimeoutMs` | `20000` | a worker that stops answering is killed and restarted on the next call |
509
+ | `powershellPath` | `""` | override the interpreter (pwsh accepted) |
510
+ | `logWorkerStderr` | `false` | forward worker diagnostics to the host log |
511
+ | `takeoverAllowed` | `false` | allow `takeover:true`: cursor may move (always restored), focus held, HUD mandatory |
512
+ | `keyInjectAllowed` | `false` | allow `keyInput:"inject"` inside the takeover tier (keyboard only, foreground asserted) |
513
+ | `takeoverMaxMs` | `10000` | hard ceiling for one takeover action (500–60000); the HUD shows the clock |
514
+ | `takeoverArmMs` | `800` | length of the arming phase: the window in which you can cancel before anything moves |
515
+ | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
516
+ | `screenshotMaxWidth` | `0` | downscale captures to this width; `0` means no scaling and `scale=1` — a resized image is a different coordinate system, so it is never chosen silently |
517
+ | `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
518
+ | `policy` | `balanced` | the ceiling over all eleven actions: `readonly` < `quiet` < `balanced` < `full`. Above it a call is refused with `policy_denied`, whose next step is to raise THIS setting and not to retry. An unrecognizable value falls back to `balanced`, never to `full` |
519
+ | `policyIdleMs` | `3000` | how recently a physical input counts as "the owner is here". A takeover-tier call then refuses with `user_active` and opens no dialog; `0` disables the check |
520
+ | `appLaunchAllowed` | `false` | allow `action=launch` at all. Independent of `takeoverAllowed`: being allowed to move a pointer is not being allowed to start a program |
521
+ | `appLaunchAllow` | `[]` | the launch whitelist — exact names or absolute paths, matched case-insensitively and in full. Empty means nothing may launch even with the gate on; no wildcard, no prefix |
522
+ | `auditKeep` | `2000` | how many lines `%LOCALAPPDATA%\wpm\audit.log` holds before the oldest are pruned |
523
+
524
+ ## What measurement established
525
+
526
+ The hard gate was run on a real Windows desktop before any of this shipped, and part of the original
527
+ goal statement did not survive it. Kept here rather than quietly dropped:
528
+
529
+ - **Cursor: true.** Every channel tested produced 0 px of cursor displacement across 24 action
530
+ rounds, against a control arm that made no call.
531
+ - **"Keyboard focus never changes": false as a general property.** UIA pattern actions raised their
532
+ own target in 12/12 and 6/6 rounds with no mouse button down, no modifier key down and the cursor
533
+ outside the target rect; a no-call control arm raised 0/6 in the same conditions.
534
+ - **Window messages: true but narrow.** 6/6 effective, 0/6 raising. But a message needs an
535
+ *address*: only 17 of 57 live windows here have one, and the two largest families (UWP/WinUI,
536
+ Chromium/Electron) have none.
537
+ - **The complementary-exclusive catch:** on the toolkit where messages work (WinForms/classic),
538
+ UIA exposes no patterns at all; on the toolkits where UIA works (WPF/UWP/Chromium), there is no
539
+ message door. The identifiable door and the quiet door are never on the same window.
540
+ - **Restoration is measured, not assumed.** After a raise, the widget that held focus came back
541
+ 6/6 and 6/6 in two independent runs, and internal focus (not just the window) returned 4/4.
542
+ - **The engine is often quieter than the budget suggests.** Under its real operating condition,
543
+ UIA `Invoke` was foreground-neutral in 0 of 12 rounds — the earlier 6/6 and 12/12 were measured
544
+ under a construction that first took the foreground away. The flash tier is a fuse, not a promise
545
+ of disturbance.
546
+ - **An empty accessibility tree is a switch, not a delay.** The alternative reading — Chromium
547
+ activates renderer accessibility on demand, so the tree might be merely slow — was tested, not
548
+ assumed away: the same window was re-read in place three times (+0/+700/+1500 ms,
549
+ `scripts/uia-tree-content.ps1`). uTools read **0/0/0** descendants, zero interactive content
550
+ elements every time (one earlier peek the same day saw a single `Chrome Legacy Window` shell
551
+ pane appear, content still 0); DSH on the same desktop read a real tree on the **first** query
552
+ (514 at census time, 1019 raw / 85 content on re-read). Nothing ever trickled in. So the
553
+ engine refuses with `uia_tree_empty` and does **not** poll — there is nothing to wait for — and
554
+ the actual switch is a launch-time state (`--force-renderer-accessibility`) the engine cannot
555
+ impose on a browser the user already has open. `unreachable` is the other world: the tree is
556
+ alive and offers nothing at the named point or element.
557
+
558
+ `elevated_target` is measured live: the engine compares the target's integrity RID against its own
559
+ and refuses before acting (verified on an elevated Task Manager; 19 medium windows, zero
560
+ misrefusals). The **restore-failure path on an elevated target** (`restore_failed`) remains
561
+ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.md).
562
+
563
+ ### 0.2.0's four new measurements (all re-runnable from `scripts/`)
564
+
565
+ - **The cursor can be placed exactly and put back** — `scripts/probe-setcursor-pos.ps1`:
566
+ `SetCursorPos(+40,+20)` read back as exactly the requested point and the restore landed on the
567
+ original point. The elevated-foreground arm could not be arranged (a non-elevated process cannot
568
+ raise Task Manager), so it is recorded as unmeasured rather than guessed — the decision table
569
+ refuses elevated targets before this primitive anyway.
570
+ - **Injected characters go to the FOREGROUND window, not to the window you meant** —
571
+ `scripts/probe-sendinput-unicode.ps1`: with window B in front, the text landed in B and window A
572
+ received nothing; the reverse arm (A in front, including Chinese characters) landed in A. That is
573
+ the measurement S1 rests on.
574
+ - **The terminal cannot be typed into from here** — `scripts/probe-console-inject.ps1` and
575
+ `scripts/probe-console-scan.ps1`: Unicode and scan-code arms both accepted by `SendInput`, both
576
+ with the terminal in the foreground, neither executed. This is why the terminal claim is withdrawn.
577
+ - **A WPF window can be click-through on empty space while its button stays clickable** —
578
+ `scripts/probe-hittest-children.ps1`: the naive `HwndSource` hook received `WM_NCHITTEST` but its
579
+ return value did not reach hit-testing (empty point still answered `HTCLIENT`); a `WNDPROC`
580
+ subclass returning `HTTRANSPARENT` outside the button rect works — measured `-1` on empty space,
581
+ `WindowFromPoint` no longer returning the HUD, and `HTCLIENT` on the button. That is what
582
+ `hud.ps1` ships.
583
+
584
+ ### 0.6.0's measurements (all re-runnable, probe scripts under `.tmp/` in the repository)
585
+
586
+ - **The read-back exists and is truthful** — three window classes (`Edit`,
587
+ `WindowsForms10.EDIT.app.*`, `WindowsForms10.RichEdit20W.app.*`) all return the written value through
588
+ `WM_GETTEXT` cross-process, and in four cases the value equals what the *application* reported about
589
+ itself from inside its own process (168–241 ms to observe, on the app's 400 ms timer).
590
+ - **A password field reports a length but no text** — `ES_PASSWORD`: `WM_GETTEXT` returns the empty
591
+ string while `WM_GETTEXTLENGTH` returns the real length. Hence `readback=unavailable`, never "empty".
592
+ - **`EM_SETSEL(-1,-1)` does not mean "the end" on WinForms EDIT** — the selection stayed `0,0` and the
593
+ typed character went to the front; `EM_SETSEL(len,len)` gave `abcY`. On a buffer holding `CRLF` the
594
+ numeric end landed at `4,4` for a reported length of `6` — measured, therefore reported as
595
+ `asked=`/`applied=` rather than papered over. A plain Win32 `EDIT` that never held focus accepts every
596
+ `WM_CHAR` and changes nothing, even with `ES_NOHIDESEL`: the case the old `reported-by-send` was
597
+ laundering, and the reason this batch exists.
598
+ - **A read-only edit refuses `WM_CHAR` and honours `WM_SETTEXT`** — the falsification arm of
599
+ `test/readback-truth.mjs`, chosen over two candidates that measurement eliminated (a bare `LF` is
600
+ preserved verbatim, so it agrees; WinForms enforces `MaxLength` in its own `WM_CHAR` handler, so a
601
+ programmatic `WM_SETTEXT` bypasses it, as does `EM_SETLIMITTEXT` set from outside).
602
+ - **BitBlt halves the capture and leaves the bottleneck where it is** — 16–21 ms against 22–33 ms for a
603
+ 1920×1080 grab, PNG encode 37–39 ms in both paths, capture+encode 12–16 ms on a 642×432 window. JPEG
604
+ (6 ms) and WIC (158 ms) measured and rejected, 24bpp measured at 7 % of the size and rejected.
605
+ - **`replace:true` threw on every target until 0.6.0** — the `WM_SETTEXT` binding was declared as
606
+ `SendMessageStrW`, an export `user32.dll` does not have: the call raised
607
+ `EntryPointNotFoundException` on first use and surfaced as `action_failed`. No test in the repository
608
+ exercised `replace:true` through the message door, which is why the fix ships with an arm that does
609
+ (`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
610
+
611
+ ### 0.7.0's measurements
612
+
613
+ - **A cold `Process.Start` has no window for over a second** — notepad: pid present,
614
+ `MainWindowHandle=0`, **1348 ms**, and the window only reachable by polling the pid. Hence
615
+ `waitMs`/`window-not-yet` rather than an hwnd claim at return time.
616
+ - **The STA clipboard works in the worker and is not instant** — text write+read identical, first call
617
+ **138 ms**; `SetDataObject`/`GetDataObject` for images (40×20 verified). `Clipboard.Flush()` does NOT
618
+ exist on Windows PowerShell 5.1's runtime (.NET Framework): the first version of this branch threw
619
+ "Clipboard does not contain a method named 'Flush'", which is a method present in the documentation
620
+ people read and absent from the platform the product targets. `SetDataObject($v, $true)` is the
621
+ supported way to make the data outlive the process.
622
+ - **`SW_RESTORE` activates.** Measured around a restore on a real notepad window:
623
+ `foregroundBefore=<other> foregroundAfter=<target>`. Reported as `foregroundTaken=true` on that call
624
+ instead of being attributed to something else; `move`/`resize`/`topmost` measured
625
+ `foregroundTaken=false` with `SWP_NOACTIVATE`.
626
+ - **The whitelist is only a whitelist if it is exact.** `notepad` against `notepad-helper.exe`: a
627
+ prefix or substring rule authorises the second one, so membership is a case-folded full-string test
628
+ and `test/plugin-test.mjs` asserts the refusal for an unlisted name while the gate is on.
629
+ - **The refusal vocabulary is unchanged in shape by `requiresTier`** — a rung comparison is arithmetic
630
+ over one ordered list, so the cost of an action's classification is one number, not one new code per
631
+ action. Three codes were added for the whole batch (`app_launch_denied`, `policy_denied`,
632
+ `user_active`), each naming a setting rather than a symptom.
633
+ - `Check-no-cursor-control` is still green with the same two whitelisted primitive uses and an
634
+ unchanged whitelist file list: adding `launch`/`window` did not open a door to `MOUSEEVENTF_*`,
635
+ `mouse_event` or `keybd_event`.
636
+
637
+ ### 0.8.0's measurements
638
+
639
+ - **A hand-written JSON-RPC loop over stdio is enough** (the 0.8.0 prerequisite probe): `initialize`,
640
+ `tools/list` and `tools/call` all answer, an unknown method returns `-32601` and the process survives
641
+ it, a notification produces no reply line, two requests in flight are matchable by id, a non-JSON line
642
+ does not kill the transport, and closing stdin exits 0. Fifteen assertions, zero dependencies —
643
+ `@modelcontextprotocol/sdk` is not needed and is not used.
644
+ - **The host's SDK is the stricter judge than our own harness.** `test/mcp-bridge.mjs` connects
645
+ `@modelcontextprotocol/client` 2.2.0 (the version the DSH install ships) to our server and validates
646
+ the shapes we emit. Its negotiation throws when the server answers with a protocol revision the
647
+ client does not list, which is why `PROTOCOL_VERSIONS` in `lib/mcp-server.mjs` is checked against that
648
+ SDK's constants (latest `2025-11-25`) rather than guessed from a document.
649
+ - **A picture the host cannot display still delivers its numbers.** Across the bridge with no attachment
650
+ store mounted, a `screenshot` call does not throw: the bridge projects the image block into an
651
+ `[image unavailable: …]` text diagnostic and the `screenRect` / `scale` / `identity` / `frame` /
652
+ `captureBackend` line arrives regardless. Attaching pixels by default is safe because of that
653
+ measurement, not in spite of it.
654
+ - **`tools/list` follows the contract file, in both directions.** Renaming `caretPosition` in
655
+ `src/schema/tools.json` changes what the running server reports, and flipping one
656
+ `additionalProperties` changes it too — both are gate arms (`scripts/check-mcp-schema.mjs --self-test`),
657
+ so the claim "generated, not copied" is exercised rather than asserted in prose.
658
+ - **The install artifact is what was tested.** The 0.7.0 release was smoked from the unpacked tarball
659
+ (`npm pack` → unpack → drive the policy ceiling, both launch gates, the clipboard length-not-payload
660
+ rule and the audit rows: 17 assertions) and that run found two things the working tree could not show:
661
+ the `clipboard` headline does not name which op ran, and the launch gate is only observable once the
662
+ ceiling lets the call reach it. Both are recorded rather than papered over.
663
+
664
+ ## Verifying the copy you actually installed
665
+
666
+ Every test above imports the repository checkout, so a package that installs to the wrong place or ships
667
+ a stale `lib/` would still pass all of them. `node test/smoke-installed.mjs <path-to-installed-package>`
668
+ drives the **installed** copy: it lists a real window, runs a takeover click, asserts
669
+ `takeover=on cursorRestored=true abortChord=…`, and checks that the HUD is torn down afterwards. Run once
670
+ against the desktop profile after installing, as the last step of a release.
671
+
672
+ The stdio form has the same discipline: unpack the tarball and start `lib/mcp-server.mjs` from the
673
+ unpacked directory (not from the checkout). `scripts/check-mcp-schema.mjs` and `test/mcp-bridge.mjs` both
674
+ spawn the server by path, so pointing them at the unpacked copy is the whole procedure. The 0.7.0 tag
675
+ was pushed after that run; a release that skips it is asserting that the shipped bytes work by
676
+ showing that the source does.
677
+
678
+ ## License
679
+
680
+ MIT