dsh-windows-parallel-mcp 0.1.6 → 0.2.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/CHANGELOG.md +89 -1
- package/README.md +113 -24
- package/docs/refusals.md +17 -10
- package/docs/takeover.md +129 -0
- package/dsh.plugin.json +3 -3
- package/lib/config.js +57 -2
- package/lib/host-tools.js +32 -2
- package/lib/index.js +149 -14
- package/lib/proof-window.mjs +24 -3
- package/package.json +7 -2
- package/src/engine/decide.ps1 +110 -57
- package/src/engine/engine.ps1 +201 -8
- package/src/engine/hud.ps1 +411 -0
- package/src/engine/input-inject.ps1 +176 -0
- package/src/engine/overlay.ps1 +7 -1
- package/src/engine/takeover.ps1 +144 -0
- package/src/engine/win.ps1 +18 -1
- package/src/engine/worker.ps1 +63 -4
- package/src/schema/tools.json +57 -13
|
@@ -0,0 +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
|
+
}
|
package/src/engine/win.ps1
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# win.ps1 -- the IO half of the R2' engine: probe a target's doors, act through the cheapest
|
|
1
|
+
# win.ps1 -- the IO half of the R2' engine: probe a target's doors, act through the cheapest
|
|
2
2
|
# door it has, and put the owner's focus back when the action cost them a flash.
|
|
3
3
|
#
|
|
4
4
|
# Layering is deliberate. decide.ps1 owns every judgement (pure, unit-tested). This file owns
|
|
@@ -379,6 +379,23 @@ public static class WpmCtl {
|
|
|
379
379
|
public static object Dispatcher = null; // overlay thread's WPF dispatcher (set by that thread)
|
|
380
380
|
public static object Window = null; // the marker window (touched ONLY on its own thread)
|
|
381
381
|
public static object Timer = null; // auto-hide timer (same rule)
|
|
382
|
+
|
|
383
|
+
// ---- R3 takeover surface (spec.md §2) ------------------------------------------------------
|
|
384
|
+
// Same rule as the marker fields: the HUD thread owns the window and reads these; the engine writes
|
|
385
|
+
// the request fields. No scriptblock is ever marshalled across the threads.
|
|
386
|
+
public static volatile bool HudOn = false;
|
|
387
|
+
public static volatile bool TakeoverAbort = false; // HUD button / abort chord / worker abort
|
|
388
|
+
public static volatile bool AbortChordOk = false;
|
|
389
|
+
// volatile is ILLEGAL on string in C# (like long below): a reference write is atomic, so a plain
|
|
390
|
+
// static is the honest declaration and not a weaker one.
|
|
391
|
+
public static string HudPhase = "";
|
|
392
|
+
public static string HudAction = "";
|
|
393
|
+
public static string AbortChordLabel = "";
|
|
394
|
+
public static volatile int HudElapsedMs = 0;
|
|
395
|
+
public static volatile int HudMaxMs = 0;
|
|
396
|
+
public static volatile int HudSeq = 0;
|
|
397
|
+
public static volatile int InjectedChars = 0;
|
|
398
|
+
public static long HudHwnd = 0;
|
|
382
399
|
}
|
|
383
400
|
'@
|
|
384
401
|
}
|
package/src/engine/worker.ps1
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# worker.ps1 -- the sidecar's line protocol: one JSON request in, one JSON response out.
|
|
2
2
|
#
|
|
3
3
|
# WHY A WORKER AND NOT A DIRECT CALL. Two constraints collide in this process model:
|
|
4
4
|
# * UIA COM wants a single-threaded apartment (powershell.exe -STA), and
|
|
@@ -123,22 +123,81 @@ while ($true) {
|
|
|
123
123
|
Write-Response $id @{ id = $id; ok = $true; result = @{ paused = $on } }
|
|
124
124
|
}
|
|
125
125
|
'click' {
|
|
126
|
+
# R3: takeover/keyInput travel as explicit request fields. The HOST half is what enforces the
|
|
127
|
+
# settings gates (lib/index.js) and strips these fields when a gate is off, so a request that
|
|
128
|
+
# arrives here with takeover=true was already authorised; the engine still re-checks the HUD.
|
|
126
129
|
$r = Invoke-WpmAction -Hwnd ([string](Get-Arg $req 'hwnd' '')) -Action click `
|
|
127
130
|
-X ([int](Get-Arg $req 'x' -1)) -Y ([int](Get-Arg $req 'y' -1)) `
|
|
128
|
-
-SettleMs ([int](Get-Arg $req 'settleMs' 350))
|
|
131
|
+
-SettleMs ([int](Get-Arg $req 'settleMs' 350)) `
|
|
132
|
+
-Takeover:([bool](Get-Arg $req 'takeover' $false)) `
|
|
133
|
+
-TakeoverMaxMs ([int](Get-Arg $req 'takeoverMaxMs' 10000)) `
|
|
134
|
+
-KeyInject:([bool](([string](Get-Arg $req 'keyInput' 'none')) -eq 'inject')) `
|
|
135
|
+
-TakeoverArmMs ([int](Get-Arg $req 'takeoverArmMs' 800)) `
|
|
136
|
+
-HudDoneMs ([int](Get-Arg $req 'hudDoneMs' 1500))
|
|
129
137
|
Write-Response $id @{ id = $id; ok = $true; result = $r }
|
|
130
138
|
}
|
|
131
139
|
'type' {
|
|
132
140
|
$r = Invoke-WpmAction -Hwnd ([string](Get-Arg $req 'hwnd' '')) -Action type `
|
|
133
141
|
-Text ([string](Get-Arg $req 'text' '')) -ElementName ([string](Get-Arg $req 'elementName' '')) `
|
|
134
|
-
-Replace:([bool](Get-Arg $req 'replace' $false)) -SettleMs ([int](Get-Arg $req 'settleMs' 350))
|
|
142
|
+
-Replace:([bool](Get-Arg $req 'replace' $false)) -SettleMs ([int](Get-Arg $req 'settleMs' 350)) `
|
|
143
|
+
-Takeover:([bool](Get-Arg $req 'takeover' $false)) `
|
|
144
|
+
-TakeoverMaxMs ([int](Get-Arg $req 'takeoverMaxMs' 10000)) `
|
|
145
|
+
-KeyInject:([bool](([string](Get-Arg $req 'keyInput' 'none')) -eq 'inject')) `
|
|
146
|
+
-TakeoverArmMs ([int](Get-Arg $req 'takeoverArmMs' 800)) `
|
|
147
|
+
-HudDoneMs ([int](Get-Arg $req 'hudDoneMs' 1500))
|
|
135
148
|
Write-Response $id @{ id = $id; ok = $true; result = $r }
|
|
136
149
|
}
|
|
137
150
|
'focus' {
|
|
138
151
|
$r = Invoke-WpmAction -Hwnd ([string](Get-Arg $req 'hwnd' '')) -Action focus `
|
|
139
|
-
-ElementName ([string](Get-Arg $req 'elementName' '')) -SettleMs ([int](Get-Arg $req 'settleMs' 350))
|
|
152
|
+
-ElementName ([string](Get-Arg $req 'elementName' '')) -SettleMs ([int](Get-Arg $req 'settleMs' 350)) `
|
|
153
|
+
-Takeover:([bool](Get-Arg $req 'takeover' $false)) `
|
|
154
|
+
-TakeoverMaxMs ([int](Get-Arg $req 'takeoverMaxMs' 10000))
|
|
140
155
|
Write-Response $id @{ id = $id; ok = $true; result = $r }
|
|
141
156
|
}
|
|
157
|
+
'hud' {
|
|
158
|
+
# Product surface for tests and for the owner: start/stop the HUD on its own, so its window
|
|
159
|
+
# properties can be measured without an action in flight (test/hud-test.ps1).
|
|
160
|
+
. (Join-Path $EngineRoot 'hud.ps1')
|
|
161
|
+
$on = [bool](Get-Arg $req 'on' $true)
|
|
162
|
+
if ($on) {
|
|
163
|
+
$r = Start-WpmHud -Action ([string](Get-Arg $req 'action' 'hud')) -MaxMs ([int](Get-Arg $req 'maxMs' 10000)) -ArmMs ([int](Get-Arg $req 'armMs' 0))
|
|
164
|
+
$st = if ($r.state) { $r.state } else { Get-WpmHudState -WaitMs 100 }
|
|
165
|
+
} else {
|
|
166
|
+
$r = Stop-WpmHud
|
|
167
|
+
$st = $r.state
|
|
168
|
+
}
|
|
169
|
+
Write-Response $id @{ id = $id; ok = $true; result = @{ hud = $st } }
|
|
170
|
+
}
|
|
171
|
+
'takeover' {
|
|
172
|
+
# Alias of 'hud' on purpose: the HUD IS the takeover precondition, so "takeover on" and "hud on"
|
|
173
|
+
# are the same operation. Reported separately from the settings gate, which lives in the host.
|
|
174
|
+
. (Join-Path $EngineRoot 'hud.ps1')
|
|
175
|
+
$on = [bool](Get-Arg $req 'on' $true)
|
|
176
|
+
if ($on) {
|
|
177
|
+
$r = Start-WpmHud -Action 'takeover' -MaxMs ([int](Get-Arg $req 'maxMs' 10000)) -ArmMs 0
|
|
178
|
+
$st = if ($r.state) { $r.state } else { Get-WpmHudState -WaitMs 100 }
|
|
179
|
+
} else {
|
|
180
|
+
$r = Stop-WpmHud
|
|
181
|
+
$st = $r.state
|
|
182
|
+
}
|
|
183
|
+
Write-Response $id @{ id = $id; ok = $true; result = @{ hud = $st; stance = 'takeover requires the host setting takeoverAllowed; the HUD is the hard precondition' } }
|
|
184
|
+
}
|
|
185
|
+
'abort' {
|
|
186
|
+
# IMMEDIATE ANSWER, and it must not wait for anything. This is the host's signal -> worker path;
|
|
187
|
+
# the FILE latch is the path the engine actually polls, so both are written here and the answer
|
|
188
|
+
# goes out before any cleanup work could delay it.
|
|
189
|
+
. (Join-Path $EngineRoot 'takeover.ps1')
|
|
190
|
+
[WpmCtl]::TakeoverAbort = $true
|
|
191
|
+
$latch = Get-WpmTakeoverLatchPath
|
|
192
|
+
$written = $false
|
|
193
|
+
try {
|
|
194
|
+
$dir = Split-Path -Parent $latch
|
|
195
|
+
if (-not (Test-Path -LiteralPath $dir)) { New-Item -ItemType Directory -Force -Path $dir | Out-Null }
|
|
196
|
+
Set-Content -LiteralPath $latch -Value 'abort' -Encoding ASCII -ErrorAction Stop
|
|
197
|
+
$written = $true
|
|
198
|
+
} catch { }
|
|
199
|
+
Write-Response $id @{ id = $id; ok = $true; result = @{ aborted = $true; latch = $latch; latchWritten = $written; flagSet = [bool][WpmCtl]::TakeoverAbort } }
|
|
200
|
+
}
|
|
142
201
|
'ping' {
|
|
143
202
|
# `text` is echoed back verbatim. That is not decoration: the protocol's encoding is a real
|
|
144
203
|
# failure surface on this host (ANSI codepage GBK), and an echo is the only way to prove a
|
package/src/schema/tools.json
CHANGED
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
"The `refusalCases` array is executable: test/refusals-test.ps1 iterates it and binds the placeholders, so a documented refusal path cannot rot into fiction."
|
|
29
29
|
],
|
|
30
30
|
"stance": {
|
|
31
|
-
"inputQueue": "
|
|
32
|
-
"focus": "no forged Alt key, no synthetic activation code",
|
|
33
|
-
"cursor": "the cursor is
|
|
34
|
-
"
|
|
31
|
+
"inputQueue": "quiet and bounded-flash tiers write nothing to the OS input queue. The takeover tier (opt-in, takeoverAllowed) may send KEYBOARD input (SendInput + KEYEVENTF_UNICODE) only when keyInput='inject' was requested; mouse injection is structurally impossible (MOUSEEVENTF_* is banned repo-wide and the gate enforces it)",
|
|
32
|
+
"focus": "no forged Alt key, no synthetic activation code. The bounded-flash tier reverses its one flash; the takeover tier holds the focus until the action ends and then restores it through the same table",
|
|
33
|
+
"cursor": "the cursor is 0 px in the quiet and bounded-flash tiers (24 measured rounds, scripts/channel-raise-matrix.ps1). The takeover tier moves it to the action point BY REQUEST and always restores it; a restore that fails is reported as cursorRestored=false and turns proof=fail",
|
|
34
|
+
"keyboard": "keyboard injection exists only inside the takeover tier, only for targets with no message door and no UIA pattern (terminals, measured), only after asserting GetForegroundWindow() is the target. It does not carry hardware scancodes (KEYEVENTF_UNICODE), so a target that reads scancodes only will ignore it -- documented, not a bug",
|
|
35
|
+
"tiers": "quiet (window messages) preferred over bounded-flash (UIA patterns) preferred over takeover (explicit request, HUD mandatory, always restored); the flash tier must reverse itself once and never pulls focus from a window the owner chose",
|
|
36
|
+
"hud": "the takeover tier cannot run without the HUD: it is a hard precondition (refuse takeover_unavailable), not a decoration. Three phases (arming/active/done), no-activate, click-through outside its button, and three independent interruption paths"
|
|
35
37
|
},
|
|
36
38
|
"refusals": [
|
|
37
39
|
{ "code": "no_hwnd", "layer": "decision", "summary": "no usable target window handle" },
|
|
@@ -40,10 +42,13 @@
|
|
|
40
42
|
{ "code": "unreachable", "layer": "decision", "summary": "no message door and no usable UIA pattern; the tree is alive but offers nothing at the named point or element" },
|
|
41
43
|
{ "code": "uia_tree_empty", "layer": "decision", "summary": "the accessibility tree holds no content element at all; in every measured instance the cause is the application having UI Automation disabled, which only a launch-time switch changes" },
|
|
42
44
|
{ "code": "uia_probe_failed", "layer": "decision", "summary": "the accessibility probe threw before it could measure this target; the exception text rides the reason" },
|
|
43
|
-
{ "code": "terminal_no_door", "layer": "decision", "summary": "terminal text surface
|
|
45
|
+
{ "code": "terminal_no_door", "layer": "decision", "summary": "terminal text surface has child windows but none of them is writable, and keyboard injection into this host's terminal was measured not to work (findings G3: Unicode and scan-code arms both accepted by SendInput, neither executed). Pick a target with a real door" },
|
|
44
46
|
{ "code": "needs_facts", "layer": "decision", "summary": "the caller supplied no measured facts for this target" },
|
|
47
|
+
{ "code": "takeover_unavailable", "layer": "decision", "summary": "takeover was requested but cannot run safely: the takeoverAllowed gate is off or the HUD is not up. The request is refused rather than silently downgraded" },
|
|
48
|
+
{ "code": "keyinject_unavailable", "layer": "decision", "summary": "keyboard injection was requested outside the takeover tier, with the keyInjectAllowed gate off, or with the target not in the foreground (SendInput writes to the foreground, so a blind injection would type into another application)" },
|
|
45
49
|
{ "code": "action_failed", "layer": "runtime", "summary": "the chosen channel threw while acting", "uncoveredReason": "needs a target whose channel reliably throws; not constructed this round (docs/refusals.md, gap 2)" },
|
|
46
|
-
{ "code": "restore_failed", "layer": "runtime", "summary": "the OS refused to return the foreground after a flash", "uncoveredReason": "needs a real elevated window; task_52 (docs/refusals.md, gap 2)" }
|
|
50
|
+
{ "code": "restore_failed", "layer": "runtime", "summary": "the OS refused to return the foreground after a flash", "uncoveredReason": "needs a real elevated window; task_52 (docs/refusals.md, gap 2)" },
|
|
51
|
+
{ "code": "takeover_aborted", "layer": "runtime", "summary": "the owner or the host interrupted a takeover (HUD button, abort chord, host cancellation). Not a fault: the result still carries cursorRestored and injectedChars so the reader knows exactly how far it got", "uncoveredReason": "fires from a real interruption inside a live takeover action; test/takeover-test.ps1 covers the three interruption paths at the engine level (volatile flag, latch file, and the send-time abort probe), and the schema case is declared uncovered because the refusal vocabulary gate needs an executable decision-mode instance and this is a runtime outcome" }
|
|
47
52
|
],
|
|
48
53
|
"tools": [
|
|
49
54
|
{
|
|
@@ -71,12 +76,14 @@
|
|
|
71
76
|
"hwnd": { "type": "string", "description": "Target top-level window handle, as returned by wpm_windows." },
|
|
72
77
|
"x": { "type": "integer", "description": "Screen X coordinate. Must resolve to a child window of the target, otherwise the action is refused instead of being sent somewhere else." },
|
|
73
78
|
"y": { "type": "integer", "description": "Screen Y coordinate." },
|
|
74
|
-
"settleMs": { "type": "integer", "minimum": 0, "maximum": 2000, "default": 350, "description": "How long to let the app commit its state before the effect is judged." }
|
|
79
|
+
"settleMs": { "type": "integer", "minimum": 0, "maximum": 2000, "default": 350, "description": "How long to let the app commit its state before the effect is judged." },
|
|
80
|
+
"takeover": { "type": "boolean", "default": false, "description": "Take the takeover tier: the real cursor moves to the action point and is always restored, the focus is held until the action ends, and a three-phase HUD is mandatory. Requires the takeoverAllowed setting or the call is refused with takeover_unavailable." },
|
|
81
|
+
"takeoverMaxMs": { "type": "integer", "minimum": 500, "maximum": 60000, "default": 10000, "description": "Takeover only: how long the action may hold the cursor/focus." }
|
|
75
82
|
},
|
|
76
83
|
"required": ["hwnd", "x", "y"],
|
|
77
84
|
"additionalProperties": false
|
|
78
85
|
},
|
|
79
|
-
"refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed"]
|
|
86
|
+
"refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed", "takeover_unavailable", "keyinject_unavailable", "takeover_aborted"]
|
|
80
87
|
},
|
|
81
88
|
{
|
|
82
89
|
"name": "wpm_type",
|
|
@@ -90,12 +97,15 @@
|
|
|
90
97
|
"text": { "type": "string", "description": "Text to write. Empty string is refused: it cannot be distinguished from a channel that silently did nothing." },
|
|
91
98
|
"elementName": { "type": "string", "description": "Optional UIA Name or AutomationId of the control to write into. Naming an element forces the UIA tier, because a message tier cannot address 'the control called X'." },
|
|
92
99
|
"replace": { "type": "boolean", "default": false, "description": "Replace the existing value instead of appending to it." },
|
|
93
|
-
"settleMs": { "type": "integer", "minimum": 0, "maximum": 2000, "default": 350, "description": "How long to let the app commit its state before the effect is judged." }
|
|
100
|
+
"settleMs": { "type": "integer", "minimum": 0, "maximum": 2000, "default": 350, "description": "How long to let the app commit its state before the effect is judged." },
|
|
101
|
+
"takeover": { "type": "boolean", "default": false, "description": "Take the takeover tier: the HUD is shown, the focus is held until the action ends, and (with keyInput) text may be typed into the foreground target." },
|
|
102
|
+
"takeoverMaxMs": { "type": "integer", "minimum": 500, "maximum": 60000, "default": 10000, "description": "Takeover only: how long the action may hold the cursor/focus." },
|
|
103
|
+
"keyInput": { "type": "string", "enum": ["none", "inject"], "default": "none", "description": "Takeover only: 'inject' types the text with synthetic keyboard input into the foreground target, for windows with no message door and no UIA pattern (terminals). Requires keyInjectAllowed and the target in the foreground; otherwise the call is refused with keyinject_unavailable. The cursor is never moved by this path." }
|
|
94
104
|
},
|
|
95
105
|
"required": ["hwnd", "text"],
|
|
96
106
|
"additionalProperties": false
|
|
97
107
|
},
|
|
98
|
-
"refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed"]
|
|
108
|
+
"refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed", "takeover_unavailable", "keyinject_unavailable", "takeover_aborted"]
|
|
99
109
|
},
|
|
100
110
|
{
|
|
101
111
|
"name": "wpm_focus",
|
|
@@ -107,12 +117,14 @@
|
|
|
107
117
|
"properties": {
|
|
108
118
|
"hwnd": { "type": "string", "description": "Target top-level window handle." },
|
|
109
119
|
"elementName": { "type": "string", "description": "UIA Name or AutomationId of the control that should hold focus." },
|
|
110
|
-
"settleMs": { "type": "integer", "minimum": 0, "maximum": 2000, "default": 350, "description": "How long to let the app commit its state before the effect is judged." }
|
|
120
|
+
"settleMs": { "type": "integer", "minimum": 0, "maximum": 2000, "default": 350, "description": "How long to let the app commit its state before the effect is judged." },
|
|
121
|
+
"takeover": { "type": "boolean", "default": false, "description": "Take the takeover tier: the HUD is shown and the focus is held until the action ends, then restored. Requires the takeoverAllowed setting." },
|
|
122
|
+
"takeoverMaxMs": { "type": "integer", "minimum": 500, "maximum": 60000, "default": 10000, "description": "Takeover only: how long the action may hold the cursor/focus." }
|
|
111
123
|
},
|
|
112
124
|
"required": ["hwnd", "elementName"],
|
|
113
125
|
"additionalProperties": false
|
|
114
126
|
},
|
|
115
|
-
"refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed"]
|
|
127
|
+
"refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed", "takeover_unavailable", "takeover_aborted"]
|
|
116
128
|
},
|
|
117
129
|
{
|
|
118
130
|
"name": "wpm_status",
|
|
@@ -177,7 +189,7 @@
|
|
|
177
189
|
"tool": "wpm_type",
|
|
178
190
|
"facts": { "hwnd": "$liveHwnd", "family": "terminal" },
|
|
179
191
|
"expect": "terminal_no_door",
|
|
180
|
-
"note": "Decision-table instance
|
|
192
|
+
"note": "Decision-table instance, and now a conclusion verified by measurement rather than by caution: the takeover + keyInput path was measured NOT to drive this host's terminal (scripts/probe-console-inject.ps1: 242 Unicode events with the terminal in the foreground and Enter sent, nothing executed; scripts/probe-console-scan.ps1: same with layout scan codes). The code stays because its next step is still actionable -- use a target with a door."
|
|
181
193
|
},
|
|
182
194
|
{
|
|
183
195
|
"id": "click-uia-tree-empty",
|
|
@@ -203,6 +215,38 @@
|
|
|
203
215
|
"expect": "needs_facts",
|
|
204
216
|
"note": "The absence of facts must refuse, not default to the quiet branch. Unreachable through the engine (facts are always measured), so this one guards the table when it is used on its own."
|
|
205
217
|
},
|
|
218
|
+
{
|
|
219
|
+
"id": "takeover-unavailable",
|
|
220
|
+
"mode": "decision",
|
|
221
|
+
"tool": "wpm_click",
|
|
222
|
+
"facts": { "hwnd": "$liveHwnd", "takeoverRequested": true, "hudReady": false },
|
|
223
|
+
"expect": "takeover_unavailable",
|
|
224
|
+
"note": "Takeover was asked for but the HUD is not up. The HUD is a hard precondition, so the request is refused instead of being served silently by the quiet tier -- the point of the code is that the caller learns the request did not happen."
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"id": "keyinject-unavailable",
|
|
228
|
+
"mode": "decision",
|
|
229
|
+
"tool": "wpm_type",
|
|
230
|
+
"facts": { "hwnd": "$liveHwnd", "takeoverRequested": true, "hudReady": true, "keyInjectRequested": true, "keyInjectAllowed": false },
|
|
231
|
+
"expect": "keyinject_unavailable",
|
|
232
|
+
"note": "Injection requested with the keyInjectAllowed gate off. Measured fact behind the refusal: SendInput writes to the FOREGROUND window (scripts/probe-sendinput-unicode.ps1 arm B: text landed in the foreground window and not in the window the caller had in mind), so an unauthorised injection is refused rather than attempted."
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"id": "keyinject-not-foreground",
|
|
236
|
+
"mode": "decision",
|
|
237
|
+
"tool": "wpm_type",
|
|
238
|
+
"facts": { "hwnd": "$liveHwnd", "takeoverRequested": true, "hudReady": true, "keyInjectRequested": true, "keyInjectAllowed": true, "foregroundIsTarget": false },
|
|
239
|
+
"expect": "keyinject_unavailable",
|
|
240
|
+
"note": "Injection requested, gate open, but the target is not the foreground window and could not be raised. The engine refuses: blind injection would type into whatever the owner was using (same measured fact as keyinject-unavailable)."
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"id": "takeover-aborted",
|
|
244
|
+
"mode": "none",
|
|
245
|
+
"tool": "wpm_click",
|
|
246
|
+
"args": { "hwnd": "$liveHwnd", "x": 100, "y": 100 },
|
|
247
|
+
"expect": "takeover_aborted",
|
|
248
|
+
"note": "NOT covered by an executable schema case: it is a RUNTIME outcome of an interruption (HUD button / abort chord / host cancellation), and constructing one needs a live takeover in progress. test/takeover-test.ps1 covers the three interruption paths at the engine level; the reason is declared in tools.json refusals."
|
|
249
|
+
},
|
|
206
250
|
{
|
|
207
251
|
"id": "action-failed",
|
|
208
252
|
"mode": "none",
|