dsh-windows-parallel-mcp 0.6.0 → 0.8.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.de.md CHANGED
@@ -5,7 +5,7 @@
5
5
  > Ein DSH-Plugin, mit dem ein Agent **seine eigenen** Windows-Fenster steuert — standardmäßig still, auf Anfrage sichtbar. Wenn ein Fenster Windows-Nachrichten akzeptiert, wird der Fokus nie entzogen. Wenn nur UI Automation es erreicht, gibt es einen einzigen begrenzten Fokus-Blitz, der automatisch rückgängig gemacht wird. Wenn Sie den Takeover-Modus ausdrücklich anfordern, bewegt sich der Cursor zum Aktionspunkt und wird immer wiederhergestellt; ein HUD bietet drei Möglichkeiten zum Abbruch. Überall anders wird mit Code und Grund abgelehnt.
6
6
 
7
7
  > **English canonical text follows.** The localized summary above is the orientation; the text below is the authoritative specification (structure, commands and numbers are identical across all 10 languages).
8
- > **Current release: 0.6.0** — this document describes the contract as of that version. What
8
+ > **Current release: 0.8.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,12 @@ 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
+
18
+ **It ships in two forms over one engine, and 0.8.0 did not replace the first one.** Inside DSH it is a
19
+ plugin (`apply()` on the host half, PowerShell sidecar underneath). Outside it, the same package is an
20
+ MCP server over stdio (`bin: wpm-mcp`), whose tool list is generated from the same contract file — see
21
+ "The second form" below.
17
22
 
18
23
  **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
24
  opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
@@ -31,7 +36,7 @@ bundle with a broad tool surface; this one is a single action tool whose entire
31
36
 
32
37
  ## What it does
33
38
 
34
- One tool, eight actions:
39
+ One tool, eleven actions:
35
40
 
36
41
  | action | what it returns |
37
42
  |---|---|
@@ -43,6 +48,9 @@ One tool, eight actions:
43
48
  | `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
44
49
  | `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
