dsh-windows-parallel-mcp 0.4.1 → 0.5.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 +6 -0
- package/CHANGELOG.es.md +6 -0
- package/CHANGELOG.fr.md +6 -0
- package/CHANGELOG.it.md +6 -0
- package/CHANGELOG.ja.md +6 -0
- package/CHANGELOG.ko.md +6 -0
- package/CHANGELOG.md +123 -0
- package/CHANGELOG.pt.md +6 -0
- package/CHANGELOG.ru.md +6 -0
- package/CHANGELOG.zh.md +6 -0
- package/README.de.md +77 -10
- package/README.es.md +77 -10
- package/README.fr.md +77 -10
- package/README.it.md +77 -10
- package/README.ja.md +77 -10
- package/README.ko.md +77 -10
- package/README.md +77 -10
- package/README.pt.md +77 -10
- package/README.ru.md +77 -10
- package/README.zh.md +77 -10
- package/docs/refusals.md +7 -4
- package/dsh.plugin.json +3 -3
- package/lib/config.js +14 -0
- package/lib/host-tools.js +61 -3
- package/lib/index.js +272 -14
- package/package.json +6 -3
- package/src/engine/engine.ps1 +217 -3
- package/src/engine/win.ps1 +588 -1
- package/src/engine/worker.ps1 +35 -1
- package/src/schema/tools.json +115 -9
- package/types/index.d.ts +63 -3
package/src/engine/engine.ps1
CHANGED
|
@@ -140,8 +140,13 @@ function Get-WpmProofWindow {
|
|
|
140
140
|
|
|
141
141
|
function Invoke-WpmAction {
|
|
142
142
|
param(
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
# NOT Mandatory any more: a full-screen screenshot (screenshot + fullScreen:true) legitimately has
|
|
144
|
+
# no target window, and PowerShell REFUSES to bind an empty string to a Mandatory [string]
|
|
145
|
+
# parameter -- which surfaced as "cannot bind argument to parameter 'Hwnd' because it is an empty
|
|
146
|
+
# string" instead of the capture the caller asked for. Every windowed action still checks liveness
|
|
147
|
+
# itself and returns no_hwnd, so nothing was made lenient except the binding.
|
|
148
|
+
[string]$Hwnd = '',
|
|
149
|
+
[Parameter(Mandatory)][ValidateSet('click', 'type', 'focus', 'status', 'snapshot', 'screenshot', 'preview')][string]$Action,
|
|
145
150
|
[int]$X = -1,
|
|
146
151
|
[int]$Y = -1,
|
|
147
152
|
[string]$Text = '',
|
|
@@ -156,7 +161,24 @@ function Invoke-WpmAction {
|
|
|
156
161
|
[int]$TakeoverMaxMs = 10000,
|
|
157
162
|
[switch]$KeyInject,
|
|
158
163
|
[int]$TakeoverArmMs = 800,
|
|
159
|
-
[int]$HudDoneMs = 1500
|
|
164
|
+
[int]$HudDoneMs = 1500,
|
|
165
|
+
# ---- 0.5.0 read paths and element addressing ------------------------------------------------
|
|
166
|
+
# `Space` is the coordinate space of X/Y for click. 'image' means the numbers came from a
|
|
167
|
+
# screenshot and the ENGINE converts them: the caller never multiplies a scale factor, which is
|
|
168
|
+
# the failure the upstream library documents against itself ("Click lands in the wrong place").
|
|
169
|
+
[ValidateSet('screen', 'image')][string]$Space = 'screen',
|
|
170
|
+
[string]$ShotId = '',
|
|
171
|
+
# A label is a reference into the LAST frame this worker printed. It is resolved back to the UIA
|
|
172
|
+
# element by RuntimeId, so a labelled action still takes the silent pattern path.
|
|
173
|
+
[int]$Label = 0,
|
|
174
|
+
[string]$SnapId = '',
|
|
175
|
+
[int]$MaxElements = 300,
|
|
176
|
+
[bool]$InteractableOnly = $true,
|
|
177
|
+
[string]$SinceSnapId = '',
|
|
178
|
+
[string]$Intent = '',
|
|
179
|
+
[bool]$FullScreen = $false,
|
|
180
|
+
[int]$MaxWidth = 0,
|
|
181
|
+
[int]$ShotsKeep = 10
|
|
160
182
|
)
|
|
161
183
|
$started = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
|
|
162
184
|
$h = [IntPtr][int64]$Hwnd
|
|
@@ -189,6 +211,139 @@ function Invoke-WpmAction {
|
|
|
189
211
|
$result.lastInputAgeMs = $st.lastInputAgeMs
|
|
190
212
|
$result.paused = $st.paused
|
|
191
213
|
$result.stance = $st.stance
|
|
214
|
+
# The DPI stance travels with status because the read paths (snapshot rects, screenshot pixels)
|
|
215
|
+
# are only in PHYSICAL pixels while this process is per-monitor DPI aware. A future deletion of the
|
|
216
|
+
# setter would otherwise turn the whole coordinate story half-scale with nothing to notice.
|
|
217
|
+
$result.dpiAware = [bool]$st.dpiAware
|
|
218
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
219
|
+
return $result
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
# ---- 0.5.0 READ PATHS: snapshot / screenshot / preview --------------------------------------
|
|
223
|
+
# A READ IS NOT AN ACTION. None of these three writes an input-queue entry, takes the focus, or
|
|
224
|
+
# produces a proof window -- there is no action to prove. They sit before the hwnd check because a
|
|
225
|
+
# full-screen capture has no target window at all; each branch performs its own liveness check, so a
|
|
226
|
+
# dead handle is still `no_hwnd` and a paused engine still says `paused` rather than serving reads.
|
|
227
|
+
if ($Action -eq 'snapshot' -or $Action -eq 'screenshot' -or $Action -eq 'preview') {
|
|
228
|
+
if ([WpmCtl]::Paused) {
|
|
229
|
+
$result.refusal = 'paused'; $result.reason = $script:WpmRefusals.paused
|
|
230
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
231
|
+
return $result
|
|
232
|
+
}
|
|
233
|
+
$needsWindow = -not ($Action -eq 'screenshot' -and $FullScreen)
|
|
234
|
+
if ($needsWindow -and (-not $h -or -not [WpmWin]::IsWindow($h))) {
|
|
235
|
+
$result.refusal = 'no_hwnd'; $result.reason = 'the hwnd does not identify a live window'
|
|
236
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
237
|
+
return $result
|
|
238
|
+
}
|
|
239
|
+
$result.channel = 'none'; $result.tier = 'none'
|
|
240
|
+
if ($Action -eq 'snapshot') {
|
|
241
|
+
try {
|
|
242
|
+
$snap = Get-WpmSnapshotTree -Hwnd $h -MaxElements $MaxElements -InteractableOnly $InteractableOnly `
|
|
243
|
+
-Intent $Intent -SinceSnapId $SinceSnapId
|
|
244
|
+
} catch {
|
|
245
|
+
$result.refusal = 'uia_probe_failed'
|
|
246
|
+
$result.reason = 'the accessibility probe threw while walking the tree: ' + $_.Exception.Message
|
|
247
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
248
|
+
return $result
|
|
249
|
+
}
|
|
250
|
+
$snapFrame = if ($snap.ContainsKey('frame')) { [string]$snap.frame } else { '' }
|
|
251
|
+
$snapCheck = if ($snap.ContainsKey('frameCheck')) { [string]$snap.frameCheck } else { '' }
|
|
252
|
+
if (-not $snap.ok) {
|
|
253
|
+
# THREE FAILURE WORLDS, three codes: a superseded id is stale_ref (re-read the frame); a frame
|
|
254
|
+
# self-check failure is a refusal to point at all (unreachable -- the coordinates cannot be
|
|
255
|
+
# trusted); anything else means the walk itself failed to measure (uia_probe_failed).
|
|
256
|
+
if ($snap.stale) { $result.refusal = 'stale_ref' }
|
|
257
|
+
elseif ($snapCheck -eq 'fail') { $result.refusal = 'unreachable' }
|
|
258
|
+
else { $result.refusal = 'uia_probe_failed' }
|
|
259
|
+
$result.reason = [string]$snap.reason
|
|
260
|
+
$result.frame = $snapFrame
|
|
261
|
+
$result.frameCheck = $snapCheck
|
|
262
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
263
|
+
return $result
|
|
264
|
+
}
|
|
265
|
+
$result.ok = $true
|
|
266
|
+
$result.detail = 'snapshot: read only, no action taken'
|
|
267
|
+
$result.snapId = [string]$snap.snapId
|
|
268
|
+
$result.frame = $snapFrame
|
|
269
|
+
$result.frameCheck = $snapCheck
|
|
270
|
+
$result.frameInset = $snap.frameInset
|
|
271
|
+
$result.outsideFrame = [int]$snap.outsideFrame
|
|
272
|
+
$result.intent = [string]$snap.intent
|
|
273
|
+
$result.total = [int]$snap.total
|
|
274
|
+
$result.count = [int]$snap.count
|
|
275
|
+
$result.truncated = [bool]$snap.truncated
|
|
276
|
+
$result.elements = @($snap.elements)
|
|
277
|
+
$result.delta = $snap.delta
|
|
278
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
279
|
+
return $result
|
|
280
|
+
}
|
|
281
|
+
if ($Action -eq 'screenshot') {
|
|
282
|
+
try {
|
|
283
|
+
$shot = Get-WpmScreenshot -Hwnd $h -FullScreen $FullScreen -MaxWidth $MaxWidth -Keep $ShotsKeep
|
|
284
|
+
} catch {
|
|
285
|
+
$result.refusal = 'action_failed'
|
|
286
|
+
$result.reason = 'the capture threw: ' + $_.Exception.Message
|
|
287
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
288
|
+
return $result
|
|
289
|
+
}
|
|
290
|
+
if (-not $shot.ok) {
|
|
291
|
+
$result.refusal = 'action_failed'; $result.reason = [string]$shot.reason
|
|
292
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
293
|
+
return $result
|
|
294
|
+
}
|
|
295
|
+
$result.ok = $true
|
|
296
|
+
$result.detail = 'screenshot: read only, no action taken'
|
|
297
|
+
$result.shotId = [string]$shot.shotId
|
|
298
|
+
$result.file = [string]$shot.file
|
|
299
|
+
$result.screenRect = $shot.screenRect
|
|
300
|
+
$result.imageSize = $shot.imageSize
|
|
301
|
+
$result.scale = [double]$shot.scale
|
|
302
|
+
$result.identity = [bool]$shot.identity
|
|
303
|
+
$result.frame = [string]$shot.frame
|
|
304
|
+
$result.dpiAware = [bool]$shot.dpiAware
|
|
305
|
+
$result.bytes = [long]$shot.bytes
|
|
306
|
+
$result.shotsKeep = [int]$shot.shotsKeep
|
|
307
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
308
|
+
return $result
|
|
309
|
+
}
|
|
310
|
+
# ---- preview: draw the point, report the element under it as TEXT -------------------------
|
|
311
|
+
$pv = Get-WpmPreviewAt -Hwnd $h -X $X -Y $Y
|
|
312
|
+
if (-not $pv.ok) {
|
|
313
|
+
if ($pv.outside) {
|
|
314
|
+
$result.refusal = 'unreachable'
|
|
315
|
+
$result.reason = 'the preview point does not belong to the target window: ' + [string]$pv.reason
|
|
316
|
+
} else {
|
|
317
|
+
# NOT `unreachable`: the point may be fine. The probe itself failed, so no conclusion about
|
|
318
|
+
# what is under it is licensed -- the same distinction uia_probe_failed already draws.
|
|
319
|
+
$result.refusal = 'uia_probe_failed'
|
|
320
|
+
$result.reason = [string]$pv.reason
|
|
321
|
+
}
|
|
322
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
323
|
+
return $result
|
|
324
|
+
}
|
|
325
|
+
# THE MARKER IS A REQUEST, NOT AN ACTION (overlay.ps1 Set-WpmOverlayMarker writes three fields and
|
|
326
|
+
# returns). A missing overlay downgrades to text only -- it must never fail the preview, because
|
|
327
|
+
# "what is under this point" is answerable without a picture.
|
|
328
|
+
$marker = @{ ok = $false; reason = 'overlay not loaded' }
|
|
329
|
+
try {
|
|
330
|
+
. (Join-Path $PSScriptRoot 'overlay.ps1')
|
|
331
|
+
$marker = Set-WpmOverlayMarker -X $X -Y $Y
|
|
332
|
+
} catch {
|
|
333
|
+
$marker = @{ ok = $false; reason = 'overlay unavailable: ' + $_.Exception.Message }
|
|
334
|
+
}
|
|
335
|
+
$result.ok = $true
|
|
336
|
+
$result.detail = 'preview: would click ' + $X + ',' + $Y
|
|
337
|
+
$result.previewX = [int]$X
|
|
338
|
+
$result.previewY = [int]$Y
|
|
339
|
+
$result.previewAtPoint = [bool]$pv.atPoint
|
|
340
|
+
$result.previewName = [string]$pv.name
|
|
341
|
+
$result.previewControlType = [string]$pv.controlType
|
|
342
|
+
$result.previewAutomationId = [string]$pv.automationId
|
|
343
|
+
$result.previewRect = $pv.rect
|
|
344
|
+
$result.previewReason = [string]$pv.reason
|
|
345
|
+
$result.markerPlaced = [bool]$marker.ok
|
|
346
|
+
$result.markerReason = if ($marker.ContainsKey('reason')) { [string]$marker.reason } else { '' }
|
|
192
347
|
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
193
348
|
return $result
|
|
194
349
|
}
|
|
@@ -198,11 +353,70 @@ function Invoke-WpmAction {
|
|
|
198
353
|
return $result
|
|
199
354
|
}
|
|
200
355
|
|
|
356
|
+
# ---- 0.5.0: image coordinates are converted by the ENGINE, before anything is probed ---------
|
|
357
|
+
# Why here: a bogus shotId must cost zero target probing, and the converted point then flows through
|
|
358
|
+
# the EXISTING click path unchanged -- including the point-ownership assertion and the proof window.
|
|
359
|
+
# Nothing about the safety contract is relaxed by accepting image coordinates.
|
|
360
|
+
if ($Action -eq 'click' -and $Space -eq 'image') {
|
|
361
|
+
$conv = Convert-WpmImagePoint -ShotId $ShotId -X $X -Y $Y
|
|
362
|
+
if (-not $conv.ok) {
|
|
363
|
+
$result.refusal = if ($conv.stale) { 'stale_ref' } else { 'unreachable' }
|
|
364
|
+
$result.reason = [string]$conv.reason
|
|
365
|
+
$result.coordSpace = 'image'
|
|
366
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
367
|
+
return $result
|
|
368
|
+
}
|
|
369
|
+
$result.coordSpace = 'image'
|
|
370
|
+
$result.shotId = [string]$ShotId
|
|
371
|
+
$result.scale = [double]$conv.scale
|
|
372
|
+
$result.imagePoint = "$X,$Y"
|
|
373
|
+
$result.screenPoint = "$($conv.x),$($conv.y)"
|
|
374
|
+
$X = [int]$conv.x
|
|
375
|
+
$Y = [int]$conv.y
|
|
376
|
+
}
|
|
377
|
+
|
|
201
378
|
# Coordinates travel into the probe: the UIA tier resolves the element AT THE POINT. Without them
|
|
202
379
|
# an unnamed click had no way to be anything other than "first control in tree order".
|
|
203
380
|
$probe = Get-WpmFacts -Hwnd $h -Action $Action -ElementName $ElementName -X $X -Y $Y
|
|
204
381
|
$facts = $probe.facts
|
|
205
382
|
$facts.paused = [bool][WpmCtl]::Paused
|
|
383
|
+
# ---- 0.5.0: a LABEL addresses the element itself -------------------------------------------
|
|
384
|
+
# The label is resolved back to the UIA element by RuntimeId (measured stable across queries, 71/71),
|
|
385
|
+
# so the action keeps the silent pattern path and never degrades into a coordinate click. Two things
|
|
386
|
+
# are then enforced, and they are deliberately redundant:
|
|
387
|
+
# * the label must still resolve, otherwise this is a reference to a frame that is gone (stale_ref);
|
|
388
|
+
# * for a click, the caller's point must fall inside the labelled element -- "the point is the
|
|
389
|
+
# contract" is not weakened by adding a second way to name the target.
|
|
390
|
+
if ($Label -gt 0) {
|
|
391
|
+
$res = Resolve-WpmSnapshotLabel -Hwnd $h -Label $Label -SnapId $SnapId
|
|
392
|
+
if (-not $res.ok) {
|
|
393
|
+
$result.refusal = 'stale_ref'; $result.reason = [string]$res.reason
|
|
394
|
+
$result.label = $Label
|
|
395
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
396
|
+
return $result
|
|
397
|
+
}
|
|
398
|
+
if ($Action -eq 'click' -and $X -ge 0 -and $Y -ge 0) {
|
|
399
|
+
$lr = $res.row.rect
|
|
400
|
+
$eps = 2
|
|
401
|
+
if ($X -lt ([int]$lr.left - $eps) -or $X -gt ([int]$lr.right + $eps) -or
|
|
402
|
+
$Y -lt ([int]$lr.top - $eps) -or $Y -gt ([int]$lr.bottom + $eps)) {
|
|
403
|
+
$result.refusal = 'unreachable'
|
|
404
|
+
$result.reason = "label $Label is at rect=$($lr.left),$($lr.top),$($lr.right),$($lr.bottom) but the click point is $X,$Y -- the label and the point must agree before either is used"
|
|
405
|
+
$result.label = $Label
|
|
406
|
+
$result.latencyMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $started
|
|
407
|
+
return $result
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
$probe.uiaElement = $res.element
|
|
411
|
+
$probe.uiaReason = ''
|
|
412
|
+
$facts.hasPattern = $true
|
|
413
|
+
$facts.patternKind = [string]$res.patternKind
|
|
414
|
+
$facts.uiaTreeEmpty = $false
|
|
415
|
+
$facts.uiaProbeFailed = $false
|
|
416
|
+
$facts.messageDoor = $false # a window message cannot address "label 3"
|
|
417
|
+
$result.label = $Label
|
|
418
|
+
$result.snapId = [string]$res.snapId
|
|
419
|
+
}
|
|
206
420
|
if ($ElementName) {
|
|
207
421
|
# A named control cannot be addressed through a window message: the message tiers take
|
|
208
422
|
# coordinates or a child HWND, and "the Save button" is neither. Suppressing the door here is
|