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.ja.md CHANGED
@@ -5,7 +5,7 @@
5
5
  > エージェントが**自分の** Windows ウィンドウを操作するための DSH プラグインです。既定では静默、要求があれば可視化します。ウィンドウがウィンドウメッセージを受け付ける場合、フォーカスは一切奪われません。UI Automation 経由でしか届かない場合、フォーカスは一度だけ有界なフラッシュで移り自動で戻ります。明示的にテイクオーバーを要求した場合、カーソルは操作点へ移動し常に復元され、HUD が三つの中断手段を提供します。それ以外はコードと理由を添えて拒否します。
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.ko.md CHANGED
@@ -5,7 +5,7 @@
5
5
  > 에이전트가 **자신의** Windows 창을 조작하도록 하는 DSH 플러그인입니다. 기본은 조용히, 요청 시에는 눈에 보이게 동작합니다. 창이 창 메시지를 받으면 포커스를 전혀 빼앗지 않고, UI Automation으로만 도달 가능하면 포커스가 한 번의 제한된 플래시로 이동한 뒤 자동 복구됩니다. 테이크오버를 명시적으로 요청하면 커서가 동작 지점으로 이동해 항상 복원되며 HUD가 세 가지 중단 수단을 제공합니다. 그 밖의 경우에는 코드와 이유를 붙여 거부합니다.
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.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # dsh-windows-parallel-mcp
2
2
 
3
3
  **English** · [中文](README.zh.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Italiano](README.it.md) · [Español](README.es.md) · [Português](README.pt.md) · [Русский](README.ru.md)
4
- > **Current release: 0.6.0** — this document describes the contract as of that version. What
4
+ > **Current release: 0.7.0** — this document describes the contract as of that version. What
5
5
  > changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
6
6
 
7
7
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
@@ -9,7 +9,7 @@ on request. Where a window accepts a window message, you never lose focus at all
9
9
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
10
10
  explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
11
11
  HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason — never with
12
- silence: every refusal carries a code from a closed set of fourteen and the next step.
12
+ silence: every refusal carries a code from a closed set of seventeen and the next step.
13
13
 
14
14
  **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
15
15
  opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
@@ -27,7 +27,7 @@ bundle with a broad tool surface; this one is a single action tool whose entire
27
27
 
28
28
  ## What it does
29
29
 
30
- One tool, eight actions:
30
+ One tool, eleven actions:
31
31
 
32
32
  | action | what it returns |
33
33
  |---|---|
@@ -39,6 +39,9 @@ One tool, eight actions:
39
39
  | `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
40
40
  | `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