45
50
  | `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
51
+ | `launch` | start a whitelisted program; reports the pid, and the window only once it really exists |
52
+ | `clipboard` | read or write the system clipboard — a read reports lengths and never the payload |
53
+ | `window` | minimize / restore / move / resize / topmost ONE named window, verified by reading its state back |
46
54
 
47
55
  The engine picks the cheapest available door per call:
48
56
 
@@ -278,6 +286,138 @@ click. Success is reported as `effect=reported-by-send`, never as "verified". Un
278
286
  carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
279
287
  not a bug.
280
288
 
289
+ ## Desktop actions: launch, clipboard, window (0.7.0)
290
+
291
+ Three capabilities that were missing outright — "you cannot even start a program" was the honest answer
292
+ — and none of them is a door action. They choose no channel, cost no tier, and produce no proof window,
293
+ so they live beside `Invoke-WpmAction` rather than inside it, and the door discipline (point ownership,
294
+ the restore table, the proof window) is not widened by any of them.
295
+
296
+ **`launch` — two switches, neither of which implies the other.** `appLaunchAllowed` opens the
297
+ capability; `appLaunchAllow` lists the exact program names or absolute paths that may run, and an
298
+ **empty list means nothing may launch even with the gate on**. Matching is exact and case-folded: there
299
+ is no wildcard, and `notepad` does not authorise `notepad-helper.exe` — a whitelist that grows by prefix
300
+ is a whitelist that authorises more than it says. A refusal is `app_launch_denied` and is raised before
301
+ any worker request, so a refused launch started nothing (asserted with a request counter in
302
+ `test/plugin-test.mjs` and re-checked inside the engine against the same table). The engine's own
303
+ vocabulary for the window is the interesting part: `Process.Start` returns while the app is still
304
+ loading (measured: `MainWindowHandle=0` for 1348 ms on a cold notepad), so a program that has not
305
+ published a window yet answers `ok:true` with `hwnd=""` and `detail=window-not-yet` — neither a fake
306
+ failure nor a fake readiness. Arguments are passed through as given and written to the audit log,
307
+ because listing a program does not vouch for what it is told to do.
308
+
309
+ **`clipboard` — the most private read in this product.** What is on the clipboard may be a password or
310
+ a token the owner copied seconds ago, so a text read reports its **length**, its result text never
311
+ contains the payload, the audit line records `op`/`format`/`chars`, and values are capped at 64 KB with
312
+ `truncated` stated rather than silently cut. An image write accepts a `shotId`, so a screenshot can go
313
+ straight into the clipboard without the caller handling pixels; the read-back compares the size the
314
+ clipboard reports against the size the shot recorded. A clipboard holding neither is refused with the
315
+ format names it did find — an empty success would be indistinguishable from "the clipboard is empty".
316
+
317
+ **`window` — one named window, five ops, each verified by reading the window back.** `IsIconic`,
318
+ `GetWindowRect`, the `WS_EX_TOPMOST` bit — not `ShowWindow`'s return value, because a syscall's answer
319
+ describes the CALL and this product has been burned repeatedly by reporting that as a state. `move` and
320
+ `resize` pass `SWP_NOACTIVATE`, and the result carries `foregroundTaken=true|false` measured on both
321
+ sides of that specific call: `restore` activates by definition (that is what restoring is), and the
322
+ honest answer is to report it, not to hide it or to refuse the op the caller asked for. There is no
323
+ "all windows" op and no `#32770` discovery: acting on a window nobody named is not a convenience.
324
+
325
+ ### One ceiling, eleven actions
326
+
327
+ The old shape of this problem was a boolean per capability, which does not scale past the number of
328
+ settings anyone will actually read. Instead the two axes are independent:
329
+
330
+ ```
331
+ the action declares the lowest rung it can ever need (src/schema/tools.json#requiresTier)
332
+ the owner sets one ceiling (settings: policy)
333
+
334
+ readonly < quiet < flash < takeover
335
+ reads message bounded-UIA real cursor / held focus / launch
336
+ door flash
337
+ ```
338
+
339
+ | `policy` | permits | refuses |
340
+ |---|---|---|
341
+ | `readonly` | `windows`, `status`, `snapshot`, `screenshot`, `preview`, `clipboard` read | every write |
342
+ | `quiet` | + `click` / `type` / `focus` through the message door | the flash tier, `clipboard` write, `window`, `launch` |
343
+ | `balanced` *(default)* | + the bounded-flash tier, `clipboard` write, `window` ops | `takeover:true`, `keyInput:"inject"`, `launch` |
344
+ | `full` | + the takeover tier and `launch` | nothing extra |
345
+
346
+ Above the ceiling a call is refused with **`policy_denied`** and the reason names both numbers (what the
347
+ action needed, what the policy allows), because the correct next step is a settings change and the wrong
348
+ one is a retry. The gate order is `paused → policy → takeoverAllowed/keyInjectAllowed → launch gate +
349
+ whitelist → idle check → the door table`, and every step in it is tested by making two gates disagree
350
+ about which one spoke (`test/plugin-test.mjs`). Two consequences are worth stating plainly rather than
351
+ leaving to discovery: **`takeover:true` now needs `policy:'full'` as well as `takeoverAllowed`** (0.7.0
352
+ raised the bar for the loudest tier on purpose), and `clipboard`'s halves are graded separately
353
+ (`requiresTierFor`), so a `readonly` owner can still read.
354
+
355
+ **Idle instead of a dialog.** When the last *physical* input is younger than `policyIdleMs` (default
356
+ 3000 ms) and the action needs the takeover tier, it is refused with **`user_active`** and nothing is
357
+ clicked — no popup, no countdown. The upstream design asks the owner to consent by interrupting them;
358
+ an interrupt presented as consent is just a second disturbance. The escape hatch is explicit
359
+ (`forceUserActive:true`), it does not bypass any other gate, and the audit line records `forced:true` so
360
+ an interruption caused on purpose stays distinguishable from one caused by accident. An unattended run
361
+ is never blocked by this: with nobody typing, the age grows past the window and the call goes through.
362
+
363
+ ### The audit log
364
+
365
+ Every action appends one JSONL line to `%LOCALAPPDATA%\wpm\audit.log` — allow **and** deny, because a
366
+ trail that records only refusals documents the times the guard worked and is silent about the times it
367
+ had nothing to do with. Fields: `ts, action, hwnd, tier, policy, decision, code, userActiveAgeMs,
368
+ effect, latencyMs`, plus `target`/`args` for a launch and `op`/`format`/`chars` for a clipboard call.
369
+ What is deliberately absent is content: no typed text, no clipboard payload — the second copy of a
370
+ secret is the one nobody protects. `auditKeep` (default 2000) bounds the file, pruning oldest-first when
371
+ a write pushes it past budget. An audit that cannot be written is reported (`auditNote=n write(s)
372
+ failed`) rather than swallowed: a log that looks complete and is not is worse than one that admits it
373
+ is missing lines. This is the only artifact that survives a call, and it is the one thing that can
374
+ answer "what did the agent do to this machine" after the fact.
375
+
376
+ ## The second form: MCP over stdio (0.8.0)
377
+
378
+ The same plugin is also an MCP server, and it is the same code rather than a re-implementation of it.
379
+ `lib/mcp-server.mjs` registers the tool by calling the very `apply()` the DSH host calls, and forwards
380
+ `tools/call` into the same `toRequest()` / gate order / `format()` path, so the eleven actions, the
381
+ seventeen refusal codes, the policy ceiling and the audit line are identical in both forms. That is why
382
+ the engine files were not touched to add it: a second implementation of a permission is a permission
383
+ that can be reached around by using the other copy.
384
+
385
+ **One tool, not eleven.** `tools/list` exposes `wpm` with an `action` discriminator, generated from
386
+ `src/schema/tools.json` — one `oneOf` branch per action, whose `properties`, `required` and
387
+ `additionalProperties` are that action's declaration copied field for field. Nothing in the server
388
+ spells out an action name, a parameter name or a code, and `scripts/check-mcp-schema.mjs` is the reason
389
+ that stays true: it starts the real server, reads what a client would read, and compares it to the file.
390
+ Its self-test mutates both sides on purpose — four edits to the generator must turn the gate red, and two
391
+ edits to the *contract* (rename a parameter, flip `additionalProperties`) must stay green AND move,
392
+ because an arm that only breaks the generator cannot tell a generated schema from a transcribed one that
393
+ happens to agree today.
394
+
395
+ **Settings come from the environment, never from the call.** `WPM_POLICY`, `WPM_TAKEOVER_ALLOWED`,
396
+ `WPM_APP_LAUNCH_ALLOWED`, `WPM_APP_LAUNCH_ALLOW` and the rest of the `WPM_*` set are read at start-up
397
+ and only if present — the defaults stay in `lib/index.js`, because a second copy of a default is a
398
+ default that drifts. A client that could raise its own ceiling or add itself to the launch whitelist
399
+ would make the authorization model decorative, which is the same reason the DSH form reads settings
400
+ from the profile rather than from the prompt.
401
+
402
+ **A picture is attached as pixels, because a path is not portable.** The DSH form renders the screenshot
403
+ file it wrote; a caller on the other end of a pipe cannot open it, so `tools/call` returns the PNG as
404
+ base64 `image` content alongside the text. The text is never replaced by it — `screenRect`, `scale`,
405
+ `identity`, `frame` and `captureBackend` stay in the first block, and across the DSH bridge, where a
406
+ host that cannot accept image input projects the picture into a text diagnostic, those numbers still
407
+ arrive. `WPM_MCP_NO_IMAGE=1` opts out.
408
+
409
+ **Refusals survive the trip.** A refused call comes back with `isError` and the code as the first token
410
+ of the text, unsoftened. Over the DSH bridge the refusal is re-raised as an error whose message is that
411
+ text, so `policy_denied` still reads as `policy_denied` at the far end — asserted, not assumed, in
412
+ `test/mcp-bridge.mjs`, which drives the SDK and the bridge code the host actually ships.
413
+
414
+ **The transport is the only new attack surface, and it is a pipe.** JSON-RPC 2.0 over stdin/stdout with
415
+ Node built-ins and zero dependencies: one JSON object per line, replies keyed by `id` because the worker
416
+ is asynchronous, notifications answered with nothing, a non-JSON line answered with `-32700` and a null
417
+ `id` without killing the loop, an unknown method answered `-32601` without killing the loop, and stdin
418
+ closing meaning "dispose the sidecar and exit 0". Everything that is not a protocol line goes to stderr
419
+ — `console.log` in the plugin half would otherwise print into the JSON stream and corrupt it.
420
+
281
421
  ## What it does not do
