dsh-windows-parallel-mcp 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.es.md CHANGED
@@ -5,23 +5,21 @@
5
5
  > Un plugin DSH que permite a un agente controlar **sus propias** ventanas de Windows — silencioso por defecto, visible cuando se pide. Cuando una ventana acepta mensajes de Windows, el foco nunca se pierde. Cuando solo UI Automation puede alcanzarla, el foco sufre un único destello acotado que se revierte automáticamente. Cuando pides explícitamente el modo takeover, el cursor se mueve al punto de acción y siempre se restaura, con un HUD que ofrece tres formas de interrumpir. En cualquier otro caso, rechaza con un código y una razón.
6
6
 
7
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
- > **0.2.0 — the promise changes shape, deliberately.** Through 0.1.x this plugin's claim was "no
9
- > physical input at all". 0.2.0 keeps that as the **default** and adds an **opt-in takeover tier**:
10
- > with `takeoverAllowed` on and `takeover:true` on the call, the real cursor is moved to the action
11
- > point (so you can see where the agent points) and always restored, the focus is held for the
12
- > duration, and a three-phase HUD with a stop button and a global abort key is mandatory. Keyboard
13
- > injection exists only inside that tier, only when asked (`keyInput:"inject"`), and only for
14
- > targets with no other door — and, measured, it does **not** work on this host's terminal, so the
15
- > terminal stays refused rather than becoming a promise. Both gates default off: an upgrade cannot
16
- > start moving your cursor by itself. 0.1.6 split `unreachable` into `uia_tree_empty` and
17
- > `uia_probe_failed`; 0.1.5 made a click act on the point it names; 0.1.3 added `effect=` — who
18
- > reported the success — and let it enter the judgment. Full history: [CHANGELOG.md](CHANGELOG.md).
8
+ > **Current release: 0.5.0** — 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.
19
10
 
20
11
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
21
12
  on request. Where a window accepts a window message, you never lose focus at all. Where it only
22
13
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
23
14
  explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
24
- HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason.
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 fourteen and the next step.
17
+
18
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
20
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
21
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
22
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
25
23
 
26
24
  Source, the measurement scripts behind every number below, and the release history live at
27
25
  **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
@@ -33,15 +31,18 @@ bundle with a broad tool surface; this one is a single action tool whose entire
33
31
 
34
32
  ## What it does
35
33
 
36
- One tool, five actions:
34
+ One tool, eight actions:
37
35
 
38
36
  | action | what it returns |
39
37
  |---|---|
40
38
  | `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
41
39
  | `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
42
- | `click` | click at a screen coordinate inside the named window |
43
- | `type` | write text into the target (a classic edit child, or a named UIA element) |
44
- | `focus` | move keyboard focus to a named control inside the target |
40
+ | `click` | click at a screen coordinate inside the named window, or at a snapshot `label` |
41
+ | `type` | write text into the target (a classic edit child, a named UIA element, or a `label`) |
42
+ | `focus` | move keyboard focus to a named control inside the target, or to a `label` |
43
+ | `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
44
+ | `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
45
+ | `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
45
46
 
46
47
  The engine picks the cheapest available door per call:
47
48
 
@@ -74,8 +75,69 @@ flag itself is engine-side and refuses actions with `paused`.
74
75
 
75
76
  Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
76
77
  `uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `takeover_unavailable`,