41
41
  | `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
42
+ | `launch` | start a whitelisted program; reports the pid, and the window only once it really exists |
43
+ | `clipboard` | read or write the system clipboard — a read reports lengths and never the payload |
44
+ | `window` | minimize / restore / move / resize / topmost ONE named window, verified by reading its state back |
42
45
 
43
46
  The engine picks the cheapest available door per call:
44
47
 
@@ -274,6 +277,93 @@ click. Success is reported as `effect=reported-by-send`, never as "verified". Un
274
277
  carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
275
278
  not a bug.
276
279
 
280
+ ## Desktop actions: launch, clipboard, window (0.7.0)
281
+
282
+ Three capabilities that were missing outright — "you cannot even start a program" was the honest answer
283
+ — and none of them is a door action. They choose no channel, cost no tier, and produce no proof window,
284
+ so they live beside `Invoke-WpmAction` rather than inside it, and the door discipline (point ownership,
285
+ the restore table, the proof window) is not widened by any of them.
286
+
287
+ **`launch` — two switches, neither of which implies the other.** `appLaunchAllowed` opens the
288
+ capability; `appLaunchAllow` lists the exact program names or absolute paths that may run, and an
289
+ **empty list means nothing may launch even with the gate on**. Matching is exact and case-folded: there
290
+ is no wildcard, and `notepad` does not authorise `notepad-helper.exe` — a whitelist that grows by prefix
291
+ is a whitelist that authorises more than it says. A refusal is `app_launch_denied` and is raised before
292
+ any worker request, so a refused launch started nothing (asserted with a request counter in
293
+ `test/plugin-test.mjs` and re-checked inside the engine against the same table). The engine's own
294
+ vocabulary for the window is the interesting part: `Process.Start` returns while the app is still
295
+ loading (measured: `MainWindowHandle=0` for 1348 ms on a cold notepad), so a program that has not
296
+ published a window yet answers `ok:true` with `hwnd=""` and `detail=window-not-yet` — neither a fake
297
+ failure nor a fake readiness. Arguments are passed through as given and written to the audit log,
298
+ because listing a program does not vouch for what it is told to do.
299
+
300
+ **`clipboard` — the most private read in this product.** What is on the clipboard may be a password or
301
+ a token the owner copied seconds ago, so a text read reports its **length**, its result text never
302
+ contains the payload, the audit line records `op`/`format`/`chars`, and values are capped at 64 KB with
303
+ `truncated` stated rather than silently cut. An image write accepts a `shotId`, so a screenshot can go
304
+ straight into the clipboard without the caller handling pixels; the read-back compares the size the
305
+ clipboard reports against the size the shot recorded. A clipboard holding neither is refused with the
306
+ format names it did find — an empty success would be indistinguishable from "the clipboard is empty".
307
+
308
+ **`window` — one named window, five ops, each verified by reading the window back.** `IsIconic`,
309
+ `GetWindowRect`, the `WS_EX_TOPMOST` bit — not `ShowWindow`'s return value, because a syscall's answer
310
+ describes the CALL and this product has been burned repeatedly by reporting that as a state. `move` and
311
+ `resize` pass `SWP_NOACTIVATE`, and the result carries `foregroundTaken=true|false` measured on both
312
+ sides of that specific call: `restore` activates by definition (that is what restoring is), and the
313
+ honest answer is to report it, not to hide it or to refuse the op the caller asked for. There is no
314
+ "all windows" op and no `#32770` discovery: acting on a window nobody named is not a convenience.
315
+
316
+ ### One ceiling, eleven actions
317
+
318
+ The old shape of this problem was a boolean per capability, which does not scale past the number of
319
+ settings anyone will actually read. Instead the two axes are independent:
320
+
321
+ ```
322
+ the action declares the lowest rung it can ever need (src/schema/tools.json#requiresTier)
323
+ the owner sets one ceiling (settings: policy)
324
+
325
+ readonly < quiet < flash < takeover
326
+ reads message bounded-UIA real cursor / held focus / launch
327
+ door flash
328
+ ```
329
+
330
+ | `policy` | permits | refuses |
331
+ |---|---|---|
332
+ | `readonly` | `windows`, `status`, `snapshot`, `screenshot`, `preview`, `clipboard` read | every write |
333
+ | `quiet` | + `click` / `type` / `focus` through the message door | the flash tier, `clipboard` write, `window`, `launch` |
334
+ | `balanced` *(default)* | + the bounded-flash tier, `clipboard` write, `window` ops | `takeover:true`, `keyInput:"inject"`, `launch` |
335
+ | `full` | + the takeover tier and `launch` | nothing extra |
336
+
337
+ Above the ceiling a call is refused with **`policy_denied`** and the reason names both numbers (what the
338
+ action needed, what the policy allows), because the correct next step is a settings change and the wrong
339
+ one is a retry. The gate order is `paused → policy → takeoverAllowed/keyInjectAllowed → launch gate +
340
+ whitelist → idle check → the door table`, and every step in it is tested by making two gates disagree
341
+ about which one spoke (`test/plugin-test.mjs`). Two consequences are worth stating plainly rather than
342
+ leaving to discovery: **`takeover:true` now needs `policy:'full'` as well as `takeoverAllowed`** (0.7.0
343
+ raised the bar for the loudest tier on purpose), and `clipboard`'s halves are graded separately
344
+ (`requiresTierFor`), so a `readonly` owner can still read.
345
+
346
+ **Idle instead of a dialog.** When the last *physical* input is younger than `policyIdleMs` (default
347
+ 3000 ms) and the action needs the takeover tier, it is refused with **`user_active`** and nothing is
348
+ clicked — no popup, no countdown. The upstream design asks the owner to consent by interrupting them;
349
+ an interrupt presented as consent is just a second disturbance. The escape hatch is explicit
350
+ (`forceUserActive:true`), it does not bypass any other gate, and the audit line records `forced:true` so
351
+ an interruption caused on purpose stays distinguishable from one caused by accident. An unattended run
352
+ is never blocked by this: with nobody typing, the age grows past the window and the call goes through.
353
+
354
+ ### The audit log
355
+
356
+ Every action appends one JSONL line to `%LOCALAPPDATA%\wpm\audit.log` — allow **and** deny, because a
357
+ trail that records only refusals documents the times the guard worked and is silent about the times it
358
+ had nothing to do with. Fields: `ts, action, hwnd, tier, policy, decision, code, userActiveAgeMs,
359
+ effect, latencyMs`, plus `target`/`args` for a launch and `op`/`format`/`chars` for a clipboard call.
360
+ What is deliberately absent is content: no typed text, no clipboard payload — the second copy of a
361
+ secret is the one nobody protects. `auditKeep` (default 2000) bounds the file, pruning oldest-first when
362
+ a write pushes it past budget. An audit that cannot be written is reported (`auditNote=n write(s)
363
+ failed`) rather than swallowed: a log that looks complete and is not is worse than one that admits it
364
+ is missing lines. This is the only artifact that survives a call, and it is the one thing that can
365
+ answer "what did the agent do to this machine" after the fact.
366
+
277
367
  ## What it does not do
