dsh-windows-parallel-mcp 0.8.2 → 0.9.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.de.md +433 -419
- package/CHANGELOG.es.md +433 -419
- package/CHANGELOG.fr.md +433 -419
- package/CHANGELOG.it.md +433 -419
- package/CHANGELOG.ja.md +433 -419
- package/CHANGELOG.ko.md +433 -419
- package/CHANGELOG.md +954 -940
- package/CHANGELOG.pt.md +433 -419
- package/CHANGELOG.ru.md +433 -419
- package/CHANGELOG.zh.md +433 -419
- package/INSTALL.de.md +126 -126
- package/INSTALL.es.md +126 -126
- package/INSTALL.fr.md +126 -126
- package/INSTALL.it.md +126 -126
- package/INSTALL.ja.md +126 -126
- package/INSTALL.ko.md +126 -126
- package/INSTALL.md +122 -122
- package/INSTALL.pt.md +126 -126
- package/INSTALL.ru.md +126 -126
- package/INSTALL.zh.md +126 -126
- package/README.de.md +684 -684
- package/README.es.md +684 -684
- package/README.fr.md +684 -684
- package/README.it.md +684 -684
- package/README.ja.md +684 -684
- package/README.ko.md +684 -684
- package/README.md +680 -680
- package/README.pt.md +684 -684
- package/README.ru.md +684 -684
- package/README.zh.md +684 -684
- package/cordis.patch.yml +15 -15
- package/docs/refusals.md +90 -90
- package/docs/takeover.md +128 -128
- package/dsh.plugin.json +18 -18
- package/lib/config.js +275 -275
- package/lib/engine.js +252 -252
- package/lib/host-tools.js +365 -338
- package/lib/index.js +1249 -1249
- package/lib/peers-schemastery.js +23 -23
- package/lib/peers-tools.js +15 -15
- package/lib/proof-window.mjs +427 -427
- package/package.json +122 -122
- package/server.json +110 -110
- package/src/engine/decide.ps1 +356 -356
- package/src/engine/engine.ps1 +1208 -1208
- package/src/engine/hud.ps1 +411 -411
- package/src/engine/input-inject.ps1 +176 -176
- package/src/engine/overlay.ps1 +389 -389
- package/src/engine/takeover.ps1 +144 -144
- package/src/engine/win.ps1 +1881 -1881
- package/src/engine/worker.ps1 +310 -310
- package/src/schema/tools.json +533 -533
- package/types/index.d.ts +187 -187
package/src/engine/takeover.ps1
CHANGED
|
@@ -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
|
+
}
|