77
- `keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`. Each carries a reason
78
- and a next step — see [docs/refusals.md](docs/refusals.md).
78
+ `keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`, `stale_ref`. Each
79
+ carries a reason and a next step — see [docs/refusals.md](docs/refusals.md).
80
+
81
+ ## Reading the frame instead of guessing
82
+
83
+ The three read actions exist so the two halves of a click — *where the thing is* and *where the
84
+ picture is* — stop being the caller's arithmetic.
85
+
86
+ `label` is not a coordinate in disguise. It is resolved back to the UIA **element** by its runtime id
87
+ (measured stable across queries, 71 of 71), so `click`/`type`/`focus` with `label` + `snapId` still
88
+ take the silent pattern path. A labelled `click` keeps `x`/`y` required, and the point must fall
89
+ inside the labelled element's rect — the point stays the contract. A label whose `snapId` was
90
+ superseded is refused with `stale_ref`: element numbers only mean something in the frame that printed
91
+ them.
92
+
93
+ Image coordinates are never multiplied by the caller:
94
+
95
+ ```jsonc
96
+ {"action":"screenshot","hwnd":"1310720"}
97
+ // -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm
98
+ {"action":"click","hwnd":"1310720","space":"image","shotId":"shot-…","x":350,"y":250}
99
+ // the ENGINE converts, then still asserts the point belongs to the target window
100
+ ```
101
+
102
+ The picture is not returned inline — a plugin cannot mint an inline image block without the host's
103
+ attachment service — so the PNG is written to `%LOCALAPPDATA%\wpm\shots\` (newest `shotsKeep` kept)
104
+ and read with the host's image reader. `preview` is the cheaper confirmation: it draws the marker at
105
+ the point and answers, as text, which element the OS says is there. Confirming a point therefore
106
+ never depends on looking at a picture, and a preview writes no input-queue entry, takes no focus and
107
+ produces no proof window.
108
+
109
+ ### The frame rule, and why 8px mattered
110
+
111
+ One rectangle decides everything: `DwmGetWindowAttribute(EXTENDED_FRAME_BOUNDS)`. Measured here,
112
+ `GetWindowRect` is **8px larger on every edge** — the invisible resize shadow — and the accessibility
113
+ tree mixes the two spaces: its root element reports the shadow-inclusive rect while its children
114
+ report the real one, so arithmetic that mixes them is 8px wrong and *looks right*. Labels and the
115
+ captured picture therefore come from the same function. When DWM is unavailable (RDP, Basic theme)
116
+ the fallback to `GetWindowRect` is **reported** as `frame=win32` rather than swallowed, and
117
+ `frameInset` prints the shadow width as data.
118
+
119
+ The plan for this release proposed a runtime invariant — "every element rect is inside `screenRect`" —
120
+ and measurement refuted it: real Chromium/Electron trees report virtualized content far outside the
121
+ viewport (overhangs of 3px, 18px, 287px and 2720px measured here). What replaced it: elements that do
122
+ not overlap the capture are **excluded and counted** (`outsideFrame=…`, because a number you cannot
123
+ point at would be a trap), the frame is cross-checked against the window rect the tree itself reports
124
+ (`frameCheck=pass|fail|unknown`), and a structural gate pins the single-source rule by mutating a copy
125
+ of the engine and requiring the corresponding red.
126
+
127
+ ### Deciding outside the main context
128
+
129
+ The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
130
+ clean deciding side and take back one number:
131
+
132
+ 1. `snapshot` with `intent:"close the settings dialog"` — the intent travels with the frame, and is
133
+ written to `%LOCALAPPDATA%\wpm\last-snapshot.json`;
134
+ 2. give the numbered table and the intent to a clean subagent;
135
+ 3. it answers with a single `label` — not a selector, not a coordinate;
136
+ 4. click with that `label` + `snapId`.
137
+
138
+ `sinceSnapId` serves the same goal: an unchanged tree answers `no changes since <id>` instead of
139
+ repeating itself, and a delta names only what actually moved (`added` / `removed` / `changed`, keyed
140
+ by runtime id).
79
141
 
80
142
  **Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
81
143
  verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
@@ -188,6 +250,29 @@ call, not at plugin load.
188
250
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
189
251
  degradation.
190
252
 
253
+ ## Typed surface
254
+
255
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
256
+ contract: the eight actions, every argument including the takeover fields and the image-space /
257
+ label surface, and all fourteen refusal codes as a closed union.
258
+
259
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
260
+ presence of a file:
261
+
262
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
263
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
264
+ is the only entry point and the legacy field below is never consulted;
265
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
266
+ consumer still type-checks.
267
+
268
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
269
+
270
+ The declarations are also checked against the implementation, in the direction that catches drift:
271
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
272
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
273
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
274
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
275
+
191
276
  ## Settings
192
277
 
193
278
  | key | default | effect |
@@ -201,6 +286,9 @@ degradation.
201
286
  | `keyInjectAllowed` | `false` | allow `keyInput:"inject"` inside the takeover tier (keyboard only, foreground asserted) |
202
287
  | `takeoverMaxMs` | `10000` | hard ceiling for one takeover action (500–60000); the HUD shows the clock |
203
288
  | `takeoverArmMs` | `800` | length of the arming phase: the window in which you can cancel before anything moves |
289
+ | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
290
+ | `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 |
291
+ | `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
204
292
 
205
293
  ## What measurement established
206
294
 
package/README.fr.md CHANGED
@@ -5,23 +5,21 @@
5
5
  > Un plugin DSH qui laisse un agent piloter **ses propres** fenêtres Windows — discrètement par défaut, visiblement sur demande. Quand une fenêtre accepte un message Windows, le focus n'est jamais volé. Quand seule l'UI Automation peut l'atteindre, le focus connaît un seul flash borné, automatiquement réversible. Quand vous demandez explicitement le mode takeover, le curseur se déplace vers le point d'action et est toujours restauré, avec un HUD offrant trois façons d'interrompre. Partout ailleurs, le plugin refuse avec un code et une raison.
6
6
 
7
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
- > **0.2.0 — the promise changes shape, deliberately.** Through 0.1.x this plugin's claim was "no
9
- > physical input at all". 0.2.0 keeps that as the **default** and adds an **opt-in takeover tier**:
10
- > with `takeoverAllowed` on and `takeover:true` on the call, the real cursor is moved to the action
11
- > point (so you can see where the agent points) and always restored, the focus is held for the
12
- > duration, and a three-phase HUD with a stop button and a global abort key is mandatory. Keyboard
13
- > injection exists only inside that tier, only when asked (`keyInput:"inject"`), and only for
14
- > targets with no other door — and, measured, it does **not** work on this host's terminal, so the
15
- > terminal stays refused rather than becoming a promise. Both gates default off: an upgrade cannot
16
- > start moving your cursor by itself. 0.1.6 split `unreachable` into `uia_tree_empty` and
17
- > `uia_probe_failed`; 0.1.5 made a click act on the point it names; 0.1.3 added `effect=` — who
18
- > reported the success — and let it enter the judgment. Full history: [CHANGELOG.md](CHANGELOG.md).
8
+ > **Current release: 0.5.0** — 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.
19
10
 
20
11
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
21
12
  on request. Where a window accepts a window message, you never lose focus at all. Where it only
22
13
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
23
14
  explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
24
- HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason.
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 fourteen and the next step.
17
+
18
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
20
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
21
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
22
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
25
23
 
26
24
  Source, the measurement scripts behind every number below, and the release history live at
27
25
  **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
@@ -33,15 +31,18 @@ bundle with a broad tool surface; this one is a single action tool whose entire
33
31
 
34
32
  ## What it does
35
33
 
36
- One tool, five actions:
34
+ One tool, eight actions:
37
35
 
38
36
  | action | what it returns |
39
37
  |---|---|
40
38
  | `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