278
368
 
279
369
  - **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
@@ -310,9 +400,10 @@ degradation.
310
400
  ## Typed surface
311
401
 
312
402
  `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
313
- contract: the eight actions, every argument including the takeover fields, the image-space / label
314
- surface and 0.6.0's `caretPosition`, all fourteen refusal codes as a closed union, and `effect` as its
315
- own four-value union (`WpmEffect`) beside `WpmCaptureBackend` and `WpmFrameSource`.
403
+ contract: the eleven actions, every argument including the takeover fields, the image-space / label
404
+ surface, 0.6.0's `caretPosition` and 0.7.0's `target`/`op`/`format`/`forceUserActive`, all seventeen
405
+ refusal codes as a closed union, and `effect` as its own four-value union (`WpmEffect`) beside
406
+ `WpmCaptureBackend`, `WpmClipboardOp`, `WpmWindowOp`, `WpmPolicy` and `WpmFrameSource`.
316
407
 
317
408
  Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
318
409
  presence of a file:
@@ -347,6 +438,11 @@ when one is present, and the gate reports a named SKIP rather than a red when on
347
438
  | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
348
439
  | `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 |
349
440
  | `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
441
+ | `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` |
442
+ | `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 |
443
+ | `appLaunchAllowed` | `false` | allow `action=launch` at all. Independent of `takeoverAllowed`: being allowed to move a pointer is not being allowed to start a program |
444
+ | `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 |
445
+ | `auditKeep` | `2000` | how many lines `%LOCALAPPDATA%\wpm\audit.log` holds before the oldest are pruned |
350
446
 
351
447
  ## What measurement established
352
448
 
@@ -435,6 +531,32 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
435
531
  exercised `replace:true` through the message door, which is why the fix ships with an arm that does
436
532
  (`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
437
533
 
534
+ ### 0.7.0's measurements
535
+
536
+ - **A cold `Process.Start` has no window for over a second** — notepad: pid present,
537
+ `MainWindowHandle=0`, **1348 ms**, and the window only reachable by polling the pid. Hence
538
+ `waitMs`/`window-not-yet` rather than an hwnd claim at return time.
539
+ - **The STA clipboard works in the worker and is not instant** — text write+read identical, first call
540
+ **138 ms**; `SetDataObject`/`GetDataObject` for images (40×20 verified). `Clipboard.Flush()` does NOT
541
+ exist on Windows PowerShell 5.1's runtime (.NET Framework): the first version of this branch threw
542
+ "Clipboard does not contain a method named 'Flush'", which is a method present in the documentation
543
+ people read and absent from the platform the product targets. `SetDataObject($v, $true)` is the
544
+ supported way to make the data outlive the process.
545
+ - **`SW_RESTORE` activates.** Measured around a restore on a real notepad window:
546
+ `foregroundBefore=<other> foregroundAfter=<target>`. Reported as `foregroundTaken=true` on that call
547
+ instead of being attributed to something else; `move`/`resize`/`topmost` measured
548
+ `foregroundTaken=false` with `SWP_NOACTIVATE`.
549
+ - **The whitelist is only a whitelist if it is exact.** `notepad` against `notepad-helper.exe`: a
550
+ prefix or substring rule authorises the second one, so membership is a case-folded full-string test
551
+ and `test/plugin-test.mjs` asserts the refusal for an unlisted name while the gate is on.
552
+ - **The refusal vocabulary is unchanged in shape by `requiresTier`** — a rung comparison is arithmetic
553
+ over one ordered list, so the cost of an action's classification is one number, not one new code per
554
+ action. Three codes were added for the whole batch (`app_launch_denied`, `policy_denied`,
555
+ `user_active`), each naming a setting rather than a symptom.
556
+ - `Check-no-cursor-control` is still green with the same two whitelisted primitive uses and an
557
+ unchanged whitelist file list: adding `launch`/`window` did not open a door to `MOUSEEVENTF_*`,
558
+ `mouse_event` or `keybd_event`.
559
+
438
560
  ## Verifying the copy you actually installed
439
561
 
440
562
  Every test above imports the repository checkout, so a package that installs to the wrong place or ships