dsh-windows-parallel-mcp 0.8.2 → 0.9.0-rc.2

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.
Files changed (53) hide show
  1. package/CHANGELOG.de.md +444 -419
  2. package/CHANGELOG.es.md +444 -419
  3. package/CHANGELOG.fr.md +444 -419
  4. package/CHANGELOG.it.md +444 -419
  5. package/CHANGELOG.ja.md +444 -419
  6. package/CHANGELOG.ko.md +444 -419
  7. package/CHANGELOG.md +965 -940
  8. package/CHANGELOG.pt.md +444 -419
  9. package/CHANGELOG.ru.md +444 -419
  10. package/CHANGELOG.zh.md +444 -419
  11. package/INSTALL.de.md +126 -126
  12. package/INSTALL.es.md +126 -126
  13. package/INSTALL.fr.md +126 -126
  14. package/INSTALL.it.md +126 -126
  15. package/INSTALL.ja.md +126 -126
  16. package/INSTALL.ko.md +126 -126
  17. package/INSTALL.md +122 -122
  18. package/INSTALL.pt.md +126 -126
  19. package/INSTALL.ru.md +126 -126
  20. package/INSTALL.zh.md +126 -126
  21. package/README.de.md +684 -684
  22. package/README.es.md +684 -684
  23. package/README.fr.md +684 -684
  24. package/README.it.md +684 -684
  25. package/README.ja.md +684 -684
  26. package/README.ko.md +684 -684
  27. package/README.md +680 -680
  28. package/README.pt.md +684 -684
  29. package/README.ru.md +684 -684
  30. package/README.zh.md +684 -684
  31. package/cordis.patch.yml +15 -15
  32. package/docs/refusals.md +90 -90
  33. package/docs/takeover.md +128 -128
  34. package/dsh.plugin.json +18 -18
  35. package/lib/config.js +275 -275
  36. package/lib/engine.js +252 -252
  37. package/lib/host-tools.js +365 -338
  38. package/lib/index.js +1275 -1249
  39. package/lib/peers-schemastery.js +23 -23
  40. package/lib/peers-tools.js +15 -15
  41. package/lib/proof-window.mjs +427 -427
  42. package/package.json +122 -122
  43. package/server.json +110 -110
  44. package/src/engine/decide.ps1 +356 -356
  45. package/src/engine/engine.ps1 +1208 -1208
  46. package/src/engine/hud.ps1 +411 -411
  47. package/src/engine/input-inject.ps1 +176 -176
  48. package/src/engine/overlay.ps1 +389 -389
  49. package/src/engine/takeover.ps1 +144 -144
  50. package/src/engine/win.ps1 +1881 -1881
  51. package/src/engine/worker.ps1 +310 -310
  52. package/src/schema/tools.json +533 -533
  53. package/types/index.d.ts +190 -187