41
39
  | `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
42
- | `click` | click at a screen coordinate inside the named window |
43
- | `type` | write text into the target (a classic edit child, or a named UIA element) |
44
- | `focus` | move keyboard focus to a named control inside the target |
40
+ | `click` | click at a screen coordinate inside the named window, or at a snapshot `label` |
41
+ | `type` | write text into the target (a classic edit child, a named UIA element, or a `label`) |
42
+ | `focus` | move keyboard focus to a named control inside the target, or to a `label` |
43
+ | `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
44
+ | `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
45
+ | `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
45
46
 
46
47
  The engine picks the cheapest available door per call:
47
48
 
@@ -74,8 +75,69 @@ flag itself is engine-side and refuses actions with `paused`.
74
75
 
75
76
  Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
76
77
  `uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `takeover_unavailable`,
77
- `keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`. Each carries a reason
78
- and a next step — see [docs/refusals.md](docs/refusals.md).
78
+ `keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`, `stale_ref`. Each
79
+ carries a reason and a next step — see [docs/refusals.md](docs/refusals.md).
80
+
81
+ ## Reading the frame instead of guessing
82
+
83
+ The three read actions exist so the two halves of a click — *where the thing is* and *where the
84
+ picture is* — stop being the caller's arithmetic.
85
+
86
+ `label` is not a coordinate in disguise. It is resolved back to the UIA **element** by its runtime id
87
+ (measured stable across queries, 71 of 71), so `click`/`type`/`focus` with `label` + `snapId` still
88
+ take the silent pattern path. A labelled `click` keeps `x`/`y` required, and the point must fall
89
+ inside the labelled element's rect — the point stays the contract. A label whose `snapId` was
90
+ superseded is refused with `stale_ref`: element numbers only mean something in the frame that printed
91
+ them.
92
+
93
+ Image coordinates are never multiplied by the caller:
94
+
95
+ ```jsonc
96
+ {"action":"screenshot","hwnd":"1310720"}
97
+ // -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm
98
+ {"action":"click","hwnd":"1310720","space":"image","shotId":"shot-…","x":350,"y":250}
99
+ // the ENGINE converts, then still asserts the point belongs to the target window
100
+ ```
101
+
102
+ The picture is not returned inline — a plugin cannot mint an inline image block without the host's
103
+ attachment service — so the PNG is written to `%LOCALAPPDATA%\wpm\shots\` (newest `shotsKeep` kept)
104
+ and read with the host's image reader. `preview` is the cheaper confirmation: it draws the marker at
105
+ the point and answers, as text, which element the OS says is there. Confirming a point therefore
106
+ never depends on looking at a picture, and a preview writes no input-queue entry, takes no focus and
107
+ produces no proof window.
108
+
109
+ ### The frame rule, and why 8px mattered
110
+
111
+ One rectangle decides everything: `DwmGetWindowAttribute(EXTENDED_FRAME_BOUNDS)`. Measured here,
112
+ `GetWindowRect` is **8px larger on every edge** — the invisible resize shadow — and the accessibility
113
+ tree mixes the two spaces: its root element reports the shadow-inclusive rect while its children
114
+ report the real one, so arithmetic that mixes them is 8px wrong and *looks right*. Labels and the
115
+ captured picture therefore come from the same function. When DWM is unavailable (RDP, Basic theme)
116
+ the fallback to `GetWindowRect` is **reported** as `frame=win32` rather than swallowed, and
117
+ `frameInset` prints the shadow width as data.
118
+
119
+ The plan for this release proposed a runtime invariant — "every element rect is inside `screenRect`" —
120
+ and measurement refuted it: real Chromium/Electron trees report virtualized content far outside the
121
+ viewport (overhangs of 3px, 18px, 287px and 2720px measured here). What replaced it: elements that do
122
+ not overlap the capture are **excluded and counted** (`outsideFrame=…`, because a number you cannot
123
+ point at would be a trap), the frame is cross-checked against the window rect the tree itself reports
124
+ (`frameCheck=pass|fail|unknown`), and a structural gate pins the single-source rule by mutating a copy
125
+ of the engine and requiring the corresponding red.
126
+
127
+ ### Deciding outside the main context
128
+
129
+ The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
130
+ clean deciding side and take back one number:
131
+
132
+ 1. `snapshot` with `intent:"close the settings dialog"` — the intent travels with the frame, and is
133
+ written to `%LOCALAPPDATA%\wpm\last-snapshot.json`;
134
+ 2. give the numbered table and the intent to a clean subagent;
135
+ 3. it answers with a single `label` — not a selector, not a coordinate;
136
+ 4. click with that `label` + `snapId`.
137
+
138
+ `sinceSnapId` serves the same goal: an unchanged tree answers `no changes since <id>` instead of
139
+ repeating itself, and a delta names only what actually moved (`added` / `removed` / `changed`, keyed
140
+ by runtime id).
79
141
 
80
142
  **Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
81
143
  verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
@@ -188,6 +250,29 @@ call, not at plugin load.
188
250
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
189
251
  degradation.
190
252
 
253
+ ## Typed surface
254
+
255
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
256
+ contract: the eight actions, every argument including the takeover fields and the image-space /
257
+ label surface, and all fourteen refusal codes as a closed union.
258
+
259
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
260
+ presence of a file:
261
+
262
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
263
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
264
+ is the only entry point and the legacy field below is never consulted;
265
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
266
+ consumer still type-checks.
267
+
268
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
269
+
270
+ The declarations are also checked against the implementation, in the direction that catches drift:
271
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
272
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
273
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
274
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
275
+
191
276
  ## Settings
192
277
 
193
278
  | key | default | effect |
@@ -201,6 +286,9 @@ degradation.
201
286
  | `keyInjectAllowed` | `false` | allow `keyInput:"inject"` inside the takeover tier (keyboard only, foreground asserted) |
202
287
  | `takeoverMaxMs` | `10000` | hard ceiling for one takeover action (500–60000); the HUD shows the clock |
203
288
  | `takeoverArmMs` | `800` | length of the arming phase: the window in which you can cancel before anything moves |
289
+ | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
290
+ | `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 |
291
+ | `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
204
292
 
205
293
  ## What measurement established
206
294
 
package/README.it.md CHANGED
@@ -5,23 +5,21 @@
5
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
6
 
7
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
- > **0.2.0 — the promise changes shape, deliberately.** Through 0.1.x this plugin's claim was "no
9
- > physical input at all". 0.2.0 keeps that as the **default** and adds an **opt-in takeover tier**:
10
- > with `takeoverAllowed` on and `takeover:true` on the call, the real cursor is moved to the action
11
- > point (so you can see where the agent points) and always restored, the focus is held for the
12
- > duration, and a three-phase HUD with a stop button and a global abort key is mandatory. Keyboard
13
- > injection exists only inside that tier, only when asked (`keyInput:"inject"`), and only for
14
- > targets with no other door — and, measured, it does **not** work on this host's terminal, so the
15
- > terminal stays refused rather than becoming a promise. Both gates default off: an upgrade cannot
16
- > start moving your cursor by itself. 0.1.6 split `unreachable` into `uia_tree_empty` and
17
- > `uia_probe_failed`; 0.1.5 made a click act on the point it names; 0.1.3 added `effect=` — who
18
- > reported the success — and let it enter the judgment. Full history: [CHANGELOG.md](CHANGELOG.md).
8
+ > **Current release: 0.5.0** — 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.
19
10
 
20
11
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
21
12
  on request. Where a window accepts a window message, you never lose focus at all. Where it only
22
13
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
23
14
  explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
24
- HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason.
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 fourteen and the next step.
17
+
18
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
20
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
21
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
22
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
25
23
 
26
24
  Source, the measurement scripts behind every number below, and the release history live at
27
25
  **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
@@ -33,15 +31,18 @@ bundle with a broad tool surface; this one is a single action tool whose entire
33
31
 
34
32
  ## What it does
35
33
 
36
- One tool, five actions:
34
+ One tool, eight actions:
37
35
 
38
36
  | action | what it returns |
39
37
  |---|---|
40
38
  | `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