282
422
 
283
423
  - **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
@@ -291,6 +431,10 @@ not a bug.
291
431
  - **No OCR / Set-of-Marks / pixel fallback.** Not part of this claim, and already done well elsewhere.
292
432
  - **No watchdog.** The restore is one-shot and happens inline. A watchdog that keeps chasing the
293
433
  foreground would fight you.
434
+ - **No HTTP, no SSE, no OAuth, no TLS.** Two forms exist and neither has a network face: in-process for
435
+ DSH, stdio for MCP. "No network surface" is not a hardening claim, it is the absence of one — there is
436
+ nothing to authenticate against, nothing to listen on, and nothing that keeps running when the caller
437
+ goes away.
294
438
  - **Terminals are still refused** (`terminal_no_door`), and now for a measured reason. The 0.2.0 plan
295
439
  was to drive one by typing into it; two probes say otherwise on this host: 242 `KEYEVENTF_UNICODE`
296
440
  events with the terminal in the foreground and Enter sent produced nothing, and a scan-code arm
@@ -311,12 +455,29 @@ call, not at plugin load.
311
455
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
312
456
  degradation.
313
457
 
458
+ Since 0.8.0 the same package is also an MCP server, and nothing about the install above changes — the
459
+ two forms are parallel entries, not a migration:
460
+
461
+ ```bash
462
+ # stdio, configured by the environment of whoever starts it
463
+ WPM_POLICY=balanced npx dsh-windows-parallel-mcp # via bin: wpm-mcp
464
+ # or, from a checkout
465
+ node lib/mcp-server.mjs
466
+ ```
467
+
468
+ Point any MCP client at that command; `server.json` (shipped in the tarball) is the MCP Registry
469
+ manifest for it, with the namespace `io.github.drscrewdriver/dsh-windows-parallel-mcp` and the npm
470
+ package as its ownership proof. A DSH profile can bridge it instead of loading the plugin directly
471
+ (`@deepseek-ai/dsh-mcp-client`, stdio transport), which registers the tool as `mcp__<serverName>__wpm`;
472
+ `test/mcp-bridge.mjs` drives that bridge with the host's own client SDK and tool-definition code.
473
+
314
474
  ## Typed surface
315
475
 
316
476
  `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`.
477
+ contract: the eleven actions, every argument including the takeover fields, the image-space / label
478
+ surface, 0.6.0's `caretPosition` and 0.7.0's `target`/`op`/`format`/`forceUserActive`, all seventeen
479
+ refusal codes as a closed union, and `effect` as its own four-value union (`WpmEffect`) beside
480
+ `WpmCaptureBackend`, `WpmClipboardOp`, `WpmWindowOp`, `WpmPolicy` and `WpmFrameSource`.
320
481
 
321
482
  Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
322
483
  presence of a file:
@@ -351,6 +512,11 @@ when one is present, and the gate reports a named SKIP rather than a red when on
351
512
  | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
352
513
  | `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
514
  | `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
515
+ | `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` |
516
+ | `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 |
517
+ | `appLaunchAllowed` | `false` | allow `action=launch` at all. Independent of `takeoverAllowed`: being allowed to move a pointer is not being allowed to start a program |
518
+ | `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 |
519
+ | `auditKeep` | `2000` | how many lines `%LOCALAPPDATA%\wpm\audit.log` holds before the oldest are pruned |
354
520
 
355
521
  ## What measurement established
356
522
 