@@ -1,144 +1,144 @@
1
- # takeover.ps1 -- the ONE file allowed to move the real cursor, and the ONE place an interruption is
2
- # read from. (R3, spec.md §1)
3
- #
4
- # WHY THIS IS A SEPARATE MODULE RATHER THAN A FUNCTION IN win.ps1. The product's safety claim is now
5
- # "the cursor moves only when takeover was requested, and is ALWAYS put back". A claim like that is
6
- # only checkable if the primitive is confined: scripts/check-no-cursor-control.mjs plus
7
- # scripts/check-takeover-path.mjs G1 assert that SetCursorPos appears in this file and nowhere else.
8
- # Structural confinement beats a promise in a comment -- the same reasoning the repo already used for
9
- # the original "no injection" gate.
10
- #
11
- # THE THREE FACTS CALLERS NEED, and the honest shape of each:
12
- # * the position BEFORE the move (so a restore targets a measured point, not "here-ish");
13
- # * whether the move was actually applied (read-back == request), because a silently refused call
14
- # must not be reported as a moved cursor;
15
- # * whether the restore actually landed (read-back == the saved point), because "restored: true" in
16
- # a log while the pointer sits 40px away is worse than a red verdict.
17
- #
18
- # INTERRUPTION has two channels and both are read here (spec.md §1): the in-process volatile flag
19
- # [WpmCtl]::TakeoverAbort, written by the HUD button / the global chord / the worker's abort command,
20
- # and a latch FILE written by the host half, because the worker is single-threaded and cannot read a
21
- # request while it is inside an action. Volatile is a request; the file is the one that survives a
22
- # wedged notification. Either is sufficient; the flag alone is not treated as the only path.
23
-
24
- Set-StrictMode -Version 2.0
25
-
26
- if (-not ('WpmCtl' -as [type])) {
27
- . (Join-Path $PSScriptRoot 'win.ps1')
28
- }
29
-
30
- if (-not ('WpmTakeover' -as [type])) {
31
- Add-Type -TypeDefinition @'
32
- using System;
33
- using System.Runtime.InteropServices;
34
-
35
- public static class WpmTakeover
36
- {
37
- [StructLayout(LayoutKind.Sequential)] public struct POINT { public int X; public int Y; }
38
-
39
- [DllImport("user32.dll", SetLastError = true)] public static extern bool GetCursorPos(out POINT p);
40
- [DllImport("user32.dll", SetLastError = true)] public static extern bool SetCursorPos(int x, int y);
41
-
42
- public static int[] Read() {
43
- POINT p;
44
- if (!GetCursorPos(out p)) return null;
45
- return new int[] { p.X, p.Y };
46
- }
47
- public static int Apply(int x, int y) {
48
- if (SetCursorPos(x, y)) return 1;
49
- return 0;
50
- }
51
- public static int LastError() { return Marshal.GetLastWin32Error(); }
52
- }
53
- '@
54
- }
55
-
56
- function Get-WpmCursorPos {
57
- # Read-only. Returns the raw point plus 'ok', because a null from the API must not be read as (0,0).
58
- $p = [WpmTakeover]::Read()
59
- if (-not $p) { return @{ ok = $false; x = -1; y = -1; reason = 'GetCursorPos failed' } }
60
- return @{ ok = $true; x = [int]$p[0]; y = [int]$p[1]; reason = '' }
61
- }
62
-
63
- function Set-WpmCursorTakeover {
64
- # MOVE, THEN READ BACK. The request is remembered separately from the read-back on purpose: a
65
- # refusal (UIPI on an elevated foreground, for example) shows up as applied=false with the cursor
66
- # still at 'before', and the caller decides whether that is a refusal or a degraded takeover.
67
- param([int]$X, [int]$Y)
68
- $before = Get-WpmCursorPos
69
- if (-not $before.ok) {
70
- return @{ ok = $false; applied = $false; requestedX = $X; requestedY = $Y
71
- beforeX = -1; beforeY = -1; x = -1; y = -1; reason = 'could not read the cursor before moving it' }
72
- }
73
- $okSet = ([WpmTakeover]::Apply($X, $Y) -eq 1)
74
- # A read-back immediately after the call is the measurement; SetCursorPos' own return value is only
75
- # a hint (it can succeed into a queued move that a later warp overrides).
76
- Start-Sleep -Milliseconds 20
77
- $after = Get-WpmCursorPos
78
- $exact = ($after.ok -and $after.x -eq $X -and $after.y -eq $Y)
79
- return @{
80
- ok = [bool]($after.ok)
81
- applied = [bool]($exact)
82
- setReturned = [bool]$okSet
83
- requestedX = $X; requestedY = $Y
84
- beforeX = [int]$before.x; beforeY = [int]$before.y
85
- x = [int]$after.x; y = [int]$after.y
86
- deltaX = [int]($after.x - $X); deltaY = [int]($after.y - $Y)
87
- reason = if ($exact) { '' } else { 'the cursor did not land on the requested point (win32=' + [WpmTakeover]::LastError() + ')' }
88
- }
89
- }
90
-
91
- function Restore-WpmCursorTakeover {
92
- # RESTORE IS NOT CONDITIONAL ON THE ACTION HAVING SUCCEEDED. It is also not conditional on the move
93
- # having been recorded as applied: if the request was issued, the pointer may have been warped by the
94
- # OS anyway, so the restore is attempted whenever a 'before' point exists. The verdict is the
95
- # read-back, and a restore that failed is reported as restored=false rather than retried forever
96
- # (a watchdog here would fight the owner -- the same decision R2'.7 made about focus).
97
- param([hashtable]$Entry)
98
- if (-not $Entry -or -not $Entry.ok) {
99
- return @{ restored = $false; attempted = $false; x = -1; y = -1
100
- reason = 'no saved cursor position; nothing to restore' }
101
- }
102
- $bx = [int]$Entry.beforeX
103
- $by = [int]$Entry.beforeY
104
- [void][WpmTakeover]::Apply($bx, $by)
105
- Start-Sleep -Milliseconds 20
106
- $now = Get-WpmCursorPos
107
- $landed = ($now.ok -and $now.x -eq $bx -and $now.y -eq $by)
108
- return @{
109
- restored = [bool]$landed
110
- attempted = $true
111
- targetX = $bx; targetY = $by
112
- x = [int]$now.x; y = [int]$now.y
113
- deltaX = [int]($now.x - $bx); deltaY = [int]($now.y - $by)
114
- reason = if ($landed) { '' } else { 'the cursor did not return to the saved point (win32=' + [WpmTakeover]::LastError() + ')' }
115
- }
116
- }
117
-
118
- function Get-WpmTakeoverLatchPath {
119
- # Per-process latch so two workers cannot confuse each other's interruption, and so a stale file from
120
- # a crashed worker can never abort a live one. The host half writes the same path (lib/index.js).
121
- param([int]$ProcessId = $PID)
122
- $base = $env:LOCALAPPDATA
123
- if (-not $base) { $base = [System.IO.Path]::GetTempPath() }
124
- return (Join-Path (Join-Path $base 'wpm') ('takeover-abort.' + $ProcessId))
125
- }
126
-
127
- function Test-WpmTakeoverAbort {
128
- param([int]$ProcessId = $PID)
129
- if ([WpmCtl]::TakeoverAbort) { return $true }
130
- $latch = Get-WpmTakeoverLatchPath -ProcessId $ProcessId
131
- if (Test-Path -LiteralPath $latch) { return $true }
132
- return $false
133
- }
134
-
135
- function Reset-WpmTakeoverAbort {
136
- param([int]$ProcessId = $PID)
137
- [WpmCtl]::TakeoverAbort = $false
138
- [WpmCtl]::InjectedChars = 0
139
- $latch = Get-WpmTakeoverLatchPath -ProcessId $ProcessId
140
- if (Test-Path -LiteralPath $latch) {
141
- try { Remove-Item -LiteralPath $latch -Force -ErrorAction Stop } catch { }
142
- }
143
- return @{ cleared = $true; latch = $latch; latchExists = (Test-Path -LiteralPath $latch) }
144
- }
1
+ # takeover.ps1 -- the ONE file allowed to move the real cursor, and the ONE place an interruption is
2
+ # read from. (R3, spec.md §1)
3
+ #
4
+ # WHY THIS IS A SEPARATE MODULE RATHER THAN A FUNCTION IN win.ps1. The product's safety claim is now
5
+ # "the cursor moves only when takeover was requested, and is ALWAYS put back". A claim like that is
6
+ # only checkable if the primitive is confined: scripts/check-no-cursor-control.mjs plus
7
+ # scripts/check-takeover-path.mjs G1 assert that SetCursorPos appears in this file and nowhere else.
8
+ # Structural confinement beats a promise in a comment -- the same reasoning the repo already used for
9
+ # the original "no injection" gate.
10
+ #
11
+ # THE THREE FACTS CALLERS NEED, and the honest shape of each:
12
+ # * the position BEFORE the move (so a restore targets a measured point, not "here-ish");
13
+ # * whether the move was actually applied (read-back == request), because a silently refused call
14
+ # must not be reported as a moved cursor;
15
+ # * whether the restore actually landed (read-back == the saved point), because "restored: true" in
16
+ # a log while the pointer sits 40px away is worse than a red verdict.
17
+ #
18
+ # INTERRUPTION has two channels and both are read here (spec.md §1): the in-process volatile flag
19
+ # [WpmCtl]::TakeoverAbort, written by the HUD button / the global chord / the worker's abort command,
20
+ # and a latch FILE written by the host half, because the worker is single-threaded and cannot read a
21
+ # request while it is inside an action. Volatile is a request; the file is the one that survives a
22
+ # wedged notification. Either is sufficient; the flag alone is not treated as the only path.
23
+
24
+ Set-StrictMode -Version 2.0
25
+
26
+ if (-not ('WpmCtl' -as [type])) {
27
+ . (Join-Path $PSScriptRoot 'win.ps1')
28
+ }
29
+
30
+ if (-not ('WpmTakeover' -as [type])) {
31
+ Add-Type -TypeDefinition @'
32
+ using System;
33
+ using System.Runtime.InteropServices;
34
+
35
+ public static class WpmTakeover
36
+ {
37
+ [StructLayout(LayoutKind.Sequential)] public struct POINT { public int X; public int Y; }
38
+
39
+ [DllImport("user32.dll", SetLastError = true)] public static extern bool GetCursorPos(out POINT p);
40
+ [DllImport("user32.dll", SetLastError = true)] public static extern bool SetCursorPos(int x, int y);
41
+
42
+ public static int[] Read() {
43
+ POINT p;
44
+ if (!GetCursorPos(out p)) return null;
45
+ return new int[] { p.X, p.Y };
46
+ }
47
+ public static int Apply(int x, int y) {
48
+ if (SetCursorPos(x, y)) return 1;
49
+ return 0;
50
+ }
51
+ public static int LastError() { return Marshal.GetLastWin32Error(); }
52
+ }
53
+ '@
54
+ }
55
+
56
+ function Get-WpmCursorPos {
57
+ # Read-only. Returns the raw point plus 'ok', because a null from the API must not be read as (0,0).
58
+ $p = [WpmTakeover]::Read()
59
+ if (-not $p) { return @{ ok = $false; x = -1; y = -1; reason = 'GetCursorPos failed' } }
60
+ return @{ ok = $true; x = [int]$p[0]; y = [int]$p[1]; reason = '' }
61
+ }
62
+
63
+ function Set-WpmCursorTakeover {
64
+ # MOVE, THEN READ BACK. The request is remembered separately from the read-back on purpose: a
65
+ # refusal (UIPI on an elevated foreground, for example) shows up as applied=false with the cursor
66
+ # still at 'before', and the caller decides whether that is a refusal or a degraded takeover.
67
+ param([int]$X, [int]$Y)
68
+ $before = Get-WpmCursorPos
69
+ if (-not $before.ok) {
70
+ return @{ ok = $false; applied = $false; requestedX = $X; requestedY = $Y
71
+ beforeX = -1; beforeY = -1; x = -1; y = -1; reason = 'could not read the cursor before moving it' }
72
+ }
73
+ $okSet = ([WpmTakeover]::Apply($X, $Y) -eq 1)
74
+ # A read-back immediately after the call is the measurement; SetCursorPos' own return value is only
75
+ # a hint (it can succeed into a queued move that a later warp overrides).
76
+ Start-Sleep -Milliseconds 20
77
+ $after = Get-WpmCursorPos
78
+ $exact = ($after.ok -and $after.x -eq $X -and $after.y -eq $Y)
79
+ return @{
80
+ ok = [bool]($after.ok)
81
+ applied = [bool]($exact)
82
+ setReturned = [bool]$okSet
83
+ requestedX = $X; requestedY = $Y
84
+ beforeX = [int]$before.x; beforeY = [int]$before.y
85
+ x = [int]$after.x; y = [int]$after.y
86
+ deltaX = [int]($after.x - $X); deltaY = [int]($after.y - $Y)
87
+ reason = if ($exact) { '' } else { 'the cursor did not land on the requested point (win32=' + [WpmTakeover]::LastError() + ')' }
88
+ }
89
+ }
90
+
91
+ function Restore-WpmCursorTakeover {
92
+ # RESTORE IS NOT CONDITIONAL ON THE ACTION HAVING SUCCEEDED. It is also not conditional on the move
93
+ # having been recorded as applied: if the request was issued, the pointer may have been warped by the
94
+ # OS anyway, so the restore is attempted whenever a 'before' point exists. The verdict is the
95
+ # read-back, and a restore that failed is reported as restored=false rather than retried forever
96
+ # (a watchdog here would fight the owner -- the same decision R2'.7 made about focus).
97
+ param([hashtable]$Entry)
98
+ if (-not $Entry -or -not $Entry.ok) {
99
+ return @{ restored = $false; attempted = $false; x = -1; y = -1
100
+ reason = 'no saved cursor position; nothing to restore' }
101
+ }
102
+ $bx = [int]$Entry.beforeX
103
+ $by = [int]$Entry.beforeY
104
+ [void][WpmTakeover]::Apply($bx, $by)
105
+ Start-Sleep -Milliseconds 20
106
+ $now = Get-WpmCursorPos
107
+ $landed = ($now.ok -and $now.x -eq $bx -and $now.y -eq $by)
108
+ return @{
109
+ restored = [bool]$landed
110
+ attempted = $true
111
+ targetX = $bx; targetY = $by
112
+ x = [int]$now.x; y = [int]$now.y
113
+ deltaX = [int]($now.x - $bx); deltaY = [int]($now.y - $by)
114
+ reason = if ($landed) { '' } else { 'the cursor did not return to the saved point (win32=' + [WpmTakeover]::LastError() + ')' }
115
+ }
116
+ }
117
+
118
+ function Get-WpmTakeoverLatchPath {
119
+ # Per-process latch so two workers cannot confuse each other's interruption, and so a stale file from
120
+ # a crashed worker can never abort a live one. The host half writes the same path (lib/index.js).
121
+ param([int]$ProcessId = $PID)
122
+ $base = $env:LOCALAPPDATA
123
+ if (-not $base) { $base = [System.IO.Path]::GetTempPath() }
124
+ return (Join-Path (Join-Path $base 'wpm') ('takeover-abort.' + $ProcessId))
125
+ }
126
+
127
+ function Test-WpmTakeoverAbort {
128
+ param([int]$ProcessId = $PID)
129
+ if ([WpmCtl]::TakeoverAbort) { return $true }
130
+ $latch = Get-WpmTakeoverLatchPath -ProcessId $ProcessId
131
+ if (Test-Path -LiteralPath $latch) { return $true }
132
+ return $false
133
+ }
134
+
135
+ function Reset-WpmTakeoverAbort {
136
+ param([int]$ProcessId = $PID)
137
+ [WpmCtl]::TakeoverAbort = $false
138
+ [WpmCtl]::InjectedChars = 0
139
+ $latch = Get-WpmTakeoverLatchPath -ProcessId $ProcessId
140
+ if (Test-Path -LiteralPath $latch) {
141
+ try { Remove-Item -LiteralPath $latch -Force -ErrorAction Stop } catch { }
142
+ }
143
+ return @{ cleared = $true; latch = $latch; latchExists = (Test-Path -LiteralPath $latch) }
144
+ }