dsh-windows-parallel-mcp 0.6.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/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.6.0** — this document describes the contract as of that version. What
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 fourteen and the next step.
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, eight actions:
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
 
@@ -278,6 +281,93 @@ click. Success is reported as `effect=reported-by-send`, never as "verified". Un
278
281
  carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
279
282
  not a bug.
280
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
+
281
371
  ## What it does not do
282
372
 
283
373
  - **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
@@ -314,9 +404,10 @@ degradation.
314
404
  ## Typed surface
315
405
 
316
406
  `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
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`.
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`.
320
411
 
321
412
  Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
322
413
  presence of a file:
@@ -351,6 +442,11 @@ when one is present, and the gate reports a named SKIP rather than a red when on
351
442
  | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
352
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 |
353
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 |
354
450
 
355
451
  ## What measurement established
356
452
 
@@ -439,6 +535,32 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
439
535
  exercised `replace:true` through the message door, which is why the fix ships with an arm that does
440
536
  (`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
441
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
+
442
564
  ## Verifying the copy you actually installed
443
565
 
444
566
  Every test above imports the repository checkout, so a package that installs to the wrong place or ships
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.6.0** — this document describes the contract as of that version. What
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 fourteen and the next step.
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, eight actions:
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
 
@@ -278,6 +281,93 @@ click. Success is reported as `effect=reported-by-send`, never as "verified". Un
278
281
  carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
279
282
  not a bug.
280
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
+
281
371
  ## What it does not do
282
372
 
283
373
  - **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
@@ -314,9 +404,10 @@ degradation.
314
404
  ## Typed surface
315
405
 
316
406
  `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
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`.
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`.
320
411
 
321
412
  Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
322
413
  presence of a file:
@@ -351,6 +442,11 @@ when one is present, and the gate reports a named SKIP rather than a red when on
351
442
  | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
352
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 |
353
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 |
354
450
 
355
451
  ## What measurement established
356
452
 
@@ -439,6 +535,32 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
439
535
  exercised `replace:true` through the message door, which is why the fix ships with an arm that does
440
536
  (`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
441
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
+
442
564
  ## Verifying the copy you actually installed
443
565
 
444
566
  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.6.0** — this document describes the contract as of that version. What
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 fourteen and the next step.
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, eight actions:
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
 
@@ -278,6 +281,93 @@ click. Success is reported as `effect=reported-by-send`, never as "verified". Un
278
281
  carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
279
282
  not a bug.
280
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
+
281
371
  ## What it does not do
282
372
 
283
373
  - **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
@@ -314,9 +404,10 @@ degradation.
314
404
  ## Typed surface
315
405
 
316
406
  `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
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`.
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`.
320
411
 
321
412
  Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
322
413
  presence of a file:
@@ -351,6 +442,11 @@ when one is present, and the gate reports a named SKIP rather than a red when on
351
442
  | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
352
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 |
353
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 |
354
450
 
355
451
  ## What measurement established
356
452
 
@@ -439,6 +535,32 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
439
535
  exercised `replace:true` through the message door, which is why the fix ships with an arm that does
440
536
  (`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
441
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
+
442
564
  ## Verifying the copy you actually installed
443
565
 
444
566
  Every test above imports the repository checkout, so a package that installs to the wrong place or ships