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