41
39
  | `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
42
- | `click` | click at a screen coordinate inside the named window |
43
- | `type` | write text into the target (a classic edit child, or a named UIA element) |
44
- | `focus` | move keyboard focus to a named control inside the target |
40
+ | `click` | click at a screen coordinate inside the named window, or at a snapshot `label` |
41
+ | `type` | write text into the target (a classic edit child, a named UIA element, or a `label`) |
42
+ | `focus` | move keyboard focus to a named control inside the target, or to a `label` |
43
+ | `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
44
+ | `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
45
+ | `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
45
46
 
46
47
  The engine picks the cheapest available door per call:
47
48
 
@@ -74,8 +75,69 @@ flag itself is engine-side and refuses actions with `paused`.
74
75
 
75
76
  Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
76
77
  `uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `takeover_unavailable`,
77
- `keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`. Each carries a reason
78
- and a next step — see [docs/refusals.md](docs/refusals.md).
78
+ `keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`, `stale_ref`. Each
79
+ carries a reason and a next step — see [docs/refusals.md](docs/refusals.md).
80
+
81
+ ## Reading the frame instead of guessing
82
+
83
+ The three read actions exist so the two halves of a click — *where the thing is* and *where the
84
+ picture is* — stop being the caller's arithmetic.
85
+
86
+ `label` is not a coordinate in disguise. It is resolved back to the UIA **element** by its runtime id
87
+ (measured stable across queries, 71 of 71), so `click`/`type`/`focus` with `label` + `snapId` still
88
+ take the silent pattern path. A labelled `click` keeps `x`/`y` required, and the point must fall
89
+ inside the labelled element's rect — the point stays the contract. A label whose `snapId` was
90
+ superseded is refused with `stale_ref`: element numbers only mean something in the frame that printed
91
+ them.
92
+
93
+ Image coordinates are never multiplied by the caller:
94
+
95
+ ```jsonc
96
+ {"action":"screenshot","hwnd":"1310720"}
97
+ // -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm
98
+ {"action":"click","hwnd":"1310720","space":"image","shotId":"shot-…","x":350,"y":250}
99
+ // the ENGINE converts, then still asserts the point belongs to the target window
100
+ ```
101
+
102
+ The picture is not returned inline — a plugin cannot mint an inline image block without the host's
103
+ attachment service — so the PNG is written to `%LOCALAPPDATA%\wpm\shots\` (newest `shotsKeep` kept)
104
+ and read with the host's image reader. `preview` is the cheaper confirmation: it draws the marker at
105
+ the point and answers, as text, which element the OS says is there. Confirming a point therefore
106
+ never depends on looking at a picture, and a preview writes no input-queue entry, takes no focus and
107
+ produces no proof window.
108
+
109
+ ### The frame rule, and why 8px mattered
110
+
111
+ One rectangle decides everything: `DwmGetWindowAttribute(EXTENDED_FRAME_BOUNDS)`. Measured here,
112
+ `GetWindowRect` is **8px larger on every edge** — the invisible resize shadow — and the accessibility
113
+ tree mixes the two spaces: its root element reports the shadow-inclusive rect while its children
114
+ report the real one, so arithmetic that mixes them is 8px wrong and *looks right*. Labels and the
115
+ captured picture therefore come from the same function. When DWM is unavailable (RDP, Basic theme)
116
+ the fallback to `GetWindowRect` is **reported** as `frame=win32` rather than swallowed, and
117
+ `frameInset` prints the shadow width as data.
118
+
119
+ The plan for this release proposed a runtime invariant — "every element rect is inside `screenRect`" —
120
+ and measurement refuted it: real Chromium/Electron trees report virtualized content far outside the
121
+ viewport (overhangs of 3px, 18px, 287px and 2720px measured here). What replaced it: elements that do
122
+ not overlap the capture are **excluded and counted** (`outsideFrame=…`, because a number you cannot
123
+ point at would be a trap), the frame is cross-checked against the window rect the tree itself reports
124
+ (`frameCheck=pass|fail|unknown`), and a structural gate pins the single-source rule by mutating a copy
125
+ of the engine and requiring the corresponding red.
126
+
127
+ ### Deciding outside the main context
128
+
129
+ The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
130
+ clean deciding side and take back one number:
131
+
132
+ 1. `snapshot` with `intent:"close the settings dialog"` — the intent travels with the frame, and is
133
+ written to `%LOCALAPPDATA%\wpm\last-snapshot.json`;
134
+ 2. give the numbered table and the intent to a clean subagent;
135
+ 3. it answers with a single `label` — not a selector, not a coordinate;
136
+ 4. click with that `label` + `snapId`.
137
+
138
+ `sinceSnapId` serves the same goal: an unchanged tree answers `no changes since <id>` instead of
139
+ repeating itself, and a delta names only what actually moved (`added` / `removed` / `changed`, keyed
140
+ by runtime id).
79
141
 
80
142
  **Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
81
143
  verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
@@ -188,6 +250,29 @@ call, not at plugin load.
188
250
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
189
251
  degradation.
190
252
 
253
+ ## Typed surface
254
+
255
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
256
+ contract: the eight actions, every argument including the takeover fields and the image-space /
257
+ label surface, and all fourteen refusal codes as a closed union.
258
+
259
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
260
+ presence of a file:
261
+
262
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
263
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
264
+ is the only entry point and the legacy field below is never consulted;
265
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
266
+ consumer still type-checks.
267
+
268
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
269
+
270
+ The declarations are also checked against the implementation, in the direction that catches drift:
271
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
272
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
273
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
274
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
275
+
191
276
  ## Settings
192
277
 
193
278
  | key | default | effect |
@@ -201,6 +286,9 @@ degradation.
201
286
  | `keyInjectAllowed` | `false` | allow `keyInput:"inject"` inside the takeover tier (keyboard only, foreground asserted) |
202
287
  | `takeoverMaxMs` | `10000` | hard ceiling for one takeover action (500–60000); the HUD shows the clock |
203
288
  | `takeoverArmMs` | `800` | length of the arming phase: the window in which you can cancel before anything moves |
289
+ | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
290
+ | `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 |
291
+ | `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
204
292
 
205
293
  ## What measurement established
206
294