dsh-windows-parallel-mcp 0.4.1 → 0.6.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/CHANGELOG.de.md +12 -0
- package/CHANGELOG.es.md +12 -0
- package/CHANGELOG.fr.md +12 -0
- package/CHANGELOG.it.md +12 -0
- package/CHANGELOG.ja.md +12 -0
- package/CHANGELOG.ko.md +12 -0
- package/CHANGELOG.md +202 -0
- package/CHANGELOG.pt.md +12 -0
- package/CHANGELOG.ru.md +12 -0
- package/CHANGELOG.zh.md +12 -0
- package/README.de.md +167 -11
- package/README.es.md +167 -11
- package/README.fr.md +167 -11
- package/README.it.md +167 -11
- package/README.ja.md +167 -11
- package/README.ko.md +167 -11
- package/README.md +167 -11
- package/README.pt.md +167 -11
- package/README.ru.md +167 -11
- package/README.zh.md +167 -11
- package/docs/refusals.md +7 -4
- package/dsh.plugin.json +3 -3
- package/lib/config.js +14 -0
- package/lib/host-tools.js +76 -3
- package/lib/index.js +295 -18
- package/package.json +6 -3
- package/src/engine/engine.ps1 +375 -6
- package/src/engine/win.ps1 +814 -3
- package/src/engine/worker.ps1 +40 -1
- package/src/schema/tools.json +118 -10
- package/types/index.d.ts +91 -4
package/README.fr.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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
|
-
> **Current release: 0.
|
|
8
|
+
> **Current release: 0.6.0** — this document describes the contract as of that version. What
|
|
9
9
|
> changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
|
|
10
10
|
|
|
11
11
|
A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
|
|
@@ -13,7 +13,7 @@ on request. Where a window accepts a window message, you never lose focus at all
|
|
|
13
13
|
exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
|
|
14
14
|
explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
|
|
15
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
|
|
16
|
+
silence: every refusal carries a code from a closed set of fourteen and the next step.
|
|
17
17
|
|
|
18
18
|
**The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
|
|
19
19
|
opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
|
|
@@ -31,15 +31,18 @@ bundle with a broad tool surface; this one is a single action tool whose entire
|
|
|
31
31
|
|
|
32
32
|
## What it does
|
|
33
33
|
|
|
34
|
-
One tool,
|
|
34
|
+
One tool, eight actions:
|
|
35
35
|
|
|
36
36
|
| action | what it returns |
|
|
37
37
|
|---|---|
|
|
38
38
|
| `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
|
|
39
39
|
| `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
|
|
40
|
-
| `click` | click at a screen coordinate inside the named window |
|
|
41
|
-
| `type` | write text into the target (a classic edit child,
|
|
42
|
-
| `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 |
|
|
43
46
|
|
|
44
47
|
The engine picks the cheapest available door per call:
|
|
45
48
|
|
|
@@ -72,8 +75,86 @@ flag itself is engine-side and refuses actions with `paused`.
|
|
|
72
75
|
|
|
73
76
|
Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
|
|
74
77
|
`uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `takeover_unavailable`,
|
|
75
|
-
`keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`. Each
|
|
76
|
-
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 captureBackend=bitblt
|
|
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
|
+
### Which capture path painted the picture
|
|
128
|
+
|
|
129
|
+
`captureBackend` names the producer: `bitblt` is a direct GDI `BitBlt` off the screen DC, `gdiplus` is
|
|
130
|
+
`Graphics.CopyFromScreen` — either the fallback after BitBlt was refused, or nothing else. The cheap
|
|
131
|
+
path replaced the old one on measured grounds (16–21 ms against 22–33 ms for a 1920×1080 grab), and the
|
|
132
|
+
encoder was deliberately left alone: the PNG encode is the bottleneck (37–39 ms), so JPEG (6 ms, and it
|
|
133
|
+
smears text), WIC (158 ms) and 24bpp (7 % smaller) were each measured and each rejected.
|
|
134
|
+
|
|
135
|
+
Equivalence was established on a **static** scene, not by file hash — two captures of a live desktop
|
|
136
|
+
happen at different instants, so their bytes cannot match, and that difference says nothing about the
|
|
137
|
+
paths: identical size, both non-blank, **0 maximum per-channel difference over 17 388 sampled points**,
|
|
138
|
+
byte-identical PNGs (8940 = 8940), with the comparator's self-check (two reads of one HBITMAP) also at
|
|
139
|
+
0. The one difference is reported rather than assumed away: `FromHbitmap` yields `Format32bppRgb` where
|
|
140
|
+
`CopyFromScreen` yields `Format32bppArgb`. A gate keeps both halves honest — the fallback reachable and
|
|
141
|
+
`captureBackend` produced, forwarded and printed (`scripts/check-shot-backend.mjs`, seven mutations each
|
|
142
|
+
seen red).
|
|
143
|
+
|
|
144
|
+
### Deciding outside the main context
|
|
145
|
+
|
|
146
|
+
The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
|
|
147
|
+
clean deciding side and take back one number:
|
|
148
|
+
|
|
149
|
+
1. `snapshot` with `intent:"close the settings dialog"` — the intent travels with the frame, and is
|
|
150
|
+
written to `%LOCALAPPDATA%\wpm\last-snapshot.json`;
|
|
151
|
+
2. give the numbered table and the intent to a clean subagent;
|
|
152
|
+
3. it answers with a single `label` — not a selector, not a coordinate;
|
|
153
|
+
4. click with that `label` + `snapId`.
|
|
154
|
+
|
|
155
|
+
`sinceSnapId` serves the same goal: an unchanged tree answers `no changes since <id>` instead of
|
|
156
|
+
repeating itself, and a delta names only what actually moved (`added` / `removed` / `changed`, keyed
|
|
157
|
+
by runtime id).
|
|
77
158
|
|
|
78
159
|
**Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
|
|
79
160
|
verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
|
|
@@ -94,7 +175,7 @@ reported rather than accused — but `cursorRestored=false` (borrowed and not re
|
|
|
94
175
|
`proof=fail`.
|
|
95
176
|
|
|
96
177
|
**And it says who reported the success.** Every action result carries `effect=` in the text and
|
|
97
|
-
`effect` in the structured output. The
|
|
178
|
+
`effect` in the structured output. The four values are not degrees of confidence in the
|
|
98
179
|
application — they name the speaker:
|
|
99
180
|
|
|
100
181
|
| `effect` | who is speaking | it proves | it does **not** prove |
|
|
@@ -102,6 +183,7 @@ application — they name the speaker:
|
|
|
102
183
|
| `unverified` | nobody | nothing | anything |
|
|
103
184
|
| `reported-by-send` | the window-message channel | the message was **delivered** | that the target app processed it |
|
|
104
185
|
| `reported-by-pattern` | the UI Automation pattern call | the call **returned** without throwing | that the interface actually changed |
|
|
186
|
+
| `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 |
|
|
105
187
|
|
|
106
188
|
Since 0.1.3 the effect also enters the judgment, which closes the one honest gap 0.1.2 still had:
|
|
107
189
|
a still desktop could outvote a total no-op. A call whose channel reported nothing is capped at
|
|
@@ -111,6 +193,49 @@ disturb you; it never proves we accomplished anything. A single `reported-by-*`
|
|
|
111
193
|
the caveat spelled out in the reason field (`未独立验证` — nobody observed the app), because turning
|
|
112
194
|
weak-but-real evidence into a red would train its readers to ignore the verdict.
|
|
113
195
|
|
|
196
|
+
### The fourth value has to be earned (0.6.0)
|
|
197
|
+
|
|
198
|
+
`readback-verified` is granted only by the engine, and only when a **prediction** matches a **read**.
|
|
199
|
+
The prediction is computed from measurements the control itself reported — the value it held before,
|
|
200
|
+
its own `WM_GETTEXTLENGTH`, its own `EM_GETSEL` answer for where a typed character lands — and the read
|
|
201
|
+
happens *after* the settle window, so an app that commits its text asynchronously is not judged against
|
|
202
|
+
a half-written buffer:
|
|
203
|
+
|
|
204
|
+
```jsonc
|
|
205
|
+
{"action":"type","hwnd":"…","text":"XY","caretPosition":"start"}
|
|
206
|
+
// -> type ok channel=message tier=quiet effect=readback-verified
|
|
207
|
+
// detail=msg=char|2 child=… caret=start asked=0 applied=0,0 readback=XYabc readbackLen=5 focusMoved=false
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Three things it refuses to do, each measured rather than assumed:
|
|
211
|
+
|
|
212
|
+
* **it does not upgrade what it cannot read.** A masked field (`ES_PASSWORD`) returns an empty string
|
|
213
|
+
while `WM_GETTEXTLENGTH` still reports the real length. That is "the control hides its text", not
|
|
214
|
+
"the field is empty": the result says `readback=unavailable`, the effect keeps whatever the write
|
|
215
|
+
earned, and no value is printed anywhere.
|
|
216
|
+
* **a mismatch is data, not a failure.** A read-only WinForms edit silently refuses `WM_CHAR` — every
|
|
217
|
+
character is accepted by the API and the value never moves — while honouring `WM_SETTEXT`. On the
|
|
218
|
+
refusal the result is still `ok:true` with `readbackMismatch=true` and no upgrade; on the write that
|
|
219
|
+
lands it is `readback-verified`. No refusal code changed for this batch, on purpose: "the application
|
|
220
|
+
formatted my input" is not an error in the call. `test/readback-truth.mjs` asserts both arms against
|
|
221
|
+
the value the *application* wrote about itself, from inside its own process — a readback test that
|
|
222
|
+
compared our write to our read would be grading homework in our own class, and this repo has already
|
|
223
|
+
been caught doing exactly that.
|
|
224
|
+
* **the naive guess is not the model.** Text is not appended: it lands at the caret, and a field that
|
|
225
|
+
never held focus has its caret at 0 (so `abc` + `XY` is `XYabc`). That is why `caretPosition` exists
|
|
226
|
+
and why the result prints `asked=` and `applied=` separately — `EM_SETSEL(-1,-1)` is documented as
|
|
227
|
+
"document end" and measured as a no-op on WinForms EDIT, so `end` is `EM_SETSEL(len,len)` with `len`
|
|
228
|
+
read from the control. On a buffer containing newlines that numeric end can land inside the text
|
|
229
|
+
(`asked=6 applied=4,4`), which is reported instead of hidden; `idle` touches nothing at all. The UIA
|
|
230
|
+
`value` channel replaces the whole value and has no caret to move, so it answers
|
|
231
|
+
`caretIgnored=value-pattern` rather than pretending to honour it.
|
|
232
|
+
|
|
233
|
+
Two more facts ride in the same `detail`, both warnings and neither a refusal: `focusMoved=true` when
|
|
234
|
+
the foreground or the focused control differs between the two measurements taken around the send, and
|
|
235
|
+
`disabled=true` for a target window that is greyed out — Windows keeps answering our messages while
|
|
236
|
+
throwing the input away, so a disabled target loses the right to an `effect` claim
|
|
237
|
+
(`effect=unverified`) without becoming an error.
|
|
238
|
+
|
|
114
239
|
## The takeover tier (opt-in)
|
|
115
240
|
|
|
116
241
|
Off by default (`takeoverAllowed=false`, `keyInjectAllowed=false`), because moving someone's pointer
|
|
@@ -189,8 +314,9 @@ degradation.
|
|
|
189
314
|
## Typed surface
|
|
190
315
|
|
|
191
316
|
`types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
|
|
192
|
-
contract: the
|
|
193
|
-
codes as a closed union
|
|
317
|
+
contract: the eight actions, every argument including the takeover fields, the image-space / label
|
|
318
|
+
surface and 0.6.0's `caretPosition`, all fourteen refusal codes as a closed union, and `effect` as its
|
|
319
|
+
own four-value union (`WpmEffect`) beside `WpmCaptureBackend` and `WpmFrameSource`.
|
|
194
320
|
|
|
195
321
|
Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
|
|
196
322
|
presence of a file:
|
|
@@ -222,6 +348,9 @@ when one is present, and the gate reports a named SKIP rather than a red when on
|
|
|
222
348
|
| `keyInjectAllowed` | `false` | allow `keyInput:"inject"` inside the takeover tier (keyboard only, foreground asserted) |
|
|
223
349
|
| `takeoverMaxMs` | `10000` | hard ceiling for one takeover action (500–60000); the HUD shows the clock |
|
|
224
350
|
| `takeoverArmMs` | `800` | length of the arming phase: the window in which you can cancel before anything moves |
|
|
351
|
+
| `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
|
|
352
|
+
| `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 |
|
|
353
|
+
| `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
|
|
225
354
|
|
|
226
355
|
## What measurement established
|
|
227
356
|
|
|
@@ -283,6 +412,33 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
|
|
|
283
412
|
`WindowFromPoint` no longer returning the HUD, and `HTCLIENT` on the button. That is what
|
|
284
413
|
`hud.ps1` ships.
|
|
285
414
|
|
|
415
|
+
### 0.6.0's measurements (all re-runnable, probe scripts under `.tmp/` in the repository)
|
|
416
|
+
|
|
417
|
+
- **The read-back exists and is truthful** — three window classes (`Edit`,
|
|
418
|
+
`WindowsForms10.EDIT.app.*`, `WindowsForms10.RichEdit20W.app.*`) all return the written value through
|
|
419
|
+
`WM_GETTEXT` cross-process, and in four cases the value equals what the *application* reported about
|
|
420
|
+
itself from inside its own process (168–241 ms to observe, on the app's 400 ms timer).
|
|
421
|
+
- **A password field reports a length but no text** — `ES_PASSWORD`: `WM_GETTEXT` returns the empty
|
|
422
|
+
string while `WM_GETTEXTLENGTH` returns the real length. Hence `readback=unavailable`, never "empty".
|
|
423
|
+
- **`EM_SETSEL(-1,-1)` does not mean "the end" on WinForms EDIT** — the selection stayed `0,0` and the
|
|
424
|
+
typed character went to the front; `EM_SETSEL(len,len)` gave `abcY`. On a buffer holding `CRLF` the
|
|
425
|
+
numeric end landed at `4,4` for a reported length of `6` — measured, therefore reported as
|
|
426
|
+
`asked=`/`applied=` rather than papered over. A plain Win32 `EDIT` that never held focus accepts every
|
|
427
|
+
`WM_CHAR` and changes nothing, even with `ES_NOHIDESEL`: the case the old `reported-by-send` was
|
|
428
|
+
laundering, and the reason this batch exists.
|
|
429
|
+
- **A read-only edit refuses `WM_CHAR` and honours `WM_SETTEXT`** — the falsification arm of
|
|
430
|
+
`test/readback-truth.mjs`, chosen over two candidates that measurement eliminated (a bare `LF` is
|
|
431
|
+
preserved verbatim, so it agrees; WinForms enforces `MaxLength` in its own `WM_CHAR` handler, so a
|
|
432
|
+
programmatic `WM_SETTEXT` bypasses it, as does `EM_SETLIMITTEXT` set from outside).
|
|
433
|
+
- **BitBlt halves the capture and leaves the bottleneck where it is** — 16–21 ms against 22–33 ms for a
|
|
434
|
+
1920×1080 grab, PNG encode 37–39 ms in both paths, capture+encode 12–16 ms on a 642×432 window. JPEG
|
|
435
|
+
(6 ms) and WIC (158 ms) measured and rejected, 24bpp measured at 7 % of the size and rejected.
|
|
436
|
+
- **`replace:true` threw on every target until 0.6.0** — the `WM_SETTEXT` binding was declared as
|
|
437
|
+
`SendMessageStrW`, an export `user32.dll` does not have: the call raised
|
|
438
|
+
`EntryPointNotFoundException` on first use and surfaced as `action_failed`. No test in the repository
|
|
439
|
+
exercised `replace:true` through the message door, which is why the fix ships with an arm that does
|
|
440
|
+
(`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
|
|
441
|
+
|
|
286
442
|
## Verifying the copy you actually installed
|
|
287
443
|
|
|
288
444
|
Every test above imports the repository checkout, so a package that installs to the wrong place or ships
|
package/README.it.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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
|
-
> **Current release: 0.
|
|
8
|
+
> **Current release: 0.6.0** — this document describes the contract as of that version. What
|
|
9
9
|
> changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
|
|
10
10
|
|
|
11
11
|
A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
|
|
@@ -13,7 +13,7 @@ on request. Where a window accepts a window message, you never lose focus at all
|
|
|
13
13
|
exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
|
|
14
14
|
explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
|
|
15
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
|
|
16
|
+
silence: every refusal carries a code from a closed set of fourteen and the next step.
|
|
17
17
|
|
|
18
18
|
**The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
|
|
19
19
|
opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
|
|
@@ -31,15 +31,18 @@ bundle with a broad tool surface; this one is a single action tool whose entire
|
|
|
31
31
|
|
|
32
32
|
## What it does
|
|
33
33
|
|
|
34
|
-
One tool,
|
|
34
|
+
One tool, eight actions:
|
|
35
35
|
|
|
36
36
|
| action | what it returns |
|
|
37
37
|
|---|---|
|
|
38
38
|
| `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
|
|
39
39
|
| `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
|
|
40
|
-
| `click` | click at a screen coordinate inside the named window |
|
|
41
|
-
| `type` | write text into the target (a classic edit child,
|
|
42
|
-
| `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 |
|
|
43
46
|
|
|
44
47
|
The engine picks the cheapest available door per call:
|
|
45
48
|
|
|
@@ -72,8 +75,86 @@ flag itself is engine-side and refuses actions with `paused`.
|
|
|
72
75
|
|
|
73
76
|
Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
|
|
74
77
|
`uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `takeover_unavailable`,
|
|
75
|
-
`keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`. Each
|
|
76
|
-
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 captureBackend=bitblt
|
|
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
|
+
### Which capture path painted the picture
|
|
128
|
+
|
|
129
|
+
`captureBackend` names the producer: `bitblt` is a direct GDI `BitBlt` off the screen DC, `gdiplus` is
|
|
130
|
+
`Graphics.CopyFromScreen` — either the fallback after BitBlt was refused, or nothing else. The cheap
|
|
131
|
+
path replaced the old one on measured grounds (16–21 ms against 22–33 ms for a 1920×1080 grab), and the
|
|
132
|
+
encoder was deliberately left alone: the PNG encode is the bottleneck (37–39 ms), so JPEG (6 ms, and it
|
|
133
|
+
smears text), WIC (158 ms) and 24bpp (7 % smaller) were each measured and each rejected.
|
|
134
|
+
|
|
135
|
+
Equivalence was established on a **static** scene, not by file hash — two captures of a live desktop
|
|
136
|
+
happen at different instants, so their bytes cannot match, and that difference says nothing about the
|
|
137
|
+
paths: identical size, both non-blank, **0 maximum per-channel difference over 17 388 sampled points**,
|
|
138
|
+
byte-identical PNGs (8940 = 8940), with the comparator's self-check (two reads of one HBITMAP) also at
|
|
139
|
+
0. The one difference is reported rather than assumed away: `FromHbitmap` yields `Format32bppRgb` where
|
|
140
|
+
`CopyFromScreen` yields `Format32bppArgb`. A gate keeps both halves honest — the fallback reachable and
|
|
141
|
+
`captureBackend` produced, forwarded and printed (`scripts/check-shot-backend.mjs`, seven mutations each
|
|
142
|
+
seen red).
|
|
143
|
+
|
|
144
|
+
### Deciding outside the main context
|
|
145
|
+
|
|
146
|
+
The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
|
|
147
|
+
clean deciding side and take back one number:
|
|
148
|
+
|
|
149
|
+
1. `snapshot` with `intent:"close the settings dialog"` — the intent travels with the frame, and is
|
|
150
|
+
written to `%LOCALAPPDATA%\wpm\last-snapshot.json`;
|
|
151
|
+
2. give the numbered table and the intent to a clean subagent;
|
|
152
|
+
3. it answers with a single `label` — not a selector, not a coordinate;
|
|
153
|
+
4. click with that `label` + `snapId`.
|
|
154
|
+
|
|
155
|
+
`sinceSnapId` serves the same goal: an unchanged tree answers `no changes since <id>` instead of
|
|
156
|
+
repeating itself, and a delta names only what actually moved (`added` / `removed` / `changed`, keyed
|
|
157
|
+
by runtime id).
|
|
77
158
|
|
|
78
159
|
**Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
|
|
79
160
|
verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
|
|
@@ -94,7 +175,7 @@ reported rather than accused — but `cursorRestored=false` (borrowed and not re
|
|
|
94
175
|
`proof=fail`.
|
|
95
176
|
|
|
96
177
|
**And it says who reported the success.** Every action result carries `effect=` in the text and
|
|
97
|
-
`effect` in the structured output. The
|
|
178
|
+
`effect` in the structured output. The four values are not degrees of confidence in the
|
|
98
179
|
application — they name the speaker:
|
|
99
180
|
|
|
100
181
|
| `effect` | who is speaking | it proves | it does **not** prove |
|
|
@@ -102,6 +183,7 @@ application — they name the speaker:
|
|
|
102
183
|
| `unverified` | nobody | nothing | anything |
|
|
103
184
|
| `reported-by-send` | the window-message channel | the message was **delivered** | that the target app processed it |
|
|
104
185
|
| `reported-by-pattern` | the UI Automation pattern call | the call **returned** without throwing | that the interface actually changed |
|
|
186
|
+
| `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 |
|
|
105
187
|
|
|
106
188
|
Since 0.1.3 the effect also enters the judgment, which closes the one honest gap 0.1.2 still had:
|
|
107
189
|
a still desktop could outvote a total no-op. A call whose channel reported nothing is capped at
|
|
@@ -111,6 +193,49 @@ disturb you; it never proves we accomplished anything. A single `reported-by-*`
|
|
|
111
193
|
the caveat spelled out in the reason field (`未独立验证` — nobody observed the app), because turning
|
|
112
194
|
weak-but-real evidence into a red would train its readers to ignore the verdict.
|
|
113
195
|
|
|
196
|
+
### The fourth value has to be earned (0.6.0)
|
|
197
|
+
|
|
198
|
+
`readback-verified` is granted only by the engine, and only when a **prediction** matches a **read**.
|
|
199
|
+
The prediction is computed from measurements the control itself reported — the value it held before,
|
|
200
|
+
its own `WM_GETTEXTLENGTH`, its own `EM_GETSEL` answer for where a typed character lands — and the read
|
|
201
|
+
happens *after* the settle window, so an app that commits its text asynchronously is not judged against
|
|
202
|
+
a half-written buffer:
|
|
203
|
+
|
|
204
|
+
```jsonc
|
|
205
|
+
{"action":"type","hwnd":"…","text":"XY","caretPosition":"start"}
|
|
206
|
+
// -> type ok channel=message tier=quiet effect=readback-verified
|
|
207
|
+
// detail=msg=char|2 child=… caret=start asked=0 applied=0,0 readback=XYabc readbackLen=5 focusMoved=false
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Three things it refuses to do, each measured rather than assumed:
|
|
211
|
+
|
|
212
|
+
* **it does not upgrade what it cannot read.** A masked field (`ES_PASSWORD`) returns an empty string
|
|
213
|
+
while `WM_GETTEXTLENGTH` still reports the real length. That is "the control hides its text", not
|
|
214
|
+
"the field is empty": the result says `readback=unavailable`, the effect keeps whatever the write
|
|
215
|
+
earned, and no value is printed anywhere.
|
|
216
|
+
* **a mismatch is data, not a failure.** A read-only WinForms edit silently refuses `WM_CHAR` — every
|
|
217
|
+
character is accepted by the API and the value never moves — while honouring `WM_SETTEXT`. On the
|
|
218
|
+
refusal the result is still `ok:true` with `readbackMismatch=true` and no upgrade; on the write that
|
|
219
|
+
lands it is `readback-verified`. No refusal code changed for this batch, on purpose: "the application
|
|
220
|
+
formatted my input" is not an error in the call. `test/readback-truth.mjs` asserts both arms against
|
|
221
|
+
the value the *application* wrote about itself, from inside its own process — a readback test that
|
|
222
|
+
compared our write to our read would be grading homework in our own class, and this repo has already
|
|
223
|
+
been caught doing exactly that.
|
|
224
|
+
* **the naive guess is not the model.** Text is not appended: it lands at the caret, and a field that
|
|
225
|
+
never held focus has its caret at 0 (so `abc` + `XY` is `XYabc`). That is why `caretPosition` exists
|
|
226
|
+
and why the result prints `asked=` and `applied=` separately — `EM_SETSEL(-1,-1)` is documented as
|
|
227
|
+
"document end" and measured as a no-op on WinForms EDIT, so `end` is `EM_SETSEL(len,len)` with `len`
|
|
228
|
+
read from the control. On a buffer containing newlines that numeric end can land inside the text
|
|
229
|
+
(`asked=6 applied=4,4`), which is reported instead of hidden; `idle` touches nothing at all. The UIA
|
|
230
|
+
`value` channel replaces the whole value and has no caret to move, so it answers
|
|
231
|
+
`caretIgnored=value-pattern` rather than pretending to honour it.
|
|
232
|
+
|
|
233
|
+
Two more facts ride in the same `detail`, both warnings and neither a refusal: `focusMoved=true` when
|
|
234
|
+
the foreground or the focused control differs between the two measurements taken around the send, and
|
|
235
|
+
`disabled=true` for a target window that is greyed out — Windows keeps answering our messages while
|
|
236
|
+
throwing the input away, so a disabled target loses the right to an `effect` claim
|
|
237
|
+
(`effect=unverified`) without becoming an error.
|
|
238
|
+
|
|
114
239
|
## The takeover tier (opt-in)
|
|
115
240
|
|
|
116
241
|
Off by default (`takeoverAllowed=false`, `keyInjectAllowed=false`), because moving someone's pointer
|
|
@@ -189,8 +314,9 @@ degradation.
|
|
|
189
314
|
## Typed surface
|
|
190
315
|
|
|
191
316
|
`types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
|
|
192
|
-
contract: the
|
|
193
|
-
codes as a closed union
|
|
317
|
+
contract: the eight actions, every argument including the takeover fields, the image-space / label
|
|
318
|
+
surface and 0.6.0's `caretPosition`, all fourteen refusal codes as a closed union, and `effect` as its
|
|
319
|
+
own four-value union (`WpmEffect`) beside `WpmCaptureBackend` and `WpmFrameSource`.
|
|
194
320
|
|
|
195
321
|
Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
|
|
196
322
|
presence of a file:
|
|
@@ -222,6 +348,9 @@ when one is present, and the gate reports a named SKIP rather than a red when on
|
|
|
222
348
|
| `keyInjectAllowed` | `false` | allow `keyInput:"inject"` inside the takeover tier (keyboard only, foreground asserted) |
|
|
223
349
|
| `takeoverMaxMs` | `10000` | hard ceiling for one takeover action (500–60000); the HUD shows the clock |
|
|
224
350
|
| `takeoverArmMs` | `800` | length of the arming phase: the window in which you can cancel before anything moves |
|
|
351
|
+
| `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
|
|
352
|
+
| `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 |
|
|
353
|
+
| `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
|
|
225
354
|
|
|
226
355
|
## What measurement established
|
|
227
356
|
|
|
@@ -283,6 +412,33 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
|
|
|
283
412
|
`WindowFromPoint` no longer returning the HUD, and `HTCLIENT` on the button. That is what
|
|
284
413
|
`hud.ps1` ships.
|
|
285
414
|
|
|
415
|
+
### 0.6.0's measurements (all re-runnable, probe scripts under `.tmp/` in the repository)
|
|
416
|
+
|
|
417
|
+
- **The read-back exists and is truthful** — three window classes (`Edit`,
|
|
418
|
+
`WindowsForms10.EDIT.app.*`, `WindowsForms10.RichEdit20W.app.*`) all return the written value through
|
|
419
|
+
`WM_GETTEXT` cross-process, and in four cases the value equals what the *application* reported about
|
|
420
|
+
itself from inside its own process (168–241 ms to observe, on the app's 400 ms timer).
|
|
421
|
+
- **A password field reports a length but no text** — `ES_PASSWORD`: `WM_GETTEXT` returns the empty
|
|
422
|
+
string while `WM_GETTEXTLENGTH` returns the real length. Hence `readback=unavailable`, never "empty".
|
|
423
|
+
- **`EM_SETSEL(-1,-1)` does not mean "the end" on WinForms EDIT** — the selection stayed `0,0` and the
|
|
424
|
+
typed character went to the front; `EM_SETSEL(len,len)` gave `abcY`. On a buffer holding `CRLF` the
|
|
425
|
+
numeric end landed at `4,4` for a reported length of `6` — measured, therefore reported as
|
|
426
|
+
`asked=`/`applied=` rather than papered over. A plain Win32 `EDIT` that never held focus accepts every
|
|
427
|
+
`WM_CHAR` and changes nothing, even with `ES_NOHIDESEL`: the case the old `reported-by-send` was
|
|
428
|
+
laundering, and the reason this batch exists.
|
|
429
|
+
- **A read-only edit refuses `WM_CHAR` and honours `WM_SETTEXT`** — the falsification arm of
|
|
430
|
+
`test/readback-truth.mjs`, chosen over two candidates that measurement eliminated (a bare `LF` is
|
|
431
|
+
preserved verbatim, so it agrees; WinForms enforces `MaxLength` in its own `WM_CHAR` handler, so a
|
|
432
|
+
programmatic `WM_SETTEXT` bypasses it, as does `EM_SETLIMITTEXT` set from outside).
|
|
433
|
+
- **BitBlt halves the capture and leaves the bottleneck where it is** — 16–21 ms against 22–33 ms for a
|
|
434
|
+
1920×1080 grab, PNG encode 37–39 ms in both paths, capture+encode 12–16 ms on a 642×432 window. JPEG
|
|
435
|
+
(6 ms) and WIC (158 ms) measured and rejected, 24bpp measured at 7 % of the size and rejected.
|
|
436
|
+
- **`replace:true` threw on every target until 0.6.0** — the `WM_SETTEXT` binding was declared as
|
|
437
|
+
`SendMessageStrW`, an export `user32.dll` does not have: the call raised
|
|
438
|
+
`EntryPointNotFoundException` on first use and surfaced as `action_failed`. No test in the repository
|
|
439
|
+
exercised `replace:true` through the message door, which is why the fix ships with an arm that does
|
|
440
|
+
(`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
|
|
441
|
+
|
|
286
442
|
## Verifying the copy you actually installed
|
|
287
443
|
|
|
288
444
|
Every test above imports the repository checkout, so a package that installs to the wrong place or ships
|