dsh-windows-parallel-mcp 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.de.md +13 -1
- package/CHANGELOG.es.md +13 -1
- package/CHANGELOG.fr.md +13 -1
- package/CHANGELOG.it.md +13 -1
- package/CHANGELOG.ja.md +12 -0
- package/CHANGELOG.ko.md +12 -0
- package/CHANGELOG.md +181 -3
- package/CHANGELOG.pt.md +13 -1
- package/CHANGELOG.ru.md +13 -1
- package/CHANGELOG.zh.md +12 -0
- package/README.de.md +218 -7
- package/README.es.md +218 -7
- package/README.fr.md +218 -7
- package/README.it.md +218 -7
- package/README.ja.md +218 -7
- package/README.ko.md +218 -7
- package/README.md +218 -7
- package/README.pt.md +218 -7
- package/README.ru.md +218 -7
- package/README.zh.md +218 -7
- package/docs/refusals.md +3 -0
- package/dsh.plugin.json +2 -2
- package/lib/audit.js +109 -0
- package/lib/config.js +55 -2
- package/lib/host-tools.js +76 -3
- package/lib/index.js +333 -18
- package/lib/policy.js +127 -0
- package/package.json +2 -2
- package/src/engine/decide.ps1 +120 -3
- package/src/engine/engine.ps1 +407 -5
- package/src/engine/win.ps1 +496 -6
- package/src/engine/worker.ps1 +57 -0
- package/src/schema/tools.json +156 -13
- package/types/index.d.ts +63 -4
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-windows-parallel-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"tag": "latest",
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
8
8
|
},
|
|
9
|
-
"description": "Drive a Windows window quietly by default and visibly on request: one tool,
|
|
9
|
+
"description": "Drive a Windows window quietly by default and visibly on request: one tool, eleven actions (windows, status, click, type, focus, snapshot, screenshot, preview, launch, clipboard, window), a channel decision table that prefers the quiet door, a bounded self-reversing focus flash when only UI Automation can reach the control, an opt-in takeover tier (policy full AND takeoverAllowed) where the real cursor moves to the action point and is always restored, a read surface that hands the model a numbered element frame plus screenshot coordinates as data so it never multiplies a scale factor, and since 0.6.0 a read-back of every write: effect=readback-verified only when the field's own value matches a prediction built from the control's measurements, with caretPosition, disabled/focus reporting and the capture path named as captureBackend. 0.7.0 adds the three desktop capabilities behind one ceiling (policy), an exact launch whitelist, an idle check that refuses instead of interrupting the owner, and an append-only JSONL audit log that records decisions and lengths but never payloads. Windows PowerShell 5.1 sidecar, zero install dependencies, no mouse injection.",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"deepseek",
|
|
12
12
|
"deepseek-harness",
|
package/src/engine/decide.ps1
CHANGED
|
@@ -48,6 +48,32 @@ $script:WpmRefusals = @{
|
|
|
48
48
|
needs_facts = 'the caller supplied no measured facts for this target; refusing instead of assuming quiet'
|
|
49
49
|
takeover_unavailable = 'takeover was requested but cannot run safely right now: the HUD is not up, or the takeover gate is off. Next step: enable takeoverAllowed in settings (the HUD is a hard precondition, not a decoration) or call without takeover:true'
|
|
50
50
|
keyinject_unavailable= 'keyboard injection was requested but cannot run: this target is not the foreground window and could not be raised (or it is elevated). Next step: bring the target to the front yourself, or call without keyInput:''inject'''
|
|
51
|
+
# ---- 0.7.0 authorization model. Three codes, each naming the NEXT STEP rather than describing the
|
|
52
|
+
# symptom, because all three are settings decisions and a caller that cannot tell which setting to
|
|
53
|
+
# raise will retry the same call forever.
|
|
54
|
+
policy_denied = 'the action''s declared tier is above what the policy setting allows. Next step: raise policy in settings (readonly < quiet < balanced < full) -- NOT retrying this call'
|
|
55
|
+
user_active = 'the owner was at the keyboard when this was asked for (last physical input younger than policyIdleMs) and the action needs the takeover tier. This product does not open a dialog at someone who is typing -- a popup is a second disturbance dressed as consent. Next step: wait for idle, or pass forceUserActive:true explicitly (it is recorded in the audit log as forced)'
|
|
56
|
+
app_launch_denied = 'launch is not authorised: appLaunchAllowed is off, or the program is not on the appLaunchAllow whitelist (an empty whitelist means nothing may launch). Next step: the OWNER adds the exact name to the whitelist; a wildcard does not exist and this refusal is not a transient failure to retry through'
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# THE LADDER, mirrored from lib/policy.js. Two copies of an ordering is normally the bug pattern this
|
|
60
|
+
# repo refuses, and it is allowed here for exactly one reason: the engine and the host each need the
|
|
61
|
+
# comparison in their own process, and scripts/check-policy-table.mjs asserts the two copies agree
|
|
62
|
+
# (rung set, order, and every action's declared tier in tools.json). A drift between them is red at build
|
|
63
|
+
# time instead of being a permission the owner believes they revoked.
|
|
64
|
+
$script:WpmTierOrder = @('readonly', 'quiet', 'flash', 'takeover')
|
|
65
|
+
$script:WpmPolicyCeiling = @{
|
|
66
|
+
readonly = 'readonly'; quiet = 'quiet'; balanced = 'flash'; full = 'takeover'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function Test-WpmTierAllowed {
|
|
70
|
+
# Pure, and it fails CLOSED in both directions: an unknown policy or an unknown rung answers false.
|
|
71
|
+
# "Unparseable setting" and "everything allowed" must never read the same way.
|
|
72
|
+
param([string]$Policy, [string]$Required)
|
|
73
|
+
if (-not $script:WpmPolicyCeiling.ContainsKey($Policy)) { return $false }
|
|
74
|
+
$need = [Array]::IndexOf($script:WpmTierOrder, $Required)
|
|
75
|
+
if ($need -lt 0) { return $false }
|
|
76
|
+
return $need -le [Array]::IndexOf($script:WpmTierOrder, $script:WpmPolicyCeiling[$Policy])
|
|
51
77
|
}
|
|
52
78
|
|
|
53
79
|
function New-WpmFacts {
|
|
@@ -69,7 +95,17 @@ function New-WpmFacts {
|
|
|
69
95
|
[bool]$KeyInjectRequested = $false, # caller asked for keyboard injection (keyInput:'inject')
|
|
70
96
|
[bool]$KeyInjectAllowed = $false, # the host gate (keyInjectAllowed) let the request through
|
|
71
97
|
[bool]$HudReady = $false, # hud.ps1 says a HUD window is up RIGHT NOW
|
|
72
|
-
[bool]$ForegroundIsTarget = $false # GetForegroundWindow() (or its root) IS this target
|
|
98
|
+
[bool]$ForegroundIsTarget = $false, # GetForegroundWindow() (or its root) IS this target
|
|
99
|
+
# ---- 0.7.0 authorization facts, supplied by the caller because decide.ps1 does no IO: it cannot
|
|
100
|
+
# read settings, and a table that read its own permissions could not be unit-tested.
|
|
101
|
+
[string]$Policy = 'balanced', # the ceiling the owner set (readonly|quiet|balanced|full)
|
|
102
|
+
[string]$RequiredTier = 'quiet', # what THIS action needs at minimum (tools.json#requiresTier)
|
|
103
|
+
[long]$LastInputAgeMs = -1, # -1 = UNKNOWN; unknown refuses, it does not mean "idle"
|
|
104
|
+
[int]$PolicyIdleMs = 3000,
|
|
105
|
+
[bool]$ForceUserActive = $false, # the caller's explicit override, recorded in the audit
|
|
106
|
+
[bool]$AppLaunchAllowed = $false,
|
|
107
|
+
[string[]]$AppLaunchAllow = @(),
|
|
108
|
+
[string]$LaunchTarget = ''
|
|
73
109
|
)
|
|
74
110
|
return @{
|
|
75
111
|
hwnd = $Hwnd; paused = $Paused; elevatedTarget = $ElevatedTarget; family = $Family
|
|
@@ -78,6 +114,9 @@ function New-WpmFacts {
|
|
|
78
114
|
uiaTreeEmpty = $UiaTreeEmpty; uiaProbeFailed = $UiaProbeFailed
|
|
79
115
|
takeoverRequested = $TakeoverRequested; keyInjectRequested = $KeyInjectRequested
|
|
80
116
|
keyInjectAllowed = $KeyInjectAllowed; hudReady = $HudReady; foregroundIsTarget = $ForegroundIsTarget
|
|
117
|
+
policy = $Policy; requiredTier = $RequiredTier
|
|
118
|
+
lastInputAgeMs = $LastInputAgeMs; policyIdleMs = $PolicyIdleMs; forceUserActive = $ForceUserActive
|
|
119
|
+
appLaunchAllowed = $AppLaunchAllowed; appLaunchAllow = $AppLaunchAllow; launchTarget = $LaunchTarget
|
|
81
120
|
}
|
|
82
121
|
}
|
|
83
122
|
|
|
@@ -102,15 +141,33 @@ function Get-WpmChannelDecision {
|
|
|
102
141
|
return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
|
|
103
142
|
refusal = 'paused'; reason = $script:WpmRefusals.paused }
|
|
104
143
|
}
|
|
105
|
-
|
|
144
|
+
# ---- 0.7.0 launch is not a windowed action, so the target checks do not apply to it ----------
|
|
145
|
+
# `no_hwnd` and `elevated_target` are statements ABOUT A TARGET WINDOW. `launch` has no target window at
|
|
146
|
+
# the moment it is decided -- that is precisely the point of the action -- and letting a hwnd check run
|
|
147
|
+
# first would turn every launch refusal into a wrong one (`no_hwnd` tells the caller to go find a
|
|
148
|
+
# handle, which is not what an unauthorised program name means). Guarded by the action rather than by
|
|
149
|
+
# handing the table a fake hwnd, because a fabricated fact in a decision table is how tables lie.
|
|
150
|
+
$isWindowedAction = $Facts.action -ne 'launch'
|
|
151
|
+
if ($isWindowedAction -and (-not $Facts.hwnd)) {
|
|
106
152
|
return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
|
|
107
153
|
refusal = 'no_hwnd'; reason = $script:WpmRefusals.no_hwnd }
|
|
108
154
|
}
|
|
109
|
-
if ($Facts.elevatedTarget) {
|
|
155
|
+
if ($isWindowedAction -and $Facts.elevatedTarget) {
|
|
110
156
|
return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
|
|
111
157
|
refusal = 'elevated_target'; reason = $script:WpmRefusals.elevated_target }
|
|
112
158
|
}
|
|
113
159
|
|
|
160
|
+
# ---- 0.7.0-A the policy ceiling, BEFORE any capability is consulted --------------------------
|
|
161
|
+
# Why here and not at the takeover branch: `policy` answers "may this rung be used at all", and a
|
|
162
|
+
# capability check that runs first can produce a working channel for an action the owner excluded --
|
|
163
|
+
# the same ordering mistake the pause check documents above. The refusal names the setting to raise,
|
|
164
|
+
# because the correct response to this code is a settings change, never a retry.
|
|
165
|
+
if (-not (Test-WpmTierAllowed $Facts.policy $Facts.requiredTier)) {
|
|
166
|
+
return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
|
|
167
|
+
refusal = 'policy_denied'
|
|
168
|
+
reason = $script:WpmRefusals.policy_denied + " [action needs $($Facts.requiredTier); policy '$($Facts.policy)' allows at most $($script:WpmPolicyCeiling[$Facts.policy])]" }
|
|
169
|
+
}
|
|
170
|
+
|
|
114
171
|
# ---- R3 preconditions. These are refusals about the REQUEST, not about the target, and they come
|
|
115
172
|
# before the door table because a takeover that cannot show its HUD must not reach any primitive.
|
|
116
173
|
if ($Facts.takeoverRequested -and -not $Facts.hudReady) {
|
|
@@ -128,6 +185,66 @@ function Get-WpmChannelDecision {
|
|
|
128
185
|
refusal = 'keyinject_unavailable'; reason = $script:WpmRefusals.keyinject_unavailable }
|
|
129
186
|
}
|
|
130
187
|
|
|
188
|
+
# ---- 0.7.0 the launch gate and its whitelist, double-checked here -----------------------------
|
|
189
|
+
# The host applies this BEFORE any worker request; this is the second line, because a permission that
|
|
190
|
+
# exists only in one process is a permission that can be reached around by calling the other one (the
|
|
191
|
+
# same argument that puts the HUD re-check in engine.ps1 rather than trusting the gate). ORDER MATTERS:
|
|
192
|
+
# this runs after the per-tier preconditions and BEFORE the idle check, which is the sequence the plan
|
|
193
|
+
# specifies -- an unauthorised program must be reported as unauthorised, not as "the owner is busy",
|
|
194
|
+
# because the two refusals tell the caller to change two different things.
|
|
195
|
+
if ($Facts.action -eq 'launch') {
|
|
196
|
+
if (-not $Facts.appLaunchAllowed) {
|
|
197
|
+
return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
|
|
198
|
+
refusal = 'app_launch_denied'; reason = $script:WpmRefusals.app_launch_denied + ' [appLaunchAllowed is off]' }
|
|
199
|
+
}
|
|
200
|
+
$t = if ($Facts.launchTarget) { $Facts.launchTarget.ToLower() } else { '' }
|
|
201
|
+
$hit = $false
|
|
202
|
+
foreach ($w in @($Facts.appLaunchAllow)) {
|
|
203
|
+
# EXACT match, case-folded. No wildcard, no prefix, no substring: `notepad` must not authorise
|
|
204
|
+
# `notepad-helper.exe`, and a prefix rule is the shape of a whitelist that expands by accident.
|
|
205
|
+
if ($w -and ([string]$w).Trim().ToLower() -ceq $t) { $hit = $true; break }
|
|
206
|
+
}
|
|
207
|
+
if (-not $hit) {
|
|
208
|
+
return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
|
|
209
|
+
refusal = 'app_launch_denied'
|
|
210
|
+
reason = $script:WpmRefusals.app_launch_denied + " [no exact entry for '$t'; whitelist holds $(@($Facts.appLaunchAllow).Count) name(s)]" }
|
|
211
|
+
}
|
|
212
|
+
# Fall through to the idle check below: an authorised name is still not permission to start a program
|
|
213
|
+
# while someone is typing at this keyboard.
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
# ---- 0.7.0-B idle sensing: the owner is at the keyboard, so do not interrupt them -------------
|
|
217
|
+
# Only a takeover-tier action is refused here. The quiet and flash tiers do not touch the owner's
|
|
218
|
+
# cursor or hold their focus, so "you are busy" does not apply to them -- refusing those would refuse
|
|
219
|
+
# the reason this product exists. `launch` reaches here with requiredTier 'takeover', so starting a
|
|
220
|
+
# program while the owner is typing is refused too: that is the plan's order, and it is the correct
|
|
221
|
+
# one, because a program started at the wrong moment is the least interruptible action in this product.
|
|
222
|
+
#
|
|
223
|
+
# AN UNKNOWN AGE ALLOWS, and that is a decision rather than an oversight. `LastInputAgeMs` answers -1
|
|
224
|
+
# when GetLastInputInfo fails; refusing on -1 would block every takeover on a machine where that one
|
|
225
|
+
# API does not answer, and the owner who opted into takeoverAllowed has already accepted the tier. This
|
|
226
|
+
# is the OPPOSITE of how the proof path treats -1 (there, unknown must never be read as "the desktop
|
|
227
|
+
# was still", because that would launder a disturbance into innocence) -- the two directions differ
|
|
228
|
+
# because the costs differ: here unknown costs an agent a convenience, there it costs the owner the
|
|
229
|
+
# truth. Both choices are stated where the comparison is made rather than inherited from a convention.
|
|
230
|
+
#
|
|
231
|
+
# Written as one-line conditions: a multi-line `if (A -and -not B` newline `-and C)` expression reads
|
|
232
|
+
# fine to a human and fails the PowerShell parser at the `-and` that opens the continuation line -- a
|
|
233
|
+
# runtime-only parse failure in a dot-sourced file, which surfaces as `action_failed` from the worker.
|
|
234
|
+
$needsTakeover = ($Facts.requiredTier -eq 'takeover')
|
|
235
|
+
$ageKnown = ([long]$Facts.lastInputAgeMs -ge 0)
|
|
236
|
+
$ownerPresent = ($ageKnown -and ([long]$Facts.lastInputAgeMs -lt [int]$Facts.policyIdleMs))
|
|
237
|
+
if ($needsTakeover -and $ownerPresent -and (-not $Facts.forceUserActive)) {
|
|
238
|
+
return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
|
|
239
|
+
refusal = 'user_active'
|
|
240
|
+
reason = $script:WpmRefusals.user_active + " [last physical input $($Facts.lastInputAgeMs)ms ago; policyIdleMs=$($Facts.policyIdleMs)]" }
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if ($Facts.action -eq 'launch') {
|
|
244
|
+
return @{ channel = 'launch'; tier = 'takeover'; needsRestore = $false; refusal = ''
|
|
245
|
+
reason = 'launch is authorised by both switches and the owner is not at the keyboard' }
|
|
246
|
+
}
|
|
247
|
+
|
|
131
248
|
$tier = if ($Facts.takeoverRequested) { 'takeover' } else { 'quiet' }
|
|
132
249
|
|
|
133
250
|
# TIER 1: message door. Measured free -- 0/6 raises, effect verified app-side in 6/6, cursor 0 px.
|