@@ -439,6 +605,59 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
439
605
  exercised `replace:true` through the message door, which is why the fix ships with an arm that does
440
606
  (`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
441
607
 
608
+ ### 0.7.0's measurements
609
+
610
+ - **A cold `Process.Start` has no window for over a second** — notepad: pid present,
611
+ `MainWindowHandle=0`, **1348 ms**, and the window only reachable by polling the pid. Hence
612
+ `waitMs`/`window-not-yet` rather than an hwnd claim at return time.
613
+ - **The STA clipboard works in the worker and is not instant** — text write+read identical, first call
614
+ **138 ms**; `SetDataObject`/`GetDataObject` for images (40×20 verified). `Clipboard.Flush()` does NOT
615
+ exist on Windows PowerShell 5.1's runtime (.NET Framework): the first version of this branch threw
616
+ "Clipboard does not contain a method named 'Flush'", which is a method present in the documentation
617
+ people read and absent from the platform the product targets. `SetDataObject($v, $true)` is the
618
+ supported way to make the data outlive the process.
619
+ - **`SW_RESTORE` activates.** Measured around a restore on a real notepad window:
620
+ `foregroundBefore=<other> foregroundAfter=<target>`. Reported as `foregroundTaken=true` on that call
621
+ instead of being attributed to something else; `move`/`resize`/`topmost` measured
622
+ `foregroundTaken=false` with `SWP_NOACTIVATE`.
623
+ - **The whitelist is only a whitelist if it is exact.** `notepad` against `notepad-helper.exe`: a
624
+ prefix or substring rule authorises the second one, so membership is a case-folded full-string test
625
+ and `test/plugin-test.mjs` asserts the refusal for an unlisted name while the gate is on.
626
+ - **The refusal vocabulary is unchanged in shape by `requiresTier`** — a rung comparison is arithmetic
627
+ over one ordered list, so the cost of an action's classification is one number, not one new code per
628
+ action. Three codes were added for the whole batch (`app_launch_denied`, `policy_denied`,
629
+ `user_active`), each naming a setting rather than a symptom.
630
+ - `Check-no-cursor-control` is still green with the same two whitelisted primitive uses and an
631
+ unchanged whitelist file list: adding `launch`/`window` did not open a door to `MOUSEEVENTF_*`,
632
+ `mouse_event` or `keybd_event`.
633
+
634
+ ### 0.8.0's measurements
635
+
636
+ - **A hand-written JSON-RPC loop over stdio is enough** (the 0.8.0 prerequisite probe): `initialize`,
637
+ `tools/list` and `tools/call` all answer, an unknown method returns `-32601` and the process survives
638
+ it, a notification produces no reply line, two requests in flight are matchable by id, a non-JSON line
639
+ does not kill the transport, and closing stdin exits 0. Fifteen assertions, zero dependencies —
640
+ `@modelcontextprotocol/sdk` is not needed and is not used.
641
+ - **The host's SDK is the stricter judge than our own harness.** `test/mcp-bridge.mjs` connects
642
+ `@modelcontextprotocol/client` 2.2.0 (the version the DSH install ships) to our server and validates
643
+ the shapes we emit. Its negotiation throws when the server answers with a protocol revision the
644
+ client does not list, which is why `PROTOCOL_VERSIONS` in `lib/mcp-server.mjs` is checked against that
645
+ SDK's constants (latest `2025-11-25`) rather than guessed from a document.
646
+ - **A picture the host cannot display still delivers its numbers.** Across the bridge with no attachment
647
+ store mounted, a `screenshot` call does not throw: the bridge projects the image block into an
648
+ `[image unavailable: …]` text diagnostic and the `screenRect` / `scale` / `identity` / `frame` /
649
+ `captureBackend` line arrives regardless. Attaching pixels by default is safe because of that
650
+ measurement, not in spite of it.
651
+ - **`tools/list` follows the contract file, in both directions.** Renaming `caretPosition` in
652
+ `src/schema/tools.json` changes what the running server reports, and flipping one
653
+ `additionalProperties` changes it too — both are gate arms (`scripts/check-mcp-schema.mjs --self-test`),
654
+ so the claim "generated, not copied" is exercised rather than asserted in prose.
655
+ - **The install artifact is what was tested.** The 0.7.0 release was smoked from the unpacked tarball
656
+ (`npm pack` → unpack → drive the policy ceiling, both launch gates, the clipboard length-not-payload
657
+ rule and the audit rows: 17 assertions) and that run found two things the working tree could not show:
658
+ the `clipboard` headline does not name which op ran, and the launch gate is only observable once the
659
+ ceiling lets the call reach it. Both are recorded rather than papered over.
660
+
442
661
  ## Verifying the copy you actually installed
443
662
 
444
663
  Every test above imports the repository checkout, so a package that installs to the wrong place or ships
@@ -447,6 +666,12 @@ drives the **installed** copy: it lists a real window, runs a takeover click, as
447
666
  `takeover=on cursorRestored=true abortChord=…`, and checks that the HUD is torn down afterwards. Run once
448
667
  against the desktop profile after installing, as the last step of a release.
449
668
 
669
+ The stdio form has the same discipline: unpack the tarball and start `lib/mcp-server.mjs` from the
670
+ unpacked directory (not from the checkout). `scripts/check-mcp-schema.mjs` and `test/mcp-bridge.mjs` both
671
+ spawn the server by path, so pointing them at the unpacked copy is the whole procedure. The 0.7.0 tag
672
+ was pushed after that run; a release that skips it is asserting that the shipped bytes work by
673
+ showing that the source does.
674
+
450
675
  ## License
451
676
 
452
677
  MIT
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.8.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,12 @@ 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
+
18
+ **It ships in two forms over one engine, and 0.8.0 did not replace the first one.** Inside DSH it is a
19
+ plugin (`apply()` on the host half, PowerShell sidecar underneath). Outside it, the same package is an
20
+ MCP server over stdio (`bin: wpm-mcp`), whose tool list is generated from the same contract file — see
21
+ "The second form" below.
17
22
 
18
23
  **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
24
  opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
@@ -31,7 +36,7 @@ bundle with a broad tool surface; this one is a single action tool whose entire
31
36
 
32
37
  ## What it does
33
38
 
34
- One tool, eight actions:
39
+ One tool, eleven actions:
35
40
 
36
41
  | action | what it returns |
37
42
  |---|---|
@@ -43,6 +48,9 @@ One tool, eight actions:
43
48
  | `snapshot` | the accessibility tree as a NUMBERED element table: continuous `label`, control type, name, automation id, screen rect, patterns |
44
49
  | `screenshot` | the window rect captured to a PNG, plus the coordinate mapping as data (`screenRect`, `imageSize`, `scale`, `identity`, `frame`, `dpiAware`) |
45
50
  | `preview` | the marker drawn at a point, and the element under it reported as TEXT — no picture needed |
51
+ | `launch` | start a whitelisted program; reports the pid, and the window only once it really exists |
52
+ | `clipboard` | read or write the system clipboard — a read reports lengths and never the payload |
53
+ | `window` | minimize / restore / move / resize / topmost ONE named window, verified by reading its state back |
46
54
 
47
55
  The engine picks the cheapest available door per call:
48
56
 
@@ -278,6 +286,138 @@ click. Success is reported as `effect=reported-by-send`, never as "verified". Un
278
286
  carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
279
287
  not a bug.
280
288
 
289
+ ## Desktop actions: launch, clipboard, window (0.7.0)
290
+
291
+ Three capabilities that were missing outright — "you cannot even start a program" was the honest answer
292
+ — and none of them is a door action. They choose no channel, cost no tier, and produce no proof window,
293
+ so they live beside `Invoke-WpmAction` rather than inside it, and the door discipline (point ownership,
294
+ the restore table, the proof window) is not widened by any of them.
295
+
296
+ **`launch` — two switches, neither of which implies the other.** `appLaunchAllowed` opens the
297
+ capability; `appLaunchAllow` lists the exact program names or absolute paths that may run, and an
298
+ **empty list means nothing may launch even with the gate on**. Matching is exact and case-folded: there
299
+ is no wildcard, and `notepad` does not authorise `notepad-helper.exe` — a whitelist that grows by prefix
300
+ is a whitelist that authorises more than it says. A refusal is `app_launch_denied` and is raised before
301
+ any worker request, so a refused launch started nothing (asserted with a request counter in
302
+ `test/plugin-test.mjs` and re-checked inside the engine against the same table). The engine's own
303
+ vocabulary for the window is the interesting part: `Process.Start` returns while the app is still
304
+ loading (measured: `MainWindowHandle=0` for 1348 ms on a cold notepad), so a program that has not
305
+ published a window yet answers `ok:true` with `hwnd=""` and `detail=window-not-yet` — neither a fake
306
+ failure nor a fake readiness. Arguments are passed through as given and written to the audit log,
307
+ because listing a program does not vouch for what it is told to do.
308
+
309
+ **`clipboard` — the most private read in this product.** What is on the clipboard may be a password or
310
+ a token the owner copied seconds ago, so a text read reports its **length**, its result text never
311
+ contains the payload, the audit line records `op`/`format`/`chars`, and values are capped at 64 KB with
312
+ `truncated` stated rather than silently cut. An image write accepts a `shotId`, so a screenshot can go
313
+ straight into the clipboard without the caller handling pixels; the read-back compares the size the
314
+ clipboard reports against the size the shot recorded. A clipboard holding neither is refused with the
315
+ format names it did find — an empty success would be indistinguishable from "the clipboard is empty".
316
+
317
+ **`window` — one named window, five ops, each verified by reading the window back.** `IsIconic`,
318
+ `GetWindowRect`, the `WS_EX_TOPMOST` bit — not `ShowWindow`'s return value, because a syscall's answer
319
+ describes the CALL and this product has been burned repeatedly by reporting that as a state. `move` and
320
+ `resize` pass `SWP_NOACTIVATE`, and the result carries `foregroundTaken=true|false` measured on both
321
+ sides of that specific call: `restore` activates by definition (that is what restoring is), and the
322
+ honest answer is to report it, not to hide it or to refuse the op the caller asked for. There is no
323
+ "all windows" op and no `#32770` discovery: acting on a window nobody named is not a convenience.
324
+
325
+ ### One ceiling, eleven actions
326
+
327
+ The old shape of this problem was a boolean per capability, which does not scale past the number of
328
+ settings anyone will actually read. Instead the two axes are independent:
329
+
330
+ ```
331
+ the action declares the lowest rung it can ever need (src/schema/tools.json#requiresTier)
332
+ the owner sets one ceiling (settings: policy)
333
+
334
+ readonly < quiet < flash < takeover
335
+ reads message bounded-UIA real cursor / held focus / launch
336
+ door flash
337
+ ```
338
+
339
+ | `policy` | permits | refuses |
340
+ |---|---|---|
341
+ | `readonly` | `windows`, `status`, `snapshot`, `screenshot`, `preview`, `clipboard` read | every write |
342
+ | `quiet` | + `click` / `type` / `focus` through the message door | the flash tier, `clipboard` write, `window`, `launch` |
343
+ | `balanced` *(default)* | + the bounded-flash tier, `clipboard` write, `window` ops | `takeover:true`, `keyInput:"inject"`, `launch` |
344
+ | `full` | + the takeover tier and `launch` | nothing extra |
345
+
346
+ Above the ceiling a call is refused with **`policy_denied`** and the reason names both numbers (what the
347
+ action needed, what the policy allows), because the correct next step is a settings change and the wrong
348
+ one is a retry. The gate order is `paused → policy → takeoverAllowed/keyInjectAllowed → launch gate +
349
+ whitelist → idle check → the door table`, and every step in it is tested by making two gates disagree
350
+ about which one spoke (`test/plugin-test.mjs`). Two consequences are worth stating plainly rather than
351
+ leaving to discovery: **`takeover:true` now needs `policy:'full'` as well as `takeoverAllowed`** (0.7.0
352
+ raised the bar for the loudest tier on purpose), and `clipboard`'s halves are graded separately
353
+ (`requiresTierFor`), so a `readonly` owner can still read.
354
+
355
+ **Idle instead of a dialog.** When the last *physical* input is younger than `policyIdleMs` (default
356
+ 3000 ms) and the action needs the takeover tier, it is refused with **`user_active`** and nothing is
357
+ clicked — no popup, no countdown. The upstream design asks the owner to consent by interrupting them;
358
+ an interrupt presented as consent is just a second disturbance. The escape hatch is explicit
359
+ (`forceUserActive:true`), it does not bypass any other gate, and the audit line records `forced:true` so
360
+ an interruption caused on purpose stays distinguishable from one caused by accident. An unattended run
361
+ is never blocked by this: with nobody typing, the age grows past the window and the call goes through.
362
+
363
+ ### The audit log
364
+
365
+ Every action appends one JSONL line to `%LOCALAPPDATA%\wpm\audit.log` — allow **and** deny, because a
366
+ trail that records only refusals documents the times the guard worked and is silent about the times it
367
+ had nothing to do with. Fields: `ts, action, hwnd, tier, policy, decision, code, userActiveAgeMs,
368
+ effect, latencyMs`, plus `target`/`args` for a launch and `op`/`format`/`chars` for a clipboard call.
369
+ What is deliberately absent is content: no typed text, no clipboard payload — the second copy of a
370
+ secret is the one nobody protects. `auditKeep` (default 2000) bounds the file, pruning oldest-first when
371
+ a write pushes it past budget. An audit that cannot be written is reported (`auditNote=n write(s)
372
+ failed`) rather than swallowed: a log that looks complete and is not is worse than one that admits it
373
+ is missing lines. This is the only artifact that survives a call, and it is the one thing that can
374
+ answer "what did the agent do to this machine" after the fact.
375
+
376
+ ## The second form: MCP over stdio (0.8.0)
377
+
378
+ The same plugin is also an MCP server, and it is the same code rather than a re-implementation of it.
379
+ `lib/mcp-server.mjs` registers the tool by calling the very `apply()` the DSH host calls, and forwards
380
+ `tools/call` into the same `toRequest()` / gate order / `format()` path, so the eleven actions, the
381
+ seventeen refusal codes, the policy ceiling and the audit line are identical in both forms. That is why
382
+ the engine files were not touched to add it: a second implementation of a permission is a permission
383
+ that can be reached around by using the other copy.
384
+
385
+ **One tool, not eleven.** `tools/list` exposes `wpm` with an `action` discriminator, generated from
386
+ `src/schema/tools.json` — one `oneOf` branch per action, whose `properties`, `required` and
387
+ `additionalProperties` are that action's declaration copied field for field. Nothing in the server
388
+ spells out an action name, a parameter name or a code, and `scripts/check-mcp-schema.mjs` is the reason
389
+ that stays true: it starts the real server, reads what a client would read, and compares it to the file.
390
+ Its self-test mutates both sides on purpose — four edits to the generator must turn the gate red, and two
391
+ edits to the *contract* (rename a parameter, flip `additionalProperties`) must stay green AND move,
392
+ because an arm that only breaks the generator cannot tell a generated schema from a transcribed one that
393
+ happens to agree today.
394
+
395
+ **Settings come from the environment, never from the call.** `WPM_POLICY`, `WPM_TAKEOVER_ALLOWED`,
396
+ `WPM_APP_LAUNCH_ALLOWED`, `WPM_APP_LAUNCH_ALLOW` and the rest of the `WPM_*` set are read at start-up
397
+ and only if present — the defaults stay in `lib/index.js`, because a second copy of a default is a
398
+ default that drifts. A client that could raise its own ceiling or add itself to the launch whitelist
399
+ would make the authorization model decorative, which is the same reason the DSH form reads settings
400
+ from the profile rather than from the prompt.
401
+
402
+ **A picture is attached as pixels, because a path is not portable.** The DSH form renders the screenshot
403
+ file it wrote; a caller on the other end of a pipe cannot open it, so `tools/call` returns the PNG as
404
+ base64 `image` content alongside the text. The text is never replaced by it — `screenRect`, `scale`,
405
+ `identity`, `frame` and `captureBackend` stay in the first block, and across the DSH bridge, where a
406
+ host that cannot accept image input projects the picture into a text diagnostic, those numbers still
407
+ arrive. `WPM_MCP_NO_IMAGE=1` opts out.
408
+
409
+ **Refusals survive the trip.** A refused call comes back with `isError` and the code as the first token
410
+ of the text, unsoftened. Over the DSH bridge the refusal is re-raised as an error whose message is that
411
+ text, so `policy_denied` still reads as `policy_denied` at the far end — asserted, not assumed, in
412
+ `test/mcp-bridge.mjs`, which drives the SDK and the bridge code the host actually ships.
413
+
414
+ **The transport is the only new attack surface, and it is a pipe.** JSON-RPC 2.0 over stdin/stdout with
415
+ Node built-ins and zero dependencies: one JSON object per line, replies keyed by `id` because the worker
416
+ is asynchronous, notifications answered with nothing, a non-JSON line answered with `-32700` and a null
417
+ `id` without killing the loop, an unknown method answered `-32601` without killing the loop, and stdin
418
+ closing meaning "dispose the sidecar and exit 0". Everything that is not a protocol line goes to stderr
419
+ — `console.log` in the plugin half would otherwise print into the JSON stream and corrupt it.
420
+
281
421
  ## What it does not do
282
422
 
283
423
  - **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
@@ -291,6 +431,10 @@ not a bug.
291
431
  - **No OCR / Set-of-Marks / pixel fallback.** Not part of this claim, and already done well elsewhere.
292
432
  - **No watchdog.** The restore is one-shot and happens inline. A watchdog that keeps chasing the
293
433
  foreground would fight you.
434
+ - **No HTTP, no SSE, no OAuth, no TLS.** Two forms exist and neither has a network face: in-process for
435
+ DSH, stdio for MCP. "No network surface" is not a hardening claim, it is the absence of one — there is
436
+ nothing to authenticate against, nothing to listen on, and nothing that keeps running when the caller
437
+ goes away.
294
438
  - **Terminals are still refused** (`terminal_no_door`), and now for a measured reason. The 0.2.0 plan
295
439
  was to drive one by typing into it; two probes say otherwise on this host: 242 `KEYEVENTF_UNICODE`
296
440
  events with the terminal in the foreground and Enter sent produced nothing, and a scan-code arm
@@ -311,12 +455,29 @@ call, not at plugin load.
311
455
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
312
456
  degradation.
313
457
 
458
+ Since 0.8.0 the same package is also an MCP server, and nothing about the install above changes — the
459
+ two forms are parallel entries, not a migration:
460
+
461
+ ```bash
462
+ # stdio, configured by the environment of whoever starts it
463
+ WPM_POLICY=balanced npx dsh-windows-parallel-mcp # via bin: wpm-mcp
464
+ # or, from a checkout
465
+ node lib/mcp-server.mjs
466
+ ```
467
+
468
+ Point any MCP client at that command; `server.json` (shipped in the tarball) is the MCP Registry
469
+ manifest for it, with the namespace `io.github.drscrewdriver/dsh-windows-parallel-mcp` and the npm
470
+ package as its ownership proof. A DSH profile can bridge it instead of loading the plugin directly
471
+ (`@deepseek-ai/dsh-mcp-client`, stdio transport), which registers the tool as `mcp__<serverName>__wpm`;
472
+ `test/mcp-bridge.mjs` drives that bridge with the host's own client SDK and tool-definition code.
473
+
314
474
  ## Typed surface
315
475
 
316
476
  `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`.
477
+ contract: the eleven actions, every argument including the takeover fields, the image-space / label
478
+ surface, 0.6.0's `caretPosition` and 0.7.0's `target`/`op`/`format`/`forceUserActive`, all seventeen
479
+ refusal codes as a closed union, and `effect` as its own four-value union (`WpmEffect`) beside
480
+ `WpmCaptureBackend`, `WpmClipboardOp`, `WpmWindowOp`, `WpmPolicy` and `WpmFrameSource`.
320
481
 
321
482
  Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
322
483
  presence of a file:
@@ -351,6 +512,11 @@ when one is present, and the gate reports a named SKIP rather than a red when on
351
512
  | `snapshotMaxElements` | `300` | cap on elements per snapshot (1–5000); a tighter cap is a smaller frame for a deciding subagent |
352
513
  | `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
514
  | `shotsKeep` | `10` | how many PNGs stay in `%LOCALAPPDATA%\wpm\shots`; older files are deleted after each capture |
515
+ | `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` |
516
+ | `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 |
517
+ | `appLaunchAllowed` | `false` | allow `action=launch` at all. Independent of `takeoverAllowed`: being allowed to move a pointer is not being allowed to start a program |
518
+ | `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 |
519
+ | `auditKeep` | `2000` | how many lines `%LOCALAPPDATA%\wpm\audit.log` holds before the oldest are pruned |
354
520
 
355
521
  ## What measurement established
356
522
 
@@ -439,6 +605,59 @@ unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.
439
605
  exercised `replace:true` through the message door, which is why the fix ships with an arm that does
440
606
  (`test/readback-truth.mjs` A1). Found by running the import instead of trusting its name.
441
607
 
608
+ ### 0.7.0's measurements
609
+
610
+ - **A cold `Process.Start` has no window for over a second** — notepad: pid present,
611
+ `MainWindowHandle=0`, **1348 ms**, and the window only reachable by polling the pid. Hence
612
+ `waitMs`/`window-not-yet` rather than an hwnd claim at return time.
613
+ - **The STA clipboard works in the worker and is not instant** — text write+read identical, first call
614
+ **138 ms**; `SetDataObject`/`GetDataObject` for images (40×20 verified). `Clipboard.Flush()` does NOT
615
+ exist on Windows PowerShell 5.1's runtime (.NET Framework): the first version of this branch threw
616
+ "Clipboard does not contain a method named 'Flush'", which is a method present in the documentation
617
+ people read and absent from the platform the product targets. `SetDataObject($v, $true)` is the
618
+ supported way to make the data outlive the process.
619
+ - **`SW_RESTORE` activates.** Measured around a restore on a real notepad window:
620
+ `foregroundBefore=<other> foregroundAfter=<target>`. Reported as `foregroundTaken=true` on that call
621
+ instead of being attributed to something else; `move`/`resize`/`topmost` measured
622
+ `foregroundTaken=false` with `SWP_NOACTIVATE`.
623
+ - **The whitelist is only a whitelist if it is exact.** `notepad` against `notepad-helper.exe`: a
624
+ prefix or substring rule authorises the second one, so membership is a case-folded full-string test
625
+ and `test/plugin-test.mjs` asserts the refusal for an unlisted name while the gate is on.
626
+ - **The refusal vocabulary is unchanged in shape by `requiresTier`** — a rung comparison is arithmetic
627
+ over one ordered list, so the cost of an action's classification is one number, not one new code per
628
+ action. Three codes were added for the whole batch (`app_launch_denied`, `policy_denied`,
629
+ `user_active`), each naming a setting rather than a symptom.
630
+ - `Check-no-cursor-control` is still green with the same two whitelisted primitive uses and an
631
+ unchanged whitelist file list: adding `launch`/`window` did not open a door to `MOUSEEVENTF_*`,
632
+ `mouse_event` or `keybd_event`.
633
+
634
+ ### 0.8.0's measurements
635
+
636
+ - **A hand-written JSON-RPC loop over stdio is enough** (the 0.8.0 prerequisite probe): `initialize`,
637
+ `tools/list` and `tools/call` all answer, an unknown method returns `-32601` and the process survives
638
+ it, a notification produces no reply line, two requests in flight are matchable by id, a non-JSON line
639
+ does not kill the transport, and closing stdin exits 0. Fifteen assertions, zero dependencies —
640
+ `@modelcontextprotocol/sdk` is not needed and is not used.
641
+ - **The host's SDK is the stricter judge than our own harness.** `test/mcp-bridge.mjs` connects
642
+ `@modelcontextprotocol/client` 2.2.0 (the version the DSH install ships) to our server and validates
643
+ the shapes we emit. Its negotiation throws when the server answers with a protocol revision the
644
+ client does not list, which is why `PROTOCOL_VERSIONS` in `lib/mcp-server.mjs` is checked against that
645
+ SDK's constants (latest `2025-11-25`) rather than guessed from a document.
646
+ - **A picture the host cannot display still delivers its numbers.** Across the bridge with no attachment
647
+ store mounted, a `screenshot` call does not throw: the bridge projects the image block into an
648
+ `[image unavailable: …]` text diagnostic and the `screenRect` / `scale` / `identity` / `frame` /
649
+ `captureBackend` line arrives regardless. Attaching pixels by default is safe because of that
650
+ measurement, not in spite of it.
651
+ - **`tools/list` follows the contract file, in both directions.** Renaming `caretPosition` in
652
+ `src/schema/tools.json` changes what the running server reports, and flipping one
653
+ `additionalProperties` changes it too — both are gate arms (`scripts/check-mcp-schema.mjs --self-test`),
654
+ so the claim "generated, not copied" is exercised rather than asserted in prose.
655
+ - **The install artifact is what was tested.** The 0.7.0 release was smoked from the unpacked tarball
656
+ (`npm pack` → unpack → drive the policy ceiling, both launch gates, the clipboard length-not-payload
657
+ rule and the audit rows: 17 assertions) and that run found two things the working tree could not show:
658
+ the `clipboard` headline does not name which op ran, and the launch gate is only observable once the
659
+ ceiling lets the call reach it. Both are recorded rather than papered over.
660
+
442
661
  ## Verifying the copy you actually installed
443
662
 
444
663
  Every test above imports the repository checkout, so a package that installs to the wrong place or ships
@@ -447,6 +666,12 @@ drives the **installed** copy: it lists a real window, runs a takeover click, as
447
666
  `takeover=on cursorRestored=true abortChord=…`, and checks that the HUD is torn down afterwards. Run once
448
667
  against the desktop profile after installing, as the last step of a release.
449
668
 
669
+ The stdio form has the same discipline: unpack the tarball and start `lib/mcp-server.mjs` from the
670
+ unpacked directory (not from the checkout). `scripts/check-mcp-schema.mjs` and `test/mcp-bridge.mjs` both
671
+ spawn the server by path, so pointing them at the unpacked copy is the whole procedure. The 0.7.0 tag
672
+ was pushed after that run; a release that skips it is asserting that the shipped bytes work by
673
+ showing that the source does.
674
+
450
675
  ## License
451
676
 
452
677
  MIT