dsh-windows-parallel-mcp 0.5.0 → 0.7.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 +13 -1
- package/CHANGELOG.es.md +13 -1
- package/CHANGELOG.fr.md +13 -1
- package/CHANGELOG.it.md +13 -1
- package/CHANGELOG.ja.md +12 -0
- package/CHANGELOG.ko.md +12 -0
- package/CHANGELOG.md +181 -3
- package/CHANGELOG.pt.md +13 -1
- package/CHANGELOG.ru.md +13 -1
- package/CHANGELOG.zh.md +12 -0
- package/README.de.md +218 -7
- package/README.es.md +218 -7
- package/README.fr.md +218 -7
- package/README.it.md +218 -7
- package/README.ja.md +218 -7
- package/README.ko.md +218 -7
- package/README.md +218 -7
- package/README.pt.md +218 -7
- package/README.ru.md +218 -7
- package/README.zh.md +218 -7
- package/docs/refusals.md +3 -0
- package/dsh.plugin.json +2 -2
- package/lib/audit.js +109 -0
- package/lib/config.js +55 -2
- package/lib/host-tools.js +76 -3
- package/lib/index.js +333 -18
- package/lib/policy.js +127 -0
- package/package.json +2 -2
- package/src/engine/decide.ps1 +120 -3
- package/src/engine/engine.ps1 +407 -5
- package/src/engine/win.ps1 +496 -6
- package/src/engine/worker.ps1 +57 -0
- package/src/schema/tools.json +156 -13
- package/types/index.d.ts +63 -4
package/README.de.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
> Ein DSH-Plugin, mit dem ein Agent **seine eigenen** Windows-Fenster steuert — standardmäßig still, auf Anfrage sichtbar. Wenn ein Fenster Windows-Nachrichten akzeptiert, wird der Fokus nie entzogen. Wenn nur UI Automation es erreicht, gibt es einen einzigen begrenzten Fokus-Blitz, der automatisch rückgängig gemacht wird. Wenn Sie den Takeover-Modus ausdrücklich anfordern, bewegt sich der Cursor zum Aktionspunkt und wird immer wiederhergestellt; ein HUD bietet drei Möglichkeiten zum Abbruch. Überall anders wird mit Code und Grund abgelehnt.
|
|
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.7.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 seventeen 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,7 +31,7 @@ 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, eleven actions:
|
|
35
35
|
|
|
36
36
|
| action | what it returns |
|
|
37
37
|
|---|---|
|
|
@@ -43,6 +43,9 @@ One tool, eight actions:
|
|
|
43
43
|
| `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
|
|
44
44
|
| `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
|
|
45
45
|
| `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
|
|
46
|
+
| `launch` | start a whitelisted program; reports the pid, and the window only once it really exists |
|
|
47
|
+
| `clipboard` | read or write the system clipboard — a read reports lengths and never the payload |
|
|
48
|
+
| `window` | minimize / restore / move / resize / topmost ONE named window, verified by reading its state back |
|
|
46
49
|
|
|
47
50
|
The engine picks the cheapest available door per call:
|
|
48
51
|
|
|
@@ -94,7 +97,7 @@ Image coordinates are never multiplied by the caller:
|
|
|
94
97
|
|
|
95
98
|
```jsonc
|
|
96
99
|
{"action":"screenshot","hwnd":"1310720"}
|
|
97
|
-
// -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm
|
|
100
|
+
// -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm captureBackend=bitblt
|
|
98
101
|
{"action":"click","hwnd":"1310720","space":"image","shotId":"shot-…","x":350,"y":250}
|
|
99
102
|
// the ENGINE converts, then still asserts the point belongs to the target window
|
|
100
103
|
```
|
|
@@ -124,6 +127,23 @@ point at would be a trap), the frame is cross-checked against the window rect th
|
|
|
124
127
|
(`frameCheck=pass|fail|unknown`), and a structural gate pins the single-source rule by mutating a copy
|
|
125
128
|
of the engine and requiring the corresponding red.
|
|
126
129
|
|
|
130
|
+
### Which capture path painted the picture
|
|
131
|
+
|
|
132
|
+
`captureBackend` names the producer: `bitblt` is a direct GDI `BitBlt` off the screen DC, `gdiplus` is
|
|
133
|
+
`Graphics.CopyFromScreen` — either the fallback after BitBlt was refused, or nothing else. The cheap
|
|
134
|
+
path replaced the old one on measured grounds (16–21 ms against 22–33 ms for a 1920×1080 grab), and the
|
|
135
|
+
encoder was deliberately left alone: the PNG encode is the bottleneck (37–39 ms), so JPEG (6 ms, and it
|
|
136
|
+
smears text), WIC (158 ms) and 24bpp (7 % smaller) were each measured and each rejected.
|
|
137
|
+
|
|
138
|
+
Equivalence was established on a **static** scene, not by file hash — two captures of a live desktop
|
|
139
|
+
happen at different instants, so their bytes cannot match, and that difference says nothing about the
|
|
140
|
+
paths: identical size, both non-blank, **0 maximum per-channel difference over 17 388 sampled points**,
|
|
141
|
+
byte-identical PNGs (8940 = 8940), with the comparator's self-check (two reads of one HBITMAP) also at
|
|
142
|
+
0. The one difference is reported rather than assumed away: `FromHbitmap` yields `Format32bppRgb` where
|
|
143
|
+
`CopyFromScreen` yields `Format32bppArgb`. A gate keeps both halves honest — the fallback reachable and
|
|
144
|
+
`captureBackend` produced, forwarded and printed (`scripts/check-shot-backend.mjs`, seven mutations each
|
|
145
|
+
seen red).
|
|
146
|
+
|
|
127
147
|
### Deciding outside the main context
|
|
128
148
|
|
|
129
149
|
The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
|
|
@@ -158,7 +178,7 @@ reported rather than accused — but `cursorRestored=false` (borrowed and not re
|
|
|
158
178
|
`proof=fail`.
|
|
159
179
|
|
|
160
180
|
**And it says who reported the success.** Every action result carries `effect=` in the text and
|
|
161
|
-
`effect` in the structured output. The
|
|
181
|
+
`effect` in the structured output. The four values are not degrees of confidence in the
|
|
162
182
|
application — they name the speaker:
|
|
163
183
|
|
|
164
184
|
| `effect` | who is speaking | it proves | it does **not** prove |
|
|
@@ -166,6 +186,7 @@ application — they name the speaker:
|
|
|
166
186
|
| `unverified` | nobody | nothing | anything |
|
|
167
187
|
| `reported-by-send` | the window-message channel | the message was **delivered** | that the target app processed it |
|
|
168
188
|
| `reported-by-pattern` | the UI Automation pattern call | the call **returned** without throwing | that the interface actually changed |
|
|
189
|
+
| `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 |
|
|
169
190
|
|
|
170
191
|
Since 0.1.3 the effect also enters the judgment, which closes the one honest gap 0.1.2 still had:
|
|
171
192
|
a still desktop could outvote a total no-op. A call whose channel reported nothing is capped at
|
|
@@ -175,6 +196,49 @@ disturb you; it never proves we accomplished anything. A single `reported-by-*`
|
|
|
175
196
|
the caveat spelled out in the reason field (`未独立验证` — nobody observed the app), because turning
|
|
176
197
|
weak-but-real evidence into a red would train its readers to ignore the verdict.
|
|
177
198
|
|
|
199
|
+
### The fourth value has to be earned (0.6.0)
|
|
200
|
+
|
|
201
|
+
`readback-verified` is granted only by the engine, and only when a **prediction** matches a **read**.
|
|
202
|
+
The prediction is computed from measurements the control itself reported — the value it held before,
|
|
203
|
+
its own `WM_GETTEXTLENGTH`, its own `EM_GETSEL` answer for where a typed character lands — and the read
|
|
204
|
+
happens *after* the settle window, so an app that commits its text asynchronously is not judged against
|
|
205
|
+
a half-written buffer:
|
|
206
|
+
|
|
207
|
+
```jsonc
|
|
208
|
+
{"action":"type","hwnd":"…","text":"XY","caretPosition":"start"}
|
|
209
|
+
// -> type ok channel=message tier=quiet effect=readback-verified
|
|
210
|
+
// detail=msg=char|2 child=… caret=start asked=0 applied=0,0 readback=XYabc readbackLen=5 focusMoved=false
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Three things it refuses to do, each measured rather than assumed:
|
|
214
|
+
|
|
215
|
+
* **it does not upgrade what it cannot read.** A masked field (`ES_PASSWORD`) returns an empty string
|
|
216
|
+
while `WM_GETTEXTLENGTH` still reports the real length. That is "the control hides its text", not
|
|
217
|
+
"the field is empty": the result says `readback=unavailable`, the effect keeps whatever the write
|
|
218
|
+
earned, and no value is printed anywhere.
|
|
219
|
+
* **a mismatch is data, not a failure.** A read-only WinForms edit silently refuses `WM_CHAR` — every
|
|
220
|
+
character is accepted by the API and the value never moves — while honouring `WM_SETTEXT`. On the
|
|
221
|
+
refusal the result is still `ok:true` with `readbackMismatch=true` and no upgrade; on the write that
|
|
222
|
+
lands it is `readback-verified`. No refusal code changed for this batch, on purpose: "the application
|
|
223
|
+
formatted my input" is not an error in the call. `test/readback-truth.mjs` asserts both arms against
|
|
224
|
+
the value the *application* wrote about itself, from inside its own process — a readback test that
|
|
225
|
+
compared our write to our read would be grading homework in our own class, and this repo has already
|
|
226
|
+
been caught doing exactly that.
|
|
227
|
+
* **the naive guess is not the model.** Text is not appended: it lands at the caret, and a field that
|
|
228
|
+
never held focus has its caret at 0 (so `abc` + `XY` is `XYabc`). That is why `caretPosition` exists
|
|
229
|
+
and why the result prints `asked=` and `applied=` separately — `EM_SETSEL(-1,-1)` is documented as
|
|
230
|
+
"document end" and measured as a no-op on WinForms EDIT, so `end` is `EM_SETSEL(len,len)` with `len`
|
|
231
|
+
read from the control. On a buffer containing newlines that numeric end can land inside the text
|
|
232
|
+
(`asked=6 applied=4,4`), which is reported instead of hidden; `idle` touches nothing at all. The UIA
|
|
233
|
+
`value` channel replaces the whole value and has no caret to move, so it answers
|
|
234
|
+
`caretIgnored=value-pattern` rather than pretending to honour it.
|
|
235
|
+
|
|
236
|
+
Two more facts ride in the same `detail`, both warnings and neither a refusal: `focusMoved=true` when
|
|
237
|
+
the foreground or the focused control differs between the two measurements taken around the send, and
|
|
238
|
+
`disabled=true` for a target window that is greyed out — Windows keeps answering our messages while
|
|
239
|
+
throwing the input away, so a disabled target loses the right to an `effect` claim
|
|
240
|
+
(`effect=unverified`) without becoming an error.
|
|
241
|
+
|
|
178
242
|
## The takeover tier (opt-in)
|
|
179
243
|
|
|
180
244
|
Off by default (`takeoverAllowed=false`, `keyInjectAllowed=false`), because moving someone's pointer
|
|
@@ -217,6 +281,93 @@ click. Success is reported as `effect=reported-by-send`, never as "verified". Un
|
|
|
217
281
|
carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
|
|
218
282
|
not a bug.
|
|
219
283
|
|
|
284
|
+
## Desktop actions: launch, clipboard, window (0.7.0)
|
|
285
|
+
|
|
286
|
+
Three capabilities that were missing outright — "you cannot even start a program" was the honest answer
|
|
287
|
+
— and none of them is a door action. They choose no channel, cost no tier, and produce no proof window,
|
|
288
|
+
so they live beside `Invoke-WpmAction` rather than inside it, and the door discipline (point ownership,
|
|
289
|
+
the restore table, the proof window) is not widened by any of them.
|
|
290
|
+
|
|
291
|
+
**`launch` — two switches, neither of which implies the other.** `appLaunchAllowed` opens the
|
|
292
|
+
capability; `appLaunchAllow` lists the exact program names or absolute paths that may run, and an
|
|
293
|
+
**empty list means nothing may launch even with the gate on**. Matching is exact and case-folded: there
|
|
294
|
+
is no wildcard, and `notepad` does not authorise `notepad-helper.exe` — a whitelist that grows by prefix
|
|
295
|
+
is a whitelist that authorises more than it says. A refusal is `app_launch_denied` and is raised before
|
|
296
|
+
any worker request, so a refused launch started nothing (asserted with a request counter in
|
|
297
|
+
`test/plugin-test.mjs` and re-checked inside the engine against the same table). The engine's own
|
|
298
|
+
vocabulary for the window is the interesting part: `Process.Start` returns while the app is still
|
|
299
|
+
loading (measured: `MainWindowHandle=0` for 1348 ms on a cold notepad), so a program that has not
|
|
300
|
+
published a window yet answers `ok:true` with `hwnd=""` and `detail=window-not-yet` — neither a fake
|
|
301
|
+
failure nor a fake readiness. Arguments are passed through as given and written to the audit log,
|
|
302
|
+
because listing a program does not vouch for what it is told to do.
|
|
303
|
+
|
|
304
|
+
**`clipboard` — the most private read in this product.** What is on the clipboard may be a password or
|
|
305
|
+
a token the owner copied seconds ago, so a text read reports its **length**, its result text never
|
|
306
|
+
contains the payload, the audit line records `op`/`format`/`chars`, and values are capped at 64 KB with
|
|
307
|
+
`truncated` stated rather than silently cut. An image write accepts a `shotId`, so a screenshot can go
|
|
308
|
+
straight into the clipboard without the caller handling pixels; the read-back compares the size the
|
|
309
|
+
clipboard reports against the size the shot recorded. A clipboard holding neither is refused with the
|
|
310
|
+
format names it did find — an empty success would be indistinguishable from "the clipboard is empty".
|
|
311
|
+
|
|
312
|
+
**`window` — one named window, five ops, each verified by reading the window back.** `IsIconic`,
|
|
313
|
+
`GetWindowRect`, the `WS_EX_TOPMOST` bit — not `ShowWindow`'s return value, because a syscall's answer
|
|
314
|
+
describes the CALL and this product has been burned repeatedly by reporting that as a state. `move` and
|
|
315
|
+
`resize` pass `SWP_NOACTIVATE`, and the result carries `foregroundTaken=true|false` measured on both
|
|
316
|
+
sides of that specific call: `restore` activates by definition (that is what restoring is), and the
|
|
317
|
+
honest answer is to report it, not to hide it or to refuse the op the caller asked for. There is no
|
|
318
|
+
"all windows" op and no `#32770` discovery: acting on a window nobody named is not a convenience.
|
|
319
|
+
|
|
320
|
+
### One ceiling, eleven actions
|
|
321
|
+
|
|
322
|
+
The old shape of this problem was a boolean per capability, which does not scale past the number of
|
|
323
|
+
settings anyone will actually read. Instead the two axes are independent:
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
the action declares the lowest rung it can ever need (src/schema/tools.json#requiresTier)
|
|
327
|
+
the owner sets one ceiling (settings: policy)
|
|
328
|
+
|
|
329
|
+
readonly < quiet < flash < takeover
|
|
330
|
+
reads message bounded-UIA real cursor / held focus / launch
|
|
331
|
+
door flash
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
| `policy` | permits | refuses |
|
|
335
|
+
|---|---|---|
|
|
336
|
+
| `readonly` | `windows`, `status`, `snapshot`, `screenshot`, `preview`, `clipboard` read | every write |
|
|
337
|
+
| `quiet` | + `click` / `type` / `focus` through the message door | the flash tier, `clipboard` write, `window`, `launch` |
|
|
338
|
+
| `balanced` *(default)* | + the bounded-flash tier, `clipboard` write, `window` ops | `takeover:true`, `keyInput:"inject"`, `launch` |
|
|
339
|
+
| `full` | + the takeover tier and `launch` | nothing extra |
|
|
340
|
+
|
|
341
|
+
Above the ceiling a call is refused with **`policy_denied`** and the reason names both numbers (what the
|
|
342
|
+
action needed, what the policy allows), because the correct next step is a settings change and the wrong
|
|
343
|
+
one is a retry. The gate order is `paused → policy → takeoverAllowed/keyInjectAllowed → launch gate +
|
|
344
|
+
whitelist → idle check → the door table`, and every step in it is tested by making two gates disagree
|
|
345
|
+
about which one spoke (`test/plugin-test.mjs`). Two consequences are worth stating plainly rather than
|
|
346
|
+
leaving to discovery: **`takeover:true` now needs `policy:'full'` as well as `takeoverAllowed`** (0.7.0
|
|
347
|
+
raised the bar for the loudest tier on purpose), and `clipboard`'s halves are graded separately
|
|
348
|
+
(`requiresTierFor`), so a `readonly` owner can still read.
|
|
349
|
+
|
|
350
|
+
**Idle instead of a dialog.** When the last *physical* input is younger than `policyIdleMs` (default
|
|
351
|
+
3000 ms) and the action needs the takeover tier, it is refused with **`user_active`** and nothing is
|
|
352
|
+
clicked — no popup, no countdown. The upstream design asks the owner to consent by interrupting them;
|
|
353
|
+
an interrupt presented as consent is just a second disturbance. The escape hatch is explicit
|
|
354
|
+
(`forceUserActive:true`), it does not bypass any other gate, and the audit line records `forced:true` so
|
|
355
|
+
an interruption caused on purpose stays distinguishable from one caused by accident. An unattended run
|
|
356
|
+
is never blocked by this: with nobody typing, the age grows past the window and the call goes through.
|
|
357
|
+
|
|
358
|
+
### The audit log
|
|
359
|
+
|
|
360
|
+
Every action appends one JSONL line to `%LOCALAPPDATA%\wpm\audit.log` — allow **and** deny, because a
|
|
361
|
+
trail that records only refusals documents the times the guard worked and is silent about the times it
|
|
362
|
+
had nothing to do with. Fields: `ts, action, hwnd, tier, policy, decision, code, userActiveAgeMs,
|
|
363
|
+
effect, latencyMs`, plus `target`/`args` for a launch and `op`/`format`/`chars` for a clipboard call.
|
|
364
|
+
What is deliberately absent is content: no typed text, no clipboard payload — the second copy of a
|
|
365
|
+
secret is the one nobody protects. `auditKeep` (default 2000) bounds the file, pruning oldest-first when
|
|
366
|
+
a write pushes it past budget. An audit that cannot be written is reported (`auditNote=n write(s)
|
|
367
|
+
failed`) rather than swallowed: a log that looks complete and is not is worse than one that admits it
|
|
368
|
+
is missing lines. This is the only artifact that survives a call, and it is the one thing that can
|
|
369
|
+
answer "what did the agent do to this machine" after the fact.
|
|
370
|
+
|
|
220
371
|
## What it does not do
|
|
221
372
|
|
|
222
373
|
- **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
|
|
@@ -253,8 +404,10 @@ degradation.
|
|
|
253
404
|
## Typed surface
|
|
254
405
|
|
|
255
406
|
`types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
|
|
256
|
-
contract: the
|
|
257
|
-
|
|
407
|
+
contract: the eleven actions, every argument including the takeover fields, the image-space / label
|
|
408
|
+
surface, 0.6.0's `caretPosition` and 0.7.0's `target`/`op`/`format`/`forceUserActive`, all seventeen
|
|
409
|
+
refusal codes as a closed union, and `effect` as its own four-value union (`WpmEffect`) beside
|
|
410
|
+
`WpmCaptureBackend`, `WpmClipboardOp`, `WpmWindowOp`, `WpmPolicy` and `WpmFrameSource`.
|
|
258
411
|
|
|
259
412
|
Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
|
|
260
413
|
presence of a file:
|
|
@@ -289,6 +442,11 @@ when one is present, and the gate reports a named SKIP rather than a red when on
|
|
|
289
442
|
| `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
|
|
290
443
|
| `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
444
|
| `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
|
|
445
|
+
| `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` |
|
|
446
|
+
| `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 |
|
|
447
|
+
| `appLaunchAllowed` | `false` | allow `action=launch` at all. Independent of `takeoverAllowed`: being allowed to move a pointer is not being allowed to start a program |
|
|
448
|
+
| `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 |
|
|
449
|
+
| `auditKeep` | `2000` | how many lines `%LOCALAPPDATA%\wpm\audit.log` holds before the oldest are pruned |
|
|
292
450
|
|
|
293
451
|
## What measurement established
|
|
294
452
|
|
|
@@ -350,6 +508,59 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
|
|
|
350
508
|
`WindowFromPoint` no longer returning the HUD, and `HTCLIENT` on the button. That is what
|
|
351
509
|
`hud.ps1` ships.
|
|
352
510
|
|
|
511
|
+
### 0.6.0's measurements (all re-runnable, probe scripts under `.tmp/` in the repository)
|
|
512
|
+
|
|
513
|
+
- **The read-back exists and is truthful** — three window classes (`Edit`,
|
|
514
|
+
`WindowsForms10.EDIT.app.*`, `WindowsForms10.RichEdit20W.app.*`) all return the written value through
|
|
515
|
+
`WM_GETTEXT` cross-process, and in four cases the value equals what the *application* reported about
|
|
516
|
+
itself from inside its own process (168–241 ms to observe, on the app's 400 ms timer).
|
|
517
|
+
- **A password field reports a length but no text** — `ES_PASSWORD`: `WM_GETTEXT` returns the empty
|
|
518
|
+
string while `WM_GETTEXTLENGTH` returns the real length. Hence `readback=unavailable`, never "empty".
|
|
519
|
+
- **`EM_SETSEL(-1,-1)` does not mean "the end" on WinForms EDIT** — the selection stayed `0,0` and the
|
|
520
|
+
typed character went to the front; `EM_SETSEL(len,len)` gave `abcY`. On a buffer holding `CRLF` the
|
|
521
|
+
numeric end landed at `4,4` for a reported length of `6` — measured, therefore reported as
|
|
522
|
+
`asked=`/`applied=` rather than papered over. A plain Win32 `EDIT` that never held focus accepts every
|
|
523
|
+
`WM_CHAR` and changes nothing, even with `ES_NOHIDESEL`: the case the old `reported-by-send` was
|
|
524
|
+
laundering, and the reason this batch exists.
|
|
525
|
+
- **A read-only edit refuses `WM_CHAR` and honours `WM_SETTEXT`** — the falsification arm of
|
|
526
|
+
`test/readback-truth.mjs`, chosen over two candidates that measurement eliminated (a bare `LF` is
|
|
527
|
+
preserved verbatim, so it agrees; WinForms enforces `MaxLength` in its own `WM_CHAR` handler, so a
|
|
528
|
+
programmatic `WM_SETTEXT` bypasses it, as does `EM_SETLIMITTEXT` set from outside).
|
|
529
|
+
- **BitBlt halves the capture and leaves the bottleneck where it is** — 16–21 ms against 22–33 ms for a
|
|
530
|
+
1920×1080 grab, PNG encode 37–39 ms in both paths, capture+encode 12–16 ms on a 642×432 window. JPEG
|
|
531
|
+
(6 ms) and WIC (158 ms) measured and rejected, 24bpp measured at 7 % of the size and rejected.
|
|
532
|
+
- **`replace:true` threw on every target until 0.6.0** — the `WM_SETTEXT` binding was declared as
|
|
533
|
+
`SendMessageStrW`, an export `user32.dll` does not have: the call raised
|
|
534
|
+
`EntryPointNotFoundException` on first use and surfaced as `action_failed`. No test in the repository
|
|
535
|
+
exercised `replace:true` through the message door, which is why the fix ships with an arm that does
|
|
536
|
+
(`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
|
|
537
|
+
|
|
538
|
+
### 0.7.0's measurements
|
|
539
|
+
|
|
540
|
+
- **A cold `Process.Start` has no window for over a second** — notepad: pid present,
|
|
541
|
+
`MainWindowHandle=0`, **1348 ms**, and the window only reachable by polling the pid. Hence
|
|
542
|
+
`waitMs`/`window-not-yet` rather than an hwnd claim at return time.
|
|
543
|
+
- **The STA clipboard works in the worker and is not instant** — text write+read identical, first call
|
|
544
|
+
**138 ms**; `SetDataObject`/`GetDataObject` for images (40×20 verified). `Clipboard.Flush()` does NOT
|
|
545
|
+
exist on Windows PowerShell 5.1's runtime (.NET Framework): the first version of this branch threw
|
|
546
|
+
"Clipboard does not contain a method named 'Flush'", which is a method present in the documentation
|
|
547
|
+
people read and absent from the platform the product targets. `SetDataObject($v, $true)` is the
|
|
548
|
+
supported way to make the data outlive the process.
|
|
549
|
+
- **`SW_RESTORE` activates.** Measured around a restore on a real notepad window:
|
|
550
|
+
`foregroundBefore=<other> foregroundAfter=<target>`. Reported as `foregroundTaken=true` on that call
|
|
551
|
+
instead of being attributed to something else; `move`/`resize`/`topmost` measured
|
|
552
|
+
`foregroundTaken=false` with `SWP_NOACTIVATE`.
|
|
553
|
+
- **The whitelist is only a whitelist if it is exact.** `notepad` against `notepad-helper.exe`: a
|
|
554
|
+
prefix or substring rule authorises the second one, so membership is a case-folded full-string test
|
|
555
|
+
and `test/plugin-test.mjs` asserts the refusal for an unlisted name while the gate is on.
|
|
556
|
+
- **The refusal vocabulary is unchanged in shape by `requiresTier`** — a rung comparison is arithmetic
|
|
557
|
+
over one ordered list, so the cost of an action's classification is one number, not one new code per
|
|
558
|
+
action. Three codes were added for the whole batch (`app_launch_denied`, `policy_denied`,
|
|
559
|
+
`user_active`), each naming a setting rather than a symptom.
|
|
560
|
+
- `Check-no-cursor-control` is still green with the same two whitelisted primitive uses and an
|
|
561
|
+
unchanged whitelist file list: adding `launch`/`window` did not open a door to `MOUSEEVENTF_*`,
|
|
562
|
+
`mouse_event` or `keybd_event`.
|
|
563
|
+
|
|
353
564
|
## Verifying the copy you actually installed
|
|
354
565
|
|
|
355
566
|
Every test above imports the repository checkout, so a package that installs to the wrong place or ships
|
package/README.es.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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
|
-
> **Current release: 0.
|
|
8
|
+
> **Current release: 0.7.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 seventeen 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,7 +31,7 @@ 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, eleven actions:
|
|
35
35
|
|
|
36
36
|
| action | what it returns |
|
|
37
37
|
|---|---|
|
|
@@ -43,6 +43,9 @@ One tool, eight actions:
|
|
|
43
43
|
| `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
|
|
44
44
|
| `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
|
|
45
45
|
| `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
|
|
46
|
+
| `launch` | start a whitelisted program; reports the pid, and the window only once it really exists |
|
|
47
|
+
| `clipboard` | read or write the system clipboard — a read reports lengths and never the payload |
|
|
48
|
+
| `window` | minimize / restore / move / resize / topmost ONE named window, verified by reading its state back |
|
|
46
49
|
|
|
47
50
|
The engine picks the cheapest available door per call:
|
|
48
51
|
|
|
@@ -94,7 +97,7 @@ Image coordinates are never multiplied by the caller:
|
|
|
94
97
|
|
|
95
98
|
```jsonc
|
|
96
99
|
{"action":"screenshot","hwnd":"1310720"}
|
|
97
|
-
// -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm
|
|
100
|
+
// -> screenRect=0,0,1920,1032 imageSize=1920x1032 scale=1 identity=true frame=dwm captureBackend=bitblt
|
|
98
101
|
{"action":"click","hwnd":"1310720","space":"image","shotId":"shot-…","x":350,"y":250}
|
|
99
102
|
// the ENGINE converts, then still asserts the point belongs to the target window
|
|
100
103
|
```
|
|
@@ -124,6 +127,23 @@ point at would be a trap), the frame is cross-checked against the window rect th
|
|
|
124
127
|
(`frameCheck=pass|fail|unknown`), and a structural gate pins the single-source rule by mutating a copy
|
|
125
128
|
of the engine and requiring the corresponding red.
|
|
126
129
|
|
|
130
|
+
### Which capture path painted the picture
|
|
131
|
+
|
|
132
|
+
`captureBackend` names the producer: `bitblt` is a direct GDI `BitBlt` off the screen DC, `gdiplus` is
|
|
133
|
+
`Graphics.CopyFromScreen` — either the fallback after BitBlt was refused, or nothing else. The cheap
|
|
134
|
+
path replaced the old one on measured grounds (16–21 ms against 22–33 ms for a 1920×1080 grab), and the
|
|
135
|
+
encoder was deliberately left alone: the PNG encode is the bottleneck (37–39 ms), so JPEG (6 ms, and it
|
|
136
|
+
smears text), WIC (158 ms) and 24bpp (7 % smaller) were each measured and each rejected.
|
|
137
|
+
|
|
138
|
+
Equivalence was established on a **static** scene, not by file hash — two captures of a live desktop
|
|
139
|
+
happen at different instants, so their bytes cannot match, and that difference says nothing about the
|
|
140
|
+
paths: identical size, both non-blank, **0 maximum per-channel difference over 17 388 sampled points**,
|
|
141
|
+
byte-identical PNGs (8940 = 8940), with the comparator's self-check (two reads of one HBITMAP) also at
|
|
142
|
+
0. The one difference is reported rather than assumed away: `FromHbitmap` yields `Format32bppRgb` where
|
|
143
|
+
`CopyFromScreen` yields `Format32bppArgb`. A gate keeps both halves honest — the fallback reachable and
|
|
144
|
+
`captureBackend` produced, forwarded and printed (`scripts/check-shot-backend.mjs`, seven mutations each
|
|
145
|
+
seen red).
|
|
146
|
+
|
|
127
147
|
### Deciding outside the main context
|
|
128
148
|
|
|
129
149
|
The expensive habit this replaces is re-reading a 70-row table on every step. Hand the frame to a
|
|
@@ -158,7 +178,7 @@ reported rather than accused — but `cursorRestored=false` (borrowed and not re
|
|
|
158
178
|
`proof=fail`.
|
|
159
179
|
|
|
160
180
|
**And it says who reported the success.** Every action result carries `effect=` in the text and
|
|
161
|
-
`effect` in the structured output. The
|
|
181
|
+
`effect` in the structured output. The four values are not degrees of confidence in the
|
|
162
182
|
application — they name the speaker:
|
|
163
183
|
|
|
164
184
|
| `effect` | who is speaking | it proves | it does **not** prove |
|
|
@@ -166,6 +186,7 @@ application — they name the speaker:
|
|
|
166
186
|
| `unverified` | nobody | nothing | anything |
|
|
167
187
|
| `reported-by-send` | the window-message channel | the message was **delivered** | that the target app processed it |
|
|
168
188
|
| `reported-by-pattern` | the UI Automation pattern call | the call **returned** without throwing | that the interface actually changed |
|
|
189
|
+
| `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 |
|
|
169
190
|
|
|
170
191
|
Since 0.1.3 the effect also enters the judgment, which closes the one honest gap 0.1.2 still had:
|
|
171
192
|
a still desktop could outvote a total no-op. A call whose channel reported nothing is capped at
|
|
@@ -175,6 +196,49 @@ disturb you; it never proves we accomplished anything. A single `reported-by-*`
|
|
|
175
196
|
the caveat spelled out in the reason field (`未独立验证` — nobody observed the app), because turning
|
|
176
197
|
weak-but-real evidence into a red would train its readers to ignore the verdict.
|
|
177
198
|
|
|
199
|
+
### The fourth value has to be earned (0.6.0)
|
|
200
|
+
|
|
201
|
+
`readback-verified` is granted only by the engine, and only when a **prediction** matches a **read**.
|
|
202
|
+
The prediction is computed from measurements the control itself reported — the value it held before,
|
|
203
|
+
its own `WM_GETTEXTLENGTH`, its own `EM_GETSEL` answer for where a typed character lands — and the read
|
|
204
|
+
happens *after* the settle window, so an app that commits its text asynchronously is not judged against
|
|
205
|
+
a half-written buffer:
|
|
206
|
+
|
|
207
|
+
```jsonc
|
|
208
|
+
{"action":"type","hwnd":"…","text":"XY","caretPosition":"start"}
|
|
209
|
+
// -> type ok channel=message tier=quiet effect=readback-verified
|
|
210
|
+
// detail=msg=char|2 child=… caret=start asked=0 applied=0,0 readback=XYabc readbackLen=5 focusMoved=false
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Three things it refuses to do, each measured rather than assumed:
|
|
214
|
+
|
|
215
|
+
* **it does not upgrade what it cannot read.** A masked field (`ES_PASSWORD`) returns an empty string
|
|
216
|
+
while `WM_GETTEXTLENGTH` still reports the real length. That is "the control hides its text", not
|
|
217
|
+
"the field is empty": the result says `readback=unavailable`, the effect keeps whatever the write
|
|
218
|
+
earned, and no value is printed anywhere.
|
|
219
|
+
* **a mismatch is data, not a failure.** A read-only WinForms edit silently refuses `WM_CHAR` — every
|
|
220
|
+
character is accepted by the API and the value never moves — while honouring `WM_SETTEXT`. On the
|
|
221
|
+
refusal the result is still `ok:true` with `readbackMismatch=true` and no upgrade; on the write that
|
|
222
|
+
lands it is `readback-verified`. No refusal code changed for this batch, on purpose: "the application
|
|
223
|
+
formatted my input" is not an error in the call. `test/readback-truth.mjs` asserts both arms against
|
|
224
|
+
the value the *application* wrote about itself, from inside its own process — a readback test that
|
|
225
|
+
compared our write to our read would be grading homework in our own class, and this repo has already
|
|
226
|
+
been caught doing exactly that.
|
|
227
|
+
* **the naive guess is not the model.** Text is not appended: it lands at the caret, and a field that
|
|
228
|
+
never held focus has its caret at 0 (so `abc` + `XY` is `XYabc`). That is why `caretPosition` exists
|
|
229
|
+
and why the result prints `asked=` and `applied=` separately — `EM_SETSEL(-1,-1)` is documented as
|
|
230
|
+
"document end" and measured as a no-op on WinForms EDIT, so `end` is `EM_SETSEL(len,len)` with `len`
|
|
231
|
+
read from the control. On a buffer containing newlines that numeric end can land inside the text
|
|
232
|
+
(`asked=6 applied=4,4`), which is reported instead of hidden; `idle` touches nothing at all. The UIA
|
|
233
|
+
`value` channel replaces the whole value and has no caret to move, so it answers
|
|
234
|
+
`caretIgnored=value-pattern` rather than pretending to honour it.
|
|
235
|
+
|
|
236
|
+
Two more facts ride in the same `detail`, both warnings and neither a refusal: `focusMoved=true` when
|
|
237
|
+
the foreground or the focused control differs between the two measurements taken around the send, and
|
|
238
|
+
`disabled=true` for a target window that is greyed out — Windows keeps answering our messages while
|
|
239
|
+
throwing the input away, so a disabled target loses the right to an `effect` claim
|
|
240
|
+
(`effect=unverified`) without becoming an error.
|
|
241
|
+
|
|
178
242
|
## The takeover tier (opt-in)
|
|
179
243
|
|
|
180
244
|
Off by default (`takeoverAllowed=false`, `keyInjectAllowed=false`), because moving someone's pointer
|
|
@@ -217,6 +281,93 @@ click. Success is reported as `effect=reported-by-send`, never as "verified". Un
|
|
|
217
281
|
carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
|
|
218
282
|
not a bug.
|
|
219
283
|
|
|
284
|
+
## Desktop actions: launch, clipboard, window (0.7.0)
|
|
285
|
+
|
|
286
|
+
Three capabilities that were missing outright — "you cannot even start a program" was the honest answer
|
|
287
|
+
— and none of them is a door action. They choose no channel, cost no tier, and produce no proof window,
|
|
288
|
+
so they live beside `Invoke-WpmAction` rather than inside it, and the door discipline (point ownership,
|
|
289
|
+
the restore table, the proof window) is not widened by any of them.
|
|
290
|
+
|
|
291
|
+
**`launch` — two switches, neither of which implies the other.** `appLaunchAllowed` opens the
|
|
292
|
+
capability; `appLaunchAllow` lists the exact program names or absolute paths that may run, and an
|
|
293
|
+
**empty list means nothing may launch even with the gate on**. Matching is exact and case-folded: there
|
|
294
|
+
is no wildcard, and `notepad` does not authorise `notepad-helper.exe` — a whitelist that grows by prefix
|
|
295
|
+
is a whitelist that authorises more than it says. A refusal is `app_launch_denied` and is raised before
|
|
296
|
+
any worker request, so a refused launch started nothing (asserted with a request counter in
|
|
297
|
+
`test/plugin-test.mjs` and re-checked inside the engine against the same table). The engine's own
|
|
298
|
+
vocabulary for the window is the interesting part: `Process.Start` returns while the app is still
|
|
299
|
+
loading (measured: `MainWindowHandle=0` for 1348 ms on a cold notepad), so a program that has not
|
|
300
|
+
published a window yet answers `ok:true` with `hwnd=""` and `detail=window-not-yet` — neither a fake
|
|
301
|
+
failure nor a fake readiness. Arguments are passed through as given and written to the audit log,
|
|
302
|
+
because listing a program does not vouch for what it is told to do.
|
|
303
|
+
|
|
304
|
+
**`clipboard` — the most private read in this product.** What is on the clipboard may be a password or
|
|
305
|
+
a token the owner copied seconds ago, so a text read reports its **length**, its result text never
|
|
306
|
+
contains the payload, the audit line records `op`/`format`/`chars`, and values are capped at 64 KB with
|
|
307
|
+
`truncated` stated rather than silently cut. An image write accepts a `shotId`, so a screenshot can go
|
|
308
|
+
straight into the clipboard without the caller handling pixels; the read-back compares the size the
|
|
309
|
+
clipboard reports against the size the shot recorded. A clipboard holding neither is refused with the
|
|
310
|
+
format names it did find — an empty success would be indistinguishable from "the clipboard is empty".
|
|
311
|
+
|
|
312
|
+
**`window` — one named window, five ops, each verified by reading the window back.** `IsIconic`,
|
|
313
|
+
`GetWindowRect`, the `WS_EX_TOPMOST` bit — not `ShowWindow`'s return value, because a syscall's answer
|
|
314
|
+
describes the CALL and this product has been burned repeatedly by reporting that as a state. `move` and
|
|
315
|
+
`resize` pass `SWP_NOACTIVATE`, and the result carries `foregroundTaken=true|false` measured on both
|
|
316
|
+
sides of that specific call: `restore` activates by definition (that is what restoring is), and the
|
|
317
|
+
honest answer is to report it, not to hide it or to refuse the op the caller asked for. There is no
|
|
318
|
+
"all windows" op and no `#32770` discovery: acting on a window nobody named is not a convenience.
|
|
319
|
+
|
|
320
|
+
### One ceiling, eleven actions
|
|
321
|
+
|
|
322
|
+
The old shape of this problem was a boolean per capability, which does not scale past the number of
|
|
323
|
+
settings anyone will actually read. Instead the two axes are independent:
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
the action declares the lowest rung it can ever need (src/schema/tools.json#requiresTier)
|
|
327
|
+
the owner sets one ceiling (settings: policy)
|
|
328
|
+
|
|
329
|
+
readonly < quiet < flash < takeover
|
|
330
|
+
reads message bounded-UIA real cursor / held focus / launch
|
|
331
|
+
door flash
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
| `policy` | permits | refuses |
|
|
335
|
+
|---|---|---|
|
|
336
|
+
| `readonly` | `windows`, `status`, `snapshot`, `screenshot`, `preview`, `clipboard` read | every write |
|
|
337
|
+
| `quiet` | + `click` / `type` / `focus` through the message door | the flash tier, `clipboard` write, `window`, `launch` |
|
|
338
|
+
| `balanced` *(default)* | + the bounded-flash tier, `clipboard` write, `window` ops | `takeover:true`, `keyInput:"inject"`, `launch` |
|
|
339
|
+
| `full` | + the takeover tier and `launch` | nothing extra |
|
|
340
|
+
|
|
341
|
+
Above the ceiling a call is refused with **`policy_denied`** and the reason names both numbers (what the
|
|
342
|
+
action needed, what the policy allows), because the correct next step is a settings change and the wrong
|
|
343
|
+
one is a retry. The gate order is `paused → policy → takeoverAllowed/keyInjectAllowed → launch gate +
|
|
344
|
+
whitelist → idle check → the door table`, and every step in it is tested by making two gates disagree
|
|
345
|
+
about which one spoke (`test/plugin-test.mjs`). Two consequences are worth stating plainly rather than
|
|
346
|
+
leaving to discovery: **`takeover:true` now needs `policy:'full'` as well as `takeoverAllowed`** (0.7.0
|
|
347
|
+
raised the bar for the loudest tier on purpose), and `clipboard`'s halves are graded separately
|
|
348
|
+
(`requiresTierFor`), so a `readonly` owner can still read.
|
|
349
|
+
|
|
350
|
+
**Idle instead of a dialog.** When the last *physical* input is younger than `policyIdleMs` (default
|
|
351
|
+
3000 ms) and the action needs the takeover tier, it is refused with **`user_active`** and nothing is
|
|
352
|
+
clicked — no popup, no countdown. The upstream design asks the owner to consent by interrupting them;
|
|
353
|
+
an interrupt presented as consent is just a second disturbance. The escape hatch is explicit
|
|
354
|
+
(`forceUserActive:true`), it does not bypass any other gate, and the audit line records `forced:true` so
|
|
355
|
+
an interruption caused on purpose stays distinguishable from one caused by accident. An unattended run
|
|
356
|
+
is never blocked by this: with nobody typing, the age grows past the window and the call goes through.
|
|
357
|
+
|
|
358
|
+
### The audit log
|
|
359
|
+
|
|
360
|
+
Every action appends one JSONL line to `%LOCALAPPDATA%\wpm\audit.log` — allow **and** deny, because a
|
|
361
|
+
trail that records only refusals documents the times the guard worked and is silent about the times it
|
|
362
|
+
had nothing to do with. Fields: `ts, action, hwnd, tier, policy, decision, code, userActiveAgeMs,
|
|
363
|
+
effect, latencyMs`, plus `target`/`args` for a launch and `op`/`format`/`chars` for a clipboard call.
|
|
364
|
+
What is deliberately absent is content: no typed text, no clipboard payload — the second copy of a
|
|
365
|
+
secret is the one nobody protects. `auditKeep` (default 2000) bounds the file, pruning oldest-first when
|
|
366
|
+
a write pushes it past budget. An audit that cannot be written is reported (`auditNote=n write(s)
|
|
367
|
+
failed`) rather than swallowed: a log that looks complete and is not is worse than one that admits it
|
|
368
|
+
is missing lines. This is the only artifact that survives a call, and it is the one thing that can
|
|
369
|
+
answer "what did the agent do to this machine" after the fact.
|
|
370
|
+
|
|
220
371
|
## What it does not do
|
|
221
372
|
|
|
222
373
|
- **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
|
|
@@ -253,8 +404,10 @@ degradation.
|
|
|
253
404
|
## Typed surface
|
|
254
405
|
|
|
255
406
|
`types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
|
|
256
|
-
contract: the
|
|
257
|
-
|
|
407
|
+
contract: the eleven actions, every argument including the takeover fields, the image-space / label
|
|
408
|
+
surface, 0.6.0's `caretPosition` and 0.7.0's `target`/`op`/`format`/`forceUserActive`, all seventeen
|
|
409
|
+
refusal codes as a closed union, and `effect` as its own four-value union (`WpmEffect`) beside
|
|
410
|
+
`WpmCaptureBackend`, `WpmClipboardOp`, `WpmWindowOp`, `WpmPolicy` and `WpmFrameSource`.
|
|
258
411
|
|
|
259
412
|
Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
|
|
260
413
|
presence of a file:
|
|
@@ -289,6 +442,11 @@ when one is present, and the gate reports a named SKIP rather than a red when on
|
|
|
289
442
|
| `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
|
|
290
443
|
| `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
444
|
| `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
|
|
445
|
+
| `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` |
|
|
446
|
+
| `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 |
|
|
447
|
+
| `appLaunchAllowed` | `false` | allow `action=launch` at all. Independent of `takeoverAllowed`: being allowed to move a pointer is not being allowed to start a program |
|
|
448
|
+
| `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 |
|
|
449
|
+
| `auditKeep` | `2000` | how many lines `%LOCALAPPDATA%\wpm\audit.log` holds before the oldest are pruned |
|
|
292
450
|
|
|
293
451
|
## What measurement established
|
|
294
452
|
|
|
@@ -350,6 +508,59 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
|
|
|
350
508
|
`WindowFromPoint` no longer returning the HUD, and `HTCLIENT` on the button. That is what
|
|
351
509
|
`hud.ps1` ships.
|
|
352
510
|
|
|
511
|
+
### 0.6.0's measurements (all re-runnable, probe scripts under `.tmp/` in the repository)
|
|
512
|
+
|
|
513
|
+
- **The read-back exists and is truthful** — three window classes (`Edit`,
|
|
514
|
+
`WindowsForms10.EDIT.app.*`, `WindowsForms10.RichEdit20W.app.*`) all return the written value through
|
|
515
|
+
`WM_GETTEXT` cross-process, and in four cases the value equals what the *application* reported about
|
|
516
|
+
itself from inside its own process (168–241 ms to observe, on the app's 400 ms timer).
|
|
517
|
+
- **A password field reports a length but no text** — `ES_PASSWORD`: `WM_GETTEXT` returns the empty
|
|
518
|
+
string while `WM_GETTEXTLENGTH` returns the real length. Hence `readback=unavailable`, never "empty".
|
|
519
|
+
- **`EM_SETSEL(-1,-1)` does not mean "the end" on WinForms EDIT** — the selection stayed `0,0` and the
|
|
520
|
+
typed character went to the front; `EM_SETSEL(len,len)` gave `abcY`. On a buffer holding `CRLF` the
|
|
521
|
+
numeric end landed at `4,4` for a reported length of `6` — measured, therefore reported as
|
|
522
|
+
`asked=`/`applied=` rather than papered over. A plain Win32 `EDIT` that never held focus accepts every
|
|
523
|
+
`WM_CHAR` and changes nothing, even with `ES_NOHIDESEL`: the case the old `reported-by-send` was
|
|
524
|
+
laundering, and the reason this batch exists.
|
|
525
|
+
- **A read-only edit refuses `WM_CHAR` and honours `WM_SETTEXT`** — the falsification arm of
|
|
526
|
+
`test/readback-truth.mjs`, chosen over two candidates that measurement eliminated (a bare `LF` is
|
|
527
|
+
preserved verbatim, so it agrees; WinForms enforces `MaxLength` in its own `WM_CHAR` handler, so a
|
|
528
|
+
programmatic `WM_SETTEXT` bypasses it, as does `EM_SETLIMITTEXT` set from outside).
|
|
529
|
+
- **BitBlt halves the capture and leaves the bottleneck where it is** — 16–21 ms against 22–33 ms for a
|
|
530
|
+
1920×1080 grab, PNG encode 37–39 ms in both paths, capture+encode 12–16 ms on a 642×432 window. JPEG
|
|
531
|
+
(6 ms) and WIC (158 ms) measured and rejected, 24bpp measured at 7 % of the size and rejected.
|
|
532
|
+
- **`replace:true` threw on every target until 0.6.0** — the `WM_SETTEXT` binding was declared as
|
|
533
|
+
`SendMessageStrW`, an export `user32.dll` does not have: the call raised
|
|
534
|
+
`EntryPointNotFoundException` on first use and surfaced as `action_failed`. No test in the repository
|
|
535
|
+
exercised `replace:true` through the message door, which is why the fix ships with an arm that does
|
|
536
|
+
(`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
|
|
537
|
+
|
|
538
|
+
### 0.7.0's measurements
|
|
539
|
+
|
|
540
|
+
- **A cold `Process.Start` has no window for over a second** — notepad: pid present,
|
|
541
|
+
`MainWindowHandle=0`, **1348 ms**, and the window only reachable by polling the pid. Hence
|
|
542
|
+
`waitMs`/`window-not-yet` rather than an hwnd claim at return time.
|
|
543
|
+
- **The STA clipboard works in the worker and is not instant** — text write+read identical, first call
|
|
544
|
+
**138 ms**; `SetDataObject`/`GetDataObject` for images (40×20 verified). `Clipboard.Flush()` does NOT
|
|
545
|
+
exist on Windows PowerShell 5.1's runtime (.NET Framework): the first version of this branch threw
|
|
546
|
+
"Clipboard does not contain a method named 'Flush'", which is a method present in the documentation
|
|
547
|
+
people read and absent from the platform the product targets. `SetDataObject($v, $true)` is the
|
|
548
|
+
supported way to make the data outlive the process.
|
|
549
|
+
- **`SW_RESTORE` activates.** Measured around a restore on a real notepad window:
|
|
550
|
+
`foregroundBefore=<other> foregroundAfter=<target>`. Reported as `foregroundTaken=true` on that call
|
|
551
|
+
instead of being attributed to something else; `move`/`resize`/`topmost` measured
|
|
552
|
+
`foregroundTaken=false` with `SWP_NOACTIVATE`.
|
|
553
|
+
- **The whitelist is only a whitelist if it is exact.** `notepad` against `notepad-helper.exe`: a
|
|
554
|
+
prefix or substring rule authorises the second one, so membership is a case-folded full-string test
|
|
555
|
+
and `test/plugin-test.mjs` asserts the refusal for an unlisted name while the gate is on.
|
|
556
|
+
- **The refusal vocabulary is unchanged in shape by `requiresTier`** — a rung comparison is arithmetic
|
|
557
|
+
over one ordered list, so the cost of an action's classification is one number, not one new code per
|
|
558
|
+
action. Three codes were added for the whole batch (`app_launch_denied`, `policy_denied`,
|
|
559
|
+
`user_active`), each naming a setting rather than a symptom.
|
|
560
|
+
- `Check-no-cursor-control` is still green with the same two whitelisted primitive uses and an
|
|
561
|
+
unchanged whitelist file list: adding `launch`/`window` did not open a door to `MOUSEEVENTF_*`,
|
|
562
|
+
`mouse_event` or `keybd_event`.
|
|
563
|
+
|
|
353
564
|
## Verifying the copy you actually installed
|
|
354
565
|
|
|
355
566
|
Every test above imports the repository checkout, so a package that installs to the wrong place or ships
|