dsh-windows-parallel-mcp 0.1.6 → 0.3.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 +374 -0
- package/CHANGELOG.es.md +374 -0
- package/CHANGELOG.fr.md +374 -0
- package/CHANGELOG.it.md +374 -0
- package/CHANGELOG.ja.md +374 -0
- package/CHANGELOG.ko.md +374 -0
- package/CHANGELOG.md +116 -1
- package/CHANGELOG.pt.md +374 -0
- package/CHANGELOG.ru.md +374 -0
- package/CHANGELOG.zh.md +374 -0
- package/INSTALL.de.md +126 -0
- package/INSTALL.es.md +126 -0
- package/INSTALL.fr.md +126 -0
- package/INSTALL.it.md +126 -0
- package/INSTALL.ja.md +126 -0
- package/INSTALL.ko.md +126 -0
- package/INSTALL.md +49 -11
- package/INSTALL.pt.md +126 -0
- package/INSTALL.ru.md +126 -0
- package/INSTALL.zh.md +126 -0
- package/README.de.md +275 -0
- package/README.es.md +275 -0
- package/README.fr.md +275 -0
- package/README.it.md +275 -0
- package/README.ja.md +275 -0
- package/README.ko.md +275 -0
- package/README.md +114 -24
- package/README.pt.md +275 -0
- package/README.ru.md +275 -0
- package/README.zh.md +275 -0
- 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 +38 -4
- 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
- package/types/index.d.ts +68 -0
package/README.zh.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# dsh-windows-parallel-mcp
|
|
2
|
+
|
|
3
|
+
[English](README.md) · **中文** · [日本語](README.ja.md) · [한국어](README.ko.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Italiano](README.it.md) · [Español](README.es.md) · [Português](README.pt.md) · [Русский](README.ru.md)
|
|
4
|
+
|
|
5
|
+
> 一个让代理驱动**自己**的 Windows 窗口的 DSH 插件——默认静默,按需可见。窗口接受窗口消息时完全不夺焦点;只有 UI Automation 可达时,焦点仅发生一次有界闪烁并自动还原;显式请求接管档时,光标移动到目标点并始终还原,HUD 提供三种中断方式。其他情况一律拒绝,并给出代码与原因。
|
|
6
|
+
|
|
7
|
+
> **English canonical text follows.** The localized summary above is the orientation; the text below is the authoritative specification (structure, commands and numbers are identical across all 10 languages).
|
|
8
|
+
> **0.2.0 — the promise changes shape, deliberately.** Through 0.1.x this plugin's claim was "no
|
|
9
|
+
> physical input at all". 0.2.0 keeps that as the **default** and adds an **opt-in takeover tier**:
|
|
10
|
+
> with `takeoverAllowed` on and `takeover:true` on the call, the real cursor is moved to the action
|
|
11
|
+
> point (so you can see where the agent points) and always restored, the focus is held for the
|
|
12
|
+
> duration, and a three-phase HUD with a stop button and a global abort key is mandatory. Keyboard
|
|
13
|
+
> injection exists only inside that tier, only when asked (`keyInput:"inject"`), and only for
|
|
14
|
+
> targets with no other door — and, measured, it does **not** work on this host's terminal, so the
|
|
15
|
+
> terminal stays refused rather than becoming a promise. Both gates default off: an upgrade cannot
|
|
16
|
+
> start moving your cursor by itself. 0.1.6 split `unreachable` into `uia_tree_empty` and
|
|
17
|
+
> `uia_probe_failed`; 0.1.5 made a click act on the point it names; 0.1.3 added `effect=` — who
|
|
18
|
+
> reported the success — and let it enter the judgment. Full history: [CHANGELOG.md](CHANGELOG.md).
|
|
19
|
+
|
|
20
|
+
A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
|
|
21
|
+
on request. Where a window accepts a window message, you never lose focus at all. Where it only
|
|
22
|
+
exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
|
|
23
|
+
explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
|
|
24
|
+
HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason.
|
|
25
|
+
|
|
26
|
+
Source, the measurement scripts behind every number below, and the release history live at
|
|
27
|
+
**<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
|
|
28
|
+
"this target refused and I think it should not have".
|
|
29
|
+
|
|
30
|
+
Not affiliated with `dsh-windows-mcp`. Different plugin, different trade-off: that one is a carrier
|
|
31
|
+
bundle with a broad tool surface; this one is a single action tool whose entire design is about
|
|
32
|
+
*not* disturbing the desktop.
|
|
33
|
+
|
|
34
|
+
## What it does
|
|
35
|
+
|
|
36
|
+
One tool, five actions:
|
|
37
|
+
|
|
38
|
+
| action | what it returns |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `windows` | live windows that can be driven: hwnd, title, class, pid, rect |
|
|
41
|
+
| `status` | what currently holds the foreground and the keyboard focus, and whether the engine is paused |
|
|
42
|
+
| `click` | click at a screen coordinate inside the named window |
|
|
43
|
+
| `type` | write text into the target (a classic edit child, or a named UIA element) |
|
|
44
|
+
| `focus` | move keyboard focus to a named control inside the target |
|
|
45
|
+
|
|
46
|
+
The engine picks the cheapest available door per call:
|
|
47
|
+
|
|
48
|
+
- **quiet tier** — a classic child window receives the click/text as a window message. Measured:
|
|
49
|
+
0 foreground changes in 6 of 6 rounds, cursor moved 0 px. (Those 6 rounds also read the target
|
|
50
|
+
app's own state to confirm the click landed — that was a *separate* experiment, not the `effect=`
|
|
51
|
+
field, which says only who reported the call returned; see the table below.)
|
|
52
|
+
- **bounded-flash tier** — only UI Automation can reach the control, which raises the target. The
|
|
53
|
+
engine records the focus table *before* acting, reverses it **once** afterwards, and never pulls
|
|
54
|
+
focus from a window you chose. Measured net return **15–95 ms** from three independent
|
|
55
|
+
measurements (the 120 ms budget was never approached).
|
|
56
|
+
|
|
57
|
+
## What you see while it works
|
|
58
|
+
|
|
59
|
+
After a successful `click` a small marker is placed at the point that was clicked. It is a
|
|
60
|
+
click-through, always-on-top window with `WS_EX_TOPMOST | WS_EX_NOACTIVATE | WS_EX_TRANSPARENT`:
|
|
61
|
+
measured that `Show()` does not change `GetForegroundWindow`, that `WindowFromPoint` at the marker's
|
|
62
|
+
centre returns the window *underneath*, and that a real click through the shipped plugin puts the
|
|
63
|
+
marker over the point it hit (physical pixels; the process declares DPI awareness, because using
|
|
64
|
+
WPF's device-independent units put the marker at half scale on a 150% display). It hides itself
|
|
65
|
+
1.5 s after the last placement. Cost: ~19 ms per placement, fired after the action has already
|
|
66
|
+
answered; the first action pays a one-time ~875 ms while the overlay starts.
|
|
67
|
+
|
|
68
|
+
**The pause key is not a fixed key.** `Ctrl+Alt+Q` is the first candidate, but it can already be
|
|
69
|
+
owned by another app — on the machine this was measured on it was (Win32 1409), and seven of the
|
|
70
|
+
other eight measured candidates were free. The engine walks a candidate list, registers the first
|
|
71
|
+
free chord, and **reports what it actually registered** in `status` as `pauseHotkey=...`. It never
|
|
72
|
+
silently claims the documented key works. `overlay=true` in settings controls the marker; the pause
|
|
73
|
+
flag itself is engine-side and refuses actions with `paused`.
|
|
74
|
+
|
|
75
|
+
Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
|
|
76
|
+
`uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `takeover_unavailable`,
|
|
77
|
+
`keyinject_unavailable`, `action_failed`, `restore_failed`, `takeover_aborted`. Each carries a reason
|
|
78
|
+
and a next step — see [docs/refusals.md](docs/refusals.md).
|
|
79
|
+
|
|
80
|
+
**Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
|
|
81
|
+
verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
|
|
82
|
+
samples cursor position, foreground window, keyboard focus and last-physical-input age — in a short
|
|
83
|
+
pre-action control window (when, by construction, nothing was running) and inside the settle wait it
|
|
84
|
+
already pays. The judgment is one pure function (`lib/proof-window.mjs`, unit-tested against 40
|
|
85
|
+
synthetic windows whose answers are known by construction). What it honestly can and cannot say:
|
|
86
|
+
a switch of foreground on a quiet tier fails — the control shows the desktop was not doing it, so it
|
|
87
|
+
is the action's to explain; a cursor jump is *reported*, never accused, because with nothing running
|
|
88
|
+
this desktop's cursor showed multi-gap unexplained motion on its own (a re-runnable probe ships:
|
|
89
|
+
`scripts/idle-baseline.mjs`). The cursor promise therefore lives where blame is decidable: a build
|
|
90
|
+
gate confines `SetCursorPos` to `takeover.ps1` and `SendInput` to `input-inject.ps1`, bans
|
|
91
|
+
`MOUSEEVENTF_*`/`mouse_event`/`keybd_event` everywhere, and a second gate asserts the structural
|
|
92
|
+
promises around them (the HUD is checked before any primitive runs; the cursor move and its restore
|
|
93
|
+
share one `try/finally`). A regression fails at build time with certainty instead of being hunted at
|
|
94
|
+
runtime among ambient motion. In the takeover tier the cursor motion is **declared**, so it is
|
|
95
|
+
reported rather than accused — but `cursorRestored=false` (borrowed and not returned) is a hard
|
|
96
|
+
`proof=fail`.
|
|
97
|
+
|
|
98
|
+
**And it says who reported the success.** Every action result carries `effect=` in the text and
|
|
99
|
+
`effect` in the structured output. The three values are not degrees of confidence in the
|
|
100
|
+
application — they name the speaker:
|
|
101
|
+
|
|
102
|
+
| `effect` | who is speaking | it proves | it does **not** prove |
|
|
103
|
+
|---|---|---|---|
|
|
104
|
+
| `unverified` | nobody | nothing | anything |
|
|
105
|
+
| `reported-by-send` | the window-message channel | the message was **delivered** | that the target app processed it |
|
|
106
|
+
| `reported-by-pattern` | the UI Automation pattern call | the call **returned** without throwing | that the interface actually changed |
|
|
107
|
+
|
|
108
|
+
Since 0.1.3 the effect also enters the judgment, which closes the one honest gap 0.1.2 still had:
|
|
109
|
+
a still desktop could outvote a total no-op. A call whose channel reported nothing is capped at
|
|
110
|
+
`inconclusive` — never `pass`. A batch caller that passes its per-attempt results (`actions`) gets
|
|
111
|
+
`fail` when **no** attempt took effect, however few pixels moved. Displacement proves we did not
|
|
112
|
+
disturb you; it never proves we accomplished anything. A single `reported-by-*` stays a `pass` with
|
|
113
|
+
the caveat spelled out in the reason field (`未独立验证` — nobody observed the app), because turning
|
|
114
|
+
weak-but-real evidence into a red would train its readers to ignore the verdict.
|
|
115
|
+
|
|
116
|
+
## The takeover tier (opt-in)
|
|
117
|
+
|
|
118
|
+
Off by default (`takeoverAllowed=false`, `keyInjectAllowed=false`), because moving someone's pointer
|
|
119
|
+
is not something an upgrade should switch on. When you turn it on and pass `takeover:true`:
|
|
120
|
+
|
|
121
|
+
1. **arming** — **amber** HUD (`#3A2C0C` surface, `#F0AD18` accent bar). Says what is about to be
|
|
122
|
+
borrowed (cursor / keyboard / focus), with the interrupt key that actually registered. Default
|
|
123
|
+
800 ms; this is the cancellation window.
|
|
124
|
+
2. **active** — **red** HUD (`#3A1212` / `#E84040`). The cursor is placed on the action point, the
|
|
125
|
+
action runs through the cheapest existing door, and the HUD counts elapsed/limit and characters
|
|
126
|
+
injected.
|
|
127
|
+
3. **done** — **green** HUD (`#0E2E1E` / `#34C77B`). The cursor is restored (read-back verified), the
|
|
128
|
+
focus is returned through the same one-shot table, and the HUD says so.
|
|
129
|
+
|
|
130
|
+
The colour is not decoration: while an agent borrows the pointer the owner is looking at the *target*
|
|
131
|
+
window, so the phase is encoded twice — the whole surface tint **and** a 5px accent bar — and
|
|
132
|
+
`test/hud-test.ps1` reads the real pixels to assert the three are distinct (C18). Amber = not yet
|
|
133
|
+
(cancellable), red = holding something of yours right now, green = returned.
|
|
134
|
+
|
|
135
|
+
**The keys, which are easy to mix up:**
|
|
136
|
+
|
|
137
|
+
| | key |
|
|
138
|
+
|---|---|
|
|
139
|
+
| interrupt the running takeover | **`Ctrl+Alt+X`** (the one that registered; candidates `X→Z→C→V→B→N` then `Ctrl+Shift+X`, displayed as `abortChord=`) |
|
|
140
|
+
| same thing, no keyboard | the HUD's 取消 / 停止 button (same flag, no priority) |
|
|
141
|
+
| pause the whole engine (also aborts a running takeover) | **`Ctrl+Alt+Q`**, here **`Ctrl+Alt+W`** because another app owns Q; `status` reports `pauseHotkey=` |
|
|
142
|
+
|
|
143
|
+
The abort chord lives only while the HUD exists (its window owns the registration); the pause key is a
|
|
144
|
+
permanent server-side switch. Three interruption paths, all writing the same flag/file: HUD button,
|
|
145
|
+
abort chord, and the host's cancellation (`exec.signal` → a latch file the engine polls, because the
|
|
146
|
+
worker is single-threaded and cannot read a request while an action is running). Interruption returns
|
|
147
|
+
`takeover_aborted` **with** `cursorRestored` and `injectedChars` — it is not a fault, it is the feature.
|
|
148
|
+
|
|
149
|
+
Keyboard injection (`keyInput:"inject"`) exists only inside this tier, because `SendInput` writes to
|
|
150
|
+
the **foreground** window: measured, text sent while another window was in front landed in that
|
|
151
|
+
window and not in the intended one. The engine therefore asserts `GetForegroundWindow() == target`
|
|
152
|
+
before sending, re-asserts at send time, and refuses with `keyinject_unavailable` otherwise. It never
|
|
153
|
+
injects mouse events — `MOUSEEVENTF_*` is banned repo-wide, so the module is structurally unable to
|
|
154
|
+
click. Success is reported as `effect=reported-by-send`, never as "verified". Unicode injection
|
|
155
|
+
carries no hardware scancode, which is why a rare scancode-only target would ignore it — documented,
|
|
156
|
+
not a bug.
|
|
157
|
+
|
|
158
|
+
## What it does not do
|
|
159
|
+
|
|
160
|
+
- **No mouse injection.** `MOUSEEVENTF_*`, `mouse_event` and `keybd_event` are banned in every
|
|
161
|
+
shipped file. The takeover tier moves the cursor instead of clicking synthetically — that is why
|
|
162
|
+
"the agent can type into the foreground" does not become "the agent can click anything".
|
|
163
|
+
- **No takeover without the HUD.** `takeover_unavailable` is a refusal, not a warning, and the
|
|
164
|
+
request is never downgraded silently into the quiet tier.
|
|
165
|
+
- **No forged-Alt foreground trick.** That route works and other plugins use it, but it injects a
|
|
166
|
+
real key event — a keystroke you make in that window can land in whichever window the trick just
|
|
167
|
+
raised.
|
|
168
|
+
- **No OCR / Set-of-Marks / pixel fallback.** Not part of this claim, and already done well elsewhere.
|
|
169
|
+
- **No watchdog.** The restore is one-shot and happens inline. A watchdog that keeps chasing the
|
|
170
|
+
foreground would fight you.
|
|
171
|
+
- **Terminals are still refused** (`terminal_no_door`), and now for a measured reason. The 0.2.0 plan
|
|
172
|
+
was to drive one by typing into it; two probes say otherwise on this host: 242 `KEYEVENTF_UNICODE`
|
|
173
|
+
events with the terminal in the foreground and Enter sent produced nothing, and a scan-code arm
|
|
174
|
+
(262 events, layout-correct) produced nothing either. Their text surface also exposes no writable
|
|
175
|
+
child and no `Document` element. The code stays, the reason names what does work (a target with a
|
|
176
|
+
real door), and the claim is withdrawn rather than shipped as a promise.
|
|
177
|
+
|
|
178
|
+
## Install
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
dsh plugin --profile <profile> add dsh-windows-parallel-mcp
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Requires Windows with Windows PowerShell 5.1 (it ships with Windows) — **no Python, no uv, no MSVC
|
|
185
|
+
runtime, no native module**. The engine is a PowerShell sidecar started lazily on the first tool
|
|
186
|
+
call, not at plugin load.
|
|
187
|
+
|
|
188
|
+
`engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
|
|
189
|
+
degradation.
|
|
190
|
+
|
|
191
|
+
## Settings
|
|
192
|
+
|
|
193
|
+
| key | default | effect |
|
|
194
|
+
|---|---|---|
|
|
195
|
+
| `enabled` | `true` | server-side gate: when off, every action refuses with `paused` before the engine is reached |
|
|
196
|
+
| `settleMs` | `350` | how long the app gets to commit state before the effect is judged |
|
|
197
|
+
| `requestTimeoutMs` | `20000` | a worker that stops answering is killed and restarted on the next call |
|
|
198
|
+
| `powershellPath` | `""` | override the interpreter (pwsh accepted) |
|
|
199
|
+
| `logWorkerStderr` | `false` | forward worker diagnostics to the host log |
|
|
200
|
+
| `takeoverAllowed` | `false` | allow `takeover:true`: cursor may move (always restored), focus held, HUD mandatory |
|
|
201
|
+
| `keyInjectAllowed` | `false` | allow `keyInput:"inject"` inside the takeover tier (keyboard only, foreground asserted) |
|
|
202
|
+
| `takeoverMaxMs` | `10000` | hard ceiling for one takeover action (500–60000); the HUD shows the clock |
|
|
203
|
+
| `takeoverArmMs` | `800` | length of the arming phase: the window in which you can cancel before anything moves |
|
|
204
|
+
|
|
205
|
+
## What measurement established
|
|
206
|
+
|
|
207
|
+
The hard gate was run on a real Windows desktop before any of this shipped, and part of the original
|
|
208
|
+
goal statement did not survive it. Kept here rather than quietly dropped:
|
|
209
|
+
|
|
210
|
+
- **Cursor: true.** Every channel tested produced 0 px of cursor displacement across 24 action
|
|
211
|
+
rounds, against a control arm that made no call.
|
|
212
|
+
- **"Keyboard focus never changes": false as a general property.** UIA pattern actions raised their
|
|
213
|
+
own target in 12/12 and 6/6 rounds with no mouse button down, no modifier key down and the cursor
|
|
214
|
+
outside the target rect; a no-call control arm raised 0/6 in the same conditions.
|
|
215
|
+
- **Window messages: true but narrow.** 6/6 effective, 0/6 raising. But a message needs an
|
|
216
|
+
*address*: only 17 of 57 live windows here have one, and the two largest families (UWP/WinUI,
|
|
217
|
+
Chromium/Electron) have none.
|
|
218
|
+
- **The complementary-exclusive catch:** on the toolkit where messages work (WinForms/classic),
|
|
219
|
+
UIA exposes no patterns at all; on the toolkits where UIA works (WPF/UWP/Chromium), there is no
|
|
220
|
+
message door. The identifiable door and the quiet door are never on the same window.
|
|
221
|
+
- **Restoration is measured, not assumed.** After a raise, the widget that held focus came back
|
|
222
|
+
6/6 and 6/6 in two independent runs, and internal focus (not just the window) returned 4/4.
|
|
223
|
+
- **The engine is often quieter than the budget suggests.** Under its real operating condition,
|
|
224
|
+
UIA `Invoke` was foreground-neutral in 0 of 12 rounds — the earlier 6/6 and 12/12 were measured
|
|
225
|
+
under a construction that first took the foreground away. The flash tier is a fuse, not a promise
|
|
226
|
+
of disturbance.
|
|
227
|
+
- **An empty accessibility tree is a switch, not a delay.** The alternative reading — Chromium
|
|
228
|
+
activates renderer accessibility on demand, so the tree might be merely slow — was tested, not
|
|
229
|
+
assumed away: the same window was re-read in place three times (+0/+700/+1500 ms,
|
|
230
|
+
`scripts/uia-tree-content.ps1`). uTools read **0/0/0** descendants, zero interactive content
|
|
231
|
+
elements every time (one earlier peek the same day saw a single `Chrome Legacy Window` shell
|
|
232
|
+
pane appear, content still 0); DSH on the same desktop read a real tree on the **first** query
|
|
233
|
+
(514 at census time, 1019 raw / 85 content on re-read). Nothing ever trickled in. So the
|
|
234
|
+
engine refuses with `uia_tree_empty` and does **not** poll — there is nothing to wait for — and
|
|
235
|
+
the actual switch is a launch-time state (`--force-renderer-accessibility`) the engine cannot
|
|
236
|
+
impose on a browser the user already has open. `unreachable` is the other world: the tree is
|
|
237
|
+
alive and offers nothing at the named point or element.
|
|
238
|
+
|
|
239
|
+
`elevated_target` is measured live: the engine compares the target's integrity RID against its own
|
|
240
|
+
and refuses before acting (verified on an elevated Task Manager; 19 medium windows, zero
|
|
241
|
+
misrefusals). The **restore-failure path on an elevated target** (`restore_failed`) remains
|
|
242
|
+
unmeasured end-to-end and is stated as such in [docs/refusals.md](docs/refusals.md).
|
|
243
|
+
|
|
244
|
+
### 0.2.0's four new measurements (all re-runnable from `scripts/`)
|
|
245
|
+
|
|
246
|
+
- **The cursor can be placed exactly and put back** — `scripts/probe-setcursor-pos.ps1`:
|
|
247
|
+
`SetCursorPos(+40,+20)` read back as exactly the requested point and the restore landed on the
|
|
248
|
+
original point. The elevated-foreground arm could not be arranged (a non-elevated process cannot
|
|
249
|
+
raise Task Manager), so it is recorded as unmeasured rather than guessed — the decision table
|
|
250
|
+
refuses elevated targets before this primitive anyway.
|
|
251
|
+
- **Injected characters go to the FOREGROUND window, not to the window you meant** —
|
|
252
|
+
`scripts/probe-sendinput-unicode.ps1`: with window B in front, the text landed in B and window A
|
|
253
|
+
received nothing; the reverse arm (A in front, including Chinese characters) landed in A. That is
|
|
254
|
+
the measurement S1 rests on.
|
|
255
|
+
- **The terminal cannot be typed into from here** — `scripts/probe-console-inject.ps1` and
|
|
256
|
+
`scripts/probe-console-scan.ps1`: Unicode and scan-code arms both accepted by `SendInput`, both
|
|
257
|
+
with the terminal in the foreground, neither executed. This is why the terminal claim is withdrawn.
|
|
258
|
+
- **A WPF window can be click-through on empty space while its button stays clickable** —
|
|
259
|
+
`scripts/probe-hittest-children.ps1`: the naive `HwndSource` hook received `WM_NCHITTEST` but its
|
|
260
|
+
return value did not reach hit-testing (empty point still answered `HTCLIENT`); a `WNDPROC`
|
|
261
|
+
subclass returning `HTTRANSPARENT` outside the button rect works — measured `-1` on empty space,
|
|
262
|
+
`WindowFromPoint` no longer returning the HUD, and `HTCLIENT` on the button. That is what
|
|
263
|
+
`hud.ps1` ships.
|
|
264
|
+
|
|
265
|
+
## Verifying the copy you actually installed
|
|
266
|
+
|
|
267
|
+
Every test above imports the repository checkout, so a package that installs to the wrong place or ships
|
|
268
|
+
a stale `lib/` would still pass all of them. `node test/smoke-installed.mjs <path-to-installed-package>`
|
|
269
|
+
drives the **installed** copy: it lists a real window, runs a takeover click, asserts
|
|
270
|
+
`takeover=on cursorRestored=true abortChord=…`, and checks that the HUD is torn down afterwards. Run once
|
|
271
|
+
against the desktop profile after installing, as the last step of a release.
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
MIT
|
package/docs/refusals.md
CHANGED
|
@@ -19,13 +19,13 @@ R2′ 把「拒绝」当成本产品的**正常结果**(`engine.ps1` 首段注
|
|
|
19
19
|
|
|
20
20
|
| 层 | 出处 | 数量 | 语义 |
|
|
21
21
|
|---|---|---|---|
|
|
22
|
-
| 决定层 | `src/engine/decide.ps1` 的 `$WpmRefusals` |
|
|
23
|
-
| 运行时失败层 | `src/engine/engine.ps1` 执行/回还段 |
|
|
22
|
+
| 决定层 | `src/engine/decide.ps1` 的 `$WpmRefusals` | 10 | 动作**在执行之前**被合法否决,目标本身没被碰过 |
|
|
23
|
+
| 运行时失败层 | `src/engine/engine.ps1` 执行/回还段 | 3 | 决定说「能做」,做的过程中通道炸了、回还没成,或**被所有者/宿主中断** |
|
|
24
24
|
|
|
25
25
|
混在一起会让人以为「10 个码都是设计好的分支」,实际后 2 个是**兜底**:它们出现就意味着
|
|
26
26
|
引擎的判断与实际能力不一致,属于需要调查的信号,不该被当成正常分支来轮询。
|
|
27
27
|
|
|
28
|
-
## 决定层(
|
|
28
|
+
## 决定层(10 码)
|
|
29
29
|
|
|
30
30
|
| 码 | 触发条件(代码位置) | 语义 | 下一步动作 | 实测状态 |
|
|
31
31
|
|---|---|---|---|---|
|
|
@@ -35,15 +35,18 @@ R2′ 把「拒绝」当成本产品的**正常结果**(`engine.ps1` 首段注
|
|
|
35
35
|
| `unreachable` | `decide.ps1:143`(测过:无消息门、无可用 pattern,**且树里有内容**);运行时窄路 `engine.ps1:246,255,261,275,281,291` | 树是活的、点也认了,但那个点/那个名字上没有任何可用 pattern——「换一处或换目标」的世界 | 换目标、换坐标或换元素名;或让目标暴露可寻址子窗(原生 Win32/WinForms) | **REAL** — R3:WinForms 目标按名字取控件 → 消息门被抑制、WinForms 无 pattern → 该码 |
|
|
36
36
|
| `uia_tree_empty` | `decide.ps1:140`(`facts.uiaTreeEmpty`,由 `win.ps1` 的 `Test-WpmUiaTreeHasContent` 实测:树内 **0 个内容元素**) | 树里只剩壳,一个可驱动的内容元素都没有。**主成因**(2026-11-21 普查实测):应用侧没开无障碍(uTools:raw=1/1/1、其中 0 个可交互元素,三连读全等;同日普查测得 raw=0/0/0——壳来去,内容从不出现)。**已知第二成因**(同轮挂泵靶窗实测):泵挂死的应用对 WM_GETOBJECT 不作答,UIA 立即回 0 个元素——同一观察,成因不同 | 让应用以开启无障碍的方式重启(Chromium:`--force-renderer-accessibility`,启动期开关);或换目标。若目标同时处于「未响应」状态,先等应用恢复。**不要重试轮询**——三次原位重查证明等不出内容 | **REAL** — 2026-11-21 对 uTools 真窗实测引擎端到端返回该码(扫描与点两条路);对照 DSH 同桌首读即出真树(普查 514、复测 1019) |
|
|
37
37
|
| `uia_probe_failed` | `decide.ps1:136`(`facts.uiaProbeFailed`,即探针 `uiaErr` 非空) | 探针本身抛了异常(元素在测量中途被销毁等),**树测没测成**——对目标下任何结论都无凭据 | 读 reason 里 `[uia: …]` 段的异常原文再判断;不要把它当成「目标不可达」的证据,也不要自动重试 | **REAL** — 2026-11-21 探针异常实例:WM_CLOSE 于调用后 40ms 落进探针(`IsWindow` 已过、`FromHandle` 抛「无法识别的错误」),返回该码且 reason 带 `[uia: …]` 异常原文 |
|
|
38
|
-
| `terminal_no_door` | `decide.ps1
|
|
39
|
-
| `needs_facts` | `decide.ps1
|
|
38
|
+
| `terminal_no_door` | `decide.ps1`(family=terminal 且两门皆无) | 终端文字面**有 3 个子 HWND,但无一可写**:`DRAG_BAR_WINDOW_CLASS` 是标题栏拖拽条,`DesktopWindowContentBridge` 是 DirectComposition 渲染目标(不接受 `WM_CHAR`/`WM_SETTEXT`),`InputSite.WindowClass` 是 0×0 的输入接收器;也没有可用的 UIA pattern | **换目标**(浏览器地址栏/文本框/WinForms 编辑框)。**「改用键盘注入」这条路已被实测否决**:Unicode 与扫描码两臂都被 SendInput 接受、前台也对,终端就是不执行——所以本码不再把注入写成下一步 | **REAL(窗口普查 + 注入实测)** — 2026-11-23:只读枚举 CASCADIA 终端 3 子窗无一可写(findings §B);`scripts/probe-console-inject.ps1`(242 事件、Enter 已发、文件未生成)与 `scripts/probe-console-scan.ps1`(262 事件、同样失败)见 findings §G3 |
|
|
39
|
+
| `needs_facts` | `decide.ps1` | 调用方没给这个目标的实测事实 | 先测量再决定。**拒绝,而不是默认走安静档** | **REAL(表级)** — 引擎内不可达:`facts` 恒被测量,本码只在表被单独使用时出现 |
|
|
40
|
+
| `takeover_unavailable` | `decide.ps1`(`facts.takeoverRequested && !facts.hudReady`);宿主侧 `lib/index.js` 在 `takeoverAllowed=false` 时直接拒,零 worker 请求 | 要求接管档,但**接管面不存在**:HUD 没起来,或设置里 `takeoverAllowed` 关着 | 在设置里打开 `takeoverAllowed`;HUD 是**硬前置**,不是装饰。不想接管就**去掉 `takeover:true`** 走静默档——本码存在的意义正是「绝不静默降级」 | **REAL** — `test/plugin-test.mjs`(宿主闸:默认关 + `takeover:true` ⇒ 该码且工作进程 0 请求);`test/takeover-test.ps1` 决策臂 |
|
|
41
|
+
| `keyinject_unavailable` | `decide.ps1`(注入不在接管档内/`keyInjectAllowed` 关/目标不是前台且抬不起来);`engine.ps1`(发送瞬间前台已变) | 要求键盘注入,但注入会打到**别的窗口**或没被授权。依据是实测:`SendInput` 只写前台(`scripts/probe-sendinput-unicode.ps1` arm B:文本落在前台窗 B,而不是调用方以为的 A) | 先自己把目标切到前台(或用 `focus` 动作把它抬上来),或关掉 `keyInput` 用静默档;不允许「盲注入」 | **REAL** — `test/keyinject-test.ps1` K1(非前台拒绝,注入零次)、K5(双闸独立);判定层两条用例 |
|
|
40
42
|
|
|
41
|
-
## 运行时失败层(
|
|
43
|
+
## 运行时失败层(3 码)
|
|
42
44
|
|
|
43
45
|
| 码 | 触发条件 | 语义 | 下一步动作 | 实测状态 |
|
|
44
46
|
|---|---|---|---|---|
|
|
45
47
|
| `action_failed` | `engine.ps1:218`(通道调用抛异常) | 决定说能做,实际调用炸了 | 报给所有者并附异常原文;同一目标不要自动重试第二次 | **NOT-COVERED** — 需要可稳定抛错的真实目标,本轮未构造 |
|
|
46
|
-
| `restore_failed` | `engine.ps1
|
|
48
|
+
| `restore_failed` | `engine.ps1`(表判 restore、OS 拒绝 SetForegroundWindow) | 所有者被留在了一个不是他选的窗口里 | 立刻上报;不要静默重试,也不要启动看门狗抢第三次 | **NOT-COVERED** — 需提权窗配合,属 task_52 |
|
|
49
|
+
| `takeover_aborted` | `engine.ps1`(HUD 按钮/中断键/宿主取消,三路汇聚后置位) | 接管被**人**或**宿主**中止了。这不是故障,是 R3 承诺的能力:结果里仍带 `cursorRestored` 与 `injectedChars`,让读者知道做到哪一步 | 读 `injectedChars` 判断已写入多少;要接着做就**重新发起**一次动作(不会从断点续写)。不要把它当成失败来重试 | **REAL** — `test/takeover-test.ps1` 三臂(volatile 标志/latch 文件/长文本中途中断),每臂都断言光标回位 |
|
|
47
50
|
|
|
48
51
|
## 三个诚实的缺口(写在文档里,而不是留白)
|
|
49
52
|
|
|
@@ -56,9 +59,10 @@ R2′ 把「拒绝」当成本产品的**正常结果**(`engine.ps1` 首段注
|
|
|
56
59
|
**仍缺的**:`restore_failed` 兜底路径(提权窗 + 抬前台被 OS 拒绝的端到端)需要提权窗口在跑
|
|
57
60
|
battery 时在场;本轮 Task Manager 在场时测到了识别与拒绝,恢复兜底未触发。
|
|
58
61
|
2. **`action_failed` / `restore_failed` 没有实测样例。** 表中标 NOT-COVERED,不写「已支持」。
|
|
59
|
-
3. **`terminal_no_door`
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
3. **`terminal_no_door` 的措辞已在 2026-11-23 依据实测修正**:不再是「不暴露子 HWND」,而是
|
|
63
|
+
「有 3 个子 HWND 但无一可写」(findings §B 只读枚举)。该码保留的价值是**诊断 + 指出下一步**
|
|
64
|
+
(`takeover:true` + `keyInput:'inject'`),不是死路;终端的**可写不可读**限制写在
|
|
65
|
+
`docs/takeover.md`。
|
|
62
66
|
4. **`uia_probe_failed` 的可执行用例只有判定层一条**(schema 里 `click-uia-probe-failed`,decision 模式)。
|
|
63
67
|
引擎级用例需要「探针必然抛异常」的稳定构造,本轮拿到了**真样本**但没固化成可复跑用例:构造是
|
|
64
68
|
「引擎调用开始后 N ms,由一个原生 OS 线程向靶窗投递 WM_CLOSE」(销毁落在 `IsWindow` 与
|
|
@@ -72,6 +76,9 @@ R2′ 把「拒绝」当成本产品的**正常结果**(`engine.ps1` 首段注
|
|
|
72
76
|
|
|
73
77
|
- `src/schema/tools.json` 的 `refusals` 数组是机器可读形态;每个动作型工具(`wpm_click` / `wpm_type` /
|
|
74
78
|
`wpm_focus`)列出它可能返回的码,并带**可执行**的拒绝路径用例。
|
|
79
|
+
- R3 新增三码(`takeover_unavailable` / `keyinject_unavailable` / `takeover_aborted`)**同批**写进代码、
|
|
80
|
+
schema 与本表,由 `scripts/check-refusals.mjs` 三方对齐检查;`takeover_aborted` 是运行时结果,
|
|
81
|
+
其 schema 用例声明为 uncovered 并附理由(`tools.json` 的 `uncoveredReason`)。
|
|
75
82
|
- `wpm_windows` / `wpm_status` 是只读查询,**不产生拒绝码**。与其编造一条假分支,不如在 schema 里写
|
|
76
83
|
`noRefusalReason` 并让门禁检查它非空。
|
|
77
84
|
- `test/schema-test.mjs` 校验:码集合三方一致、用例参数能通过该工具的 inputSchema、每个动作型工具至少一条用例。
|
package/docs/takeover.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# 接管档(Takeover Tier)
|
|
2
|
+
|
|
3
|
+
> 0.2.0 起,本插件有一个**默认关闭**的第三档:`takeover:true`。本文说明它借走什么、怎么还、怎么被中断,
|
|
4
|
+
> 以及**它明确做不到什么**。所有数字都出自 `scripts/` 里可复跑的探针与 `test/` 里可复跑的测试。
|
|
5
|
+
|
|
6
|
+
## 四档总表
|
|
7
|
+
|
|
8
|
+
| 档 | 何时进入 | 光标 | 焦点 | 键盘 | HUD |
|
|
9
|
+
|---|---|---|---|---|---|
|
|
10
|
+
| `quiet` | 窗口消息门存在(默认首选) | 0 px | 0 变更 | 零注入 | 无 |
|
|
11
|
+
| `bounded-flash` | 只有 UIA pattern | 0 px | 一次闪光,自动回还(实测净回还 15–95 ms) | 零注入 | 无 |
|
|
12
|
+
| **`takeover`** | 显式 `takeover:true` 且两关都开 | **移到动作点,必复位** | 持有至动作结束,然后按表回还 | 仅 `keyInput:"inject"` 时注入 | **必需,三段式** |
|
|
13
|
+
| `refuse` | 任何前置不满足 | — | — | — | 拒绝码 |
|
|
14
|
+
|
|
15
|
+
**接管档不新增点击通道。** 点击仍走 message/UIA;`SetCursorPos` 只是让所有者**看见** agent 指到哪,
|
|
16
|
+
`SendInput` 只在目标连门都没有时才作为最后手段。**鼠标注入永远不存在**:`MOUSEEVENTF_*` 全仓禁止。
|
|
17
|
+
|
|
18
|
+
## 两个开关,默认都关
|
|
19
|
+
|
|
20
|
+
| 设置 | 默认 | 含义 |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| `takeoverAllowed` | `false` | 允许 `takeover:true`;关着时**拒绝** `takeover_unavailable`,**不静默降级** |
|
|
23
|
+
| `keyInjectAllowed` | `false` | 允许接管档内的 `keyInput:"inject"`;关着时拒绝 `keyinject_unavailable` |
|
|
24
|
+
| `takeoverMaxMs` | `10000` | 单次动作上限(500–60000),HUD 实时显示时钟 |
|
|
25
|
+
| `takeoverArmMs` | `800` | 预警段时长:光标移动/按键之前的可取消窗口 |
|
|
26
|
+
|
|
27
|
+
默认全关是产品决定:升级不该让别人的指针自己动起来。
|
|
28
|
+
|
|
29
|
+
## 三段式 HUD
|
|
30
|
+
|
|
31
|
+
| 段 | 时长 | 配色(底色 / 左侧 5px 色条 / 文字) | 显示 | 可做的操作 |
|
|
32
|
+
|---|---|---|---|---|
|
|
33
|
+
| `arming` | `takeoverArmMs`(默认 800 ms) | **琥珀** `#3A2C0C` / `#F0AD18` / `#FFD88A` | 「即将使用你的鼠标/键盘/焦点 · <action>」+ **实际注册到的中断键** | 取消 |
|
|
34
|
+
| `active` | 至动作结束或上限 | **红** `#3A1212` / `#E84040` / `#FFBEBE` | 「占用中 · 已用 1.2s / 上限 10s · 已注入 N 字」 | 停止 |
|
|
35
|
+
| `done` | 默认 1500 ms | **绿** `#0E2E1E` / `#34C77B` / `#B2F0CD` | 「已归还:光标已复位」 | 无(按钮禁用) |
|
|
36
|
+
|
|
37
|
+
**为什么是三色而不是三种文案。** 接管期间所有者的注意力在目标窗口,不在右下角这块 470×104 的浮窗上;
|
|
38
|
+
读一句话的成本远高于扫一眼颜色。所以相位被编码**两遍**:整块底色 + 左侧 5px 色条(只靠底色在屏幕边缘容易漏看)。
|
|
39
|
+
配色按语义选,不按好看选:**琥珀=还没开始(可取消)**、**红=正在占用(此刻在花你的东西)**、
|
|
40
|
+
**绿=已归还(没占着任何东西)**。`test/hud-test.ps1` 的 C18 五臂直接读像素断言这三色互不相同且各自主导。
|
|
41
|
+
|
|
42
|
+
窗口属性(`test/hud-test.ps1` 实测):`WS_EX_TOPMOST | WS_EX_NOACTIVATE`,`ShowActivated=false`,
|
|
43
|
+
**不加** `WS_EX_TRANSPARENT`(按钮要能点),启动前后 `GetForegroundWindow()` 不变。
|
|
44
|
+
**空白穿透**用 `WNDPROC` 子类化:按钮矩形外返回 `HTTRANSPARENT`,按钮内交回 WPF。
|
|
45
|
+
(`HwndSource` 的 hook 收得到 `WM_NCHITTEST`,但返回值不影响命中测试——实测失败方案,见
|
|
46
|
+
`scripts/probe-hittest-children.ps1`。)
|
|
47
|
+
|
|
48
|
+
## 三个键,别记混
|
|
49
|
+
|
|
50
|
+
| 想做什么 | 键 | 说明 |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| **打断正在进行的接管** | **`Ctrl+Alt+X`** | 本机实测注册成功的那个。候选表:`Ctrl+Alt+X` → `Z` → `C` → `V` → `B` → `N` → `Ctrl+Shift+X` → `Ctrl+Alt+Shift+X`,取第一个能注册的;**HUD 上显示的是真的那个**,不是文档承诺的那个 |
|
|
53
|
+
| 同一件事的备用手段 | **点 HUD 的「取消」/「停止」按钮** | 按钮与热键写的是同一个标志,没有优先级 |
|
|
54
|
+
| **暂停整个引擎**(不只是当前动作) | **`Ctrl+Alt+Q`** | 本机被别的程序占了(Win32 1409),实际注册为 **`Ctrl+Alt+W`**,`status` 里 `pauseHotkey=` 会如实报。**暂停也会立刻中断正在进行的接管** |
|
|
55
|
+
| 宿主取消 | 无键 | `exec.signal` → latch 文件,引擎每 50 ms 轮询 |
|
|
56
|
+
|
|
57
|
+
中断键与暂停键是**两个不同的东西**,这一点容易混:中断键只在接管期间存在(HUD 窗口拥有它,窗口销毁即注销),
|
|
58
|
+
暂停键是常驻的服务端开关(拒绝后续所有动作,并打断当前接管)。
|
|
59
|
+
## 三路中断
|
|
60
|
+
|
|
61
|
+
三条路写的是**同一个**标志/文件,所以不存在「哪个才算数」:
|
|
62
|
+
|
|
63
|
+
1. **HUD 的停止按钮** → `[WpmCtl]::TakeoverAbort = true`(跨线程只写 volatile,不做
|
|
64
|
+
`Dispatcher.Invoke`——那条路实测 1818 ms 且有时不返回)。
|
|
65
|
+
2. **全局中断键** → 候选表从 `Ctrl+Alt+X` 起逐试,注册成功者写进 `AbortChordLabel`,
|
|
66
|
+
**HUD 显示的是真的那个键**;全失败显示「中断键不可用,请点按钮」,不伪造。
|
|
67
|
+
3. **宿主取消**(`exec.signal`)→ Node 写 latch 文件
|
|
68
|
+
`%LOCALAPPDATA%/wpm/takeover-abort.<worker pid>`,引擎每 50 ms `Test-Path`。
|
|
69
|
+
**为什么是文件**:worker 是单线程的,动作进行中读不到新请求,所以进程内标志不够。
|
|
70
|
+
|
|
71
|
+
中断结果不是故障:返回 `takeover_aborted`,并**仍带** `cursorRestored` 与 `injectedChars`,
|
|
72
|
+
让读者知道做到哪一步。要接着做就重新发起(不会从断点续写)。
|
|
73
|
+
|
|
74
|
+
## 光标:借了必须还
|
|
75
|
+
|
|
76
|
+
- 移动前先读存证(`GetCursorPos`),移动后**读回校验**;读回不等于请求时 `cursorMoved=false`。
|
|
77
|
+
- 复位放在**同一个** `try/finally` 里:成功、异常、拒绝、中断四条路都到那里。
|
|
78
|
+
- 复位结果同样是读回:`cursorRestored=false` ⇒ 下游 `proof=fail`,理由写「借了未还」。
|
|
79
|
+
**这是唯一一条硬红线**:桌面静不静都不能替它辩护。
|
|
80
|
+
- `scripts/check-takeover-path.mjs` 的 G4 把「移动与复位同处一个 try/finally」做成**静态**断言——
|
|
81
|
+
运行时采样只能证明「这次没发生」。
|
|
82
|
+
|
|
83
|
+
## 键盘:只在接管档、只在前台、只能打字
|
|
84
|
+
|
|
85
|
+
- **S1 前台即目标。** `SendInput` 把键送进**当前前台**窗口,不看「你以为的目标」。实测
|
|
86
|
+
(`scripts/probe-sendinput-unicode.ps1`):B 在前台时,文本落到 B,A 什么都没收到。
|
|
87
|
+
所以注入前断言 `GetForegroundWindow()==target`(子窗按根窗比对),抬不起来就拒绝
|
|
88
|
+
`keyinject_unavailable`,**绝不盲注入**;发送瞬间还会再断言一次(预警窗口期间桌面可能变)。
|
|
89
|
+
- **S2 逐字可中断。** 每 8 字符或 50 ms 查一次中断;命中即停,返回**实际**发出的字符数。
|
|
90
|
+
- **S3 不动鼠标。** 只构造 `INPUT_KEYBOARD`;门禁禁止 `MOUSEEVENTF_*` 常量,结构上点不了。
|
|
91
|
+
- **字符方案:** `KEYEVENTF_UNICODE`(逐字),不受键盘布局与死键影响,中文/emoji 可用。
|
|
92
|
+
**代价**:不带硬件扫描码,极少数只认扫描码的目标(某些游戏、远端 IP-KVM)不响应——已知限制。
|
|
93
|
+
- **effect 只能报 `reported-by-send`**:`SendInput` 返回的是「入队事件数」,不证明目标处理了。
|
|
94
|
+
|
|
95
|
+
## 终端:这条承诺被实测撤回
|
|
96
|
+
|
|
97
|
+
0.2.0 的计划是「终端无门 → 用键盘注入驱动它」。**实测否决**(2026-11-23,本机):
|
|
98
|
+
|
|
99
|
+
| 探针 | 做法 | 结果 |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `scripts/probe-console-inject.ps1` | 新建专用 Windows Terminal 窗,`KEYEVENTF_UNICODE` 逐字注入一条命令 + Enter | SendInput 接受 **242 事件**,`foregroundIsTarget=true`,Enter 已发,**文件未生成** |
|
|
102
|
+
| `scripts/probe-console-scan.ps1` | 同窗口,改用布局扫描码(`KEYEVENTF_SCANCODE` + `VkKeyScanW`) | **262 事件**,前台正确,**同样未执行** |
|
|
103
|
+
|
|
104
|
+
结论:本机终端**不接受合成输入**(GUI 目标正常——同一套代码在 WinForms 文本框里中文落字成功)。
|
|
105
|
+
因此 `terminal_no_door` **保留**,理由改成「换一个真有门的目标」,而不是把注入写成下一步。
|
|
106
|
+
**终端仍然不可写、不可读**:没有可用门,也没有 UIA `Document`,注入又无效——
|
|
107
|
+
不要从本文读出「能驱动终端」的暗示。
|
|
108
|
+
|
|
109
|
+
## 拒绝码与下一步
|
|
110
|
+
|
|
111
|
+
| 码 | 层 | 触发 | 下一步 |
|
|
112
|
+
|---|---|---|---|
|
|
113
|
+
| `takeover_unavailable` | decision | 请求了接管,但设置关着或 HUD 没起来 | 打开 `takeoverAllowed`;或去掉 `takeover:true` 用静默档 |
|
|
114
|
+
| `keyinject_unavailable` | decision | 注入不在接管档内/开关关着/目标不是前台且抬不起来 | 自己把目标切前台(或先 `focus`),或关掉 `keyInput` |
|
|
115
|
+
| `takeover_aborted` | runtime | HUD 按钮/中断键/宿主取消 | 读 `injectedChars` 知道做到哪;要接着做就重发 |
|
|
116
|
+
|
|
117
|
+
细节与三方对齐规则见 [refusals.md](refusals.md)。
|
|
118
|
+
|
|
119
|
+
## 测试与门禁
|
|
120
|
+
|
|
121
|
+
| 命令 | 覆盖 |
|
|
122
|
+
|---|---|
|
|
123
|
+
| `node scripts/check.mjs` | 11 道闸,含「光标/注入白名单」与「接管路径 G1–G5(带注入自测)」 |
|
|
124
|
+
| `powershell -STA -File test/hud-test.ps1` | 窗口属性、**不抢焦点**、三段相位、按钮/热键写同一标志、实际 chord |
|
|
125
|
+
| `powershell -STA -File test/takeover-test.ps1` | I1/I3/I4/I5 不变式、正常与中断路径的光标回位、决策臂 |
|
|
126
|
+
| `powershell -STA -File test/keyinject-test.ps1` | K1(非前台零注入)、K3(长文本可中断)、K4(Unicode 落字)、K5/K6(双闸与 effect) |
|
|
127
|
+
|
|
128
|
+
**这三个桌面测试不在 `check.mjs` 里**:它们会移动真实光标、注入真实按键,而门禁是给「随时可以跑」用的。
|
|
129
|
+
它们是手动臂,结果记录在计划的 checklist 里。
|
package/dsh.plugin.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-windows-parallel-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
|
-
"description": "One tool, five actions: drive a Windows window
|
|
5
|
+
"description": "One tool, five actions: drive a Windows window quietly by default. Prefers window messages (zero foreground change); falls back to UI Automation with a bounded, self-reversing focus flash (measured net return 15-95 ms); offers an opt-in takeover tier (takeoverAllowed) where the cursor moves to the action point and is always restored, with a mandatory three-phase HUD and three interruption paths.",
|
|
6
6
|
"engines": {
|
|
7
7
|
"dsh": ">=0.1.7-0 <0.3.0-0"
|
|
8
8
|
},
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"tools": [
|
|
11
11
|
{
|
|
12
12
|
"name": "wpm",
|
|
13
|
-
"description": "Drive a Windows window
|
|
13
|
+
"description": "Drive a Windows window quietly by default (actions: windows, status, click, type, focus), with an opt-in takeover tier that is visible, interruptible and always restores the cursor."
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"skills": []
|
package/lib/config.js
CHANGED
|
@@ -35,6 +35,24 @@ const FIELDS = [
|
|
|
35
35
|
+ 'gate the action result.' },
|
|
36
36
|
{ key: 'logWorkerStderr', type: 'boolean', default: false, volatile: true,
|
|
37
37
|
description: 'Forward the sidecar’s stderr diagnostics to the host log.' },
|
|
38
|
+
// ---- R3 gates. BOTH DEFAULT OFF, and that is a product decision, not timidity: with them off the
|
|
39
|
+
// tool behaves exactly like 0.1.6 (zero physical input), so an upgrade cannot silently start moving
|
|
40
|
+
// the owner's cursor. Turning takeover on is the owner's explicit act.
|
|
41
|
+
{ key: 'takeoverAllowed', type: 'boolean', default: false, volatile: true,
|
|
42
|
+
description: 'Allow actions to request the takeover tier (takeover:true): the real cursor is moved '
|
|
43
|
+
+ 'to the action point and always restored, the focus is held for the duration, and a three-phase '
|
|
44
|
+
+ 'HUD is mandatory. Off by default; when off, a takeover request is refused with '
|
|
45
|
+
+ 'takeover_unavailable and the action is NOT silently downgraded.' },
|
|
46
|
+
{ key: 'keyInjectAllowed', type: 'boolean', default: false, volatile: true,
|
|
47
|
+
description: 'Allow keyboard injection (keyInput:"inject") inside the takeover tier, for targets '
|
|
48
|
+
+ 'with no message door and no UIA pattern (terminals). Text is typed into the FOREGROUND window '
|
|
49
|
+
+ 'after asserting it is the target; never mouse injection. Off by default.' },
|
|
50
|
+
{ key: 'takeoverMaxMs', type: 'number', default: 10000, min: 500, max: 60000, volatile: true,
|
|
51
|
+
description: 'How long a takeover action may hold the owner’s cursor/focus before it must end. '
|
|
52
|
+
+ 'Hard ceiling 60s; the HUD shows the elapsed/limit clock so a long action is visible.' },
|
|
53
|
+
{ key: 'takeoverArmMs', type: 'number', default: 800, min: 0, max: 5000, volatile: true,
|
|
54
|
+
description: 'Length of the HUD’s arming phase: the window in which the owner can cancel before '
|
|
55
|
+
+ 'the cursor moves or a key is typed. 0 disables the wait (the HUD still shows).' },
|
|
38
56
|
];
|
|
39
57
|
|
|
40
58
|
/** Defaults, for documentation and for tests that must not depend on a resolver. */
|
|
@@ -115,8 +133,45 @@ export async function createConfigSchema() {
|
|
|
115
133
|
if (field.volatile && typeof s.volatile === 'function') s = s.volatile();
|
|
116
134
|
shape[field.key] = s;
|
|
117
135
|
}
|
|
118
|
-
const schema = z.object(shape);
|
|
119
|
-
|
|
136
|
+
const schema = typeof z.object(shape).prefault === 'function' ? z.object(shape).prefault({}) : z.object(shape);
|
|
137
|
+
// TWO PROPERTIES THE SHIM ALREADY HAD, restored on the Schemastery path so both paths behave the
|
|
138
|
+
// same way for the caller:
|
|
139
|
+
// * UNKNOWN KEYS ARE REJECTED, not silently carried through. Schemastery keeps them in the
|
|
140
|
+
// validated value, which means a typo'd setting reads as accepted while doing nothing -- the
|
|
141
|
+
// exact failure test/plugin-test.mjs pins, and the reason the shim has this rule;
|
|
142
|
+
// * '~standard' stays the single validation entry point Cordis calls.
|
|
143
|
+
// The Schemastery INSTANCE itself is kept: it is a callable object and it is what the host uses to
|
|
144
|
+
// render the settings form. Wrapping it in a plain object would trade the form for the check.
|
|
145
|
+
// Schemastery owns '~standard' as a non-writable accessor, so it cannot be replaced in place. The
|
|
146
|
+
// wrapper below is a PROXY over the instance: still callable, still carrying the instance's own
|
|
147
|
+
// fields and methods (which is what the settings form reads), but with one property -- the
|
|
148
|
+
// validation entry point Cordis calls -- replaced by the strict one.
|
|
149
|
+
const std = schema['~standard'];
|
|
150
|
+
let configValue = schema;
|
|
151
|
+
if (std && typeof std.validate === 'function') {
|
|
152
|
+
const known = new Set(FIELDS.map((f) => f.key));
|
|
153
|
+
const wrapped = Object.assign(Object.create(null), std, {
|
|
154
|
+
validate(raw) {
|
|
155
|
+
const input = raw && typeof raw === 'object' ? raw : {};
|
|
156
|
+
const unknown = Object.keys(input).filter((k) => !known.has(k));
|
|
157
|
+
if (unknown.length) {
|
|
158
|
+
return { issues: unknown.map((k) => ({ message: 'unknown setting', path: [k] })) };
|
|
159
|
+
}
|
|
160
|
+
return std.validate(raw);
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
try {
|
|
164
|
+
configValue = new Proxy(schema, {
|
|
165
|
+
get(target, prop, receiver) {
|
|
166
|
+
if (prop === '~standard') return wrapped;
|
|
167
|
+
const v = Reflect.get(target, prop, receiver);
|
|
168
|
+
return typeof v === 'function' ? v.bind(target) : v;
|
|
169
|
+
},
|
|
170
|
+
apply(target, thisArg, args) { return Reflect.apply(target, thisArg, args); },
|
|
171
|
+
});
|
|
172
|
+
} catch { configValue = schema; }
|
|
173
|
+
}
|
|
174
|
+
return { schema: configValue, source: '@deepseek-ai/schemastery' };
|
|
120
175
|
}
|
|
121
176
|
} catch {
|
|
122
177
|
// Documented fallback, reported through `source`.
|
package/lib/host-tools.js
CHANGED
|
@@ -48,6 +48,31 @@ export const PARAMETERS = {
|
|
|
48
48
|
},
|
|
49
49
|
replace: { type: 'boolean', description: 'Replace the existing value instead of appending (type only).' },
|
|
50
50
|
settleMs: { type: 'number', description: 'How long to let the app commit its state before the effect is judged (0-2000, default 350).' },
|
|
51
|
+
// ---- R3. Every one of these costs the owner something real, so each description says so: a caller
|
|
52
|
+
// that asks for takeover has to know it moves the pointer and needs the HUD up.
|
|
53
|
+
takeover: {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
description:
|
|
56
|
+
'Take the takeover tier: the REAL cursor moves to the action point (so the owner can see where the '
|
|
57
|
+
+ 'agent is pointing) and is always restored afterwards, the focus is held until the action ends, '
|
|
58
|
+
+ 'and a three-phase HUD is shown with a stop button and a global abort key. Requires the '
|
|
59
|
+
+ 'takeoverAllowed setting, otherwise it is refused with takeover_unavailable (it never degrades '
|
|
60
|
+
+ 'silently into the quiet tier). Interruptible three ways: HUD button, abort key, host cancellation.',
|
|
61
|
+
},
|
|
62
|
+
takeoverMaxMs: {
|
|
63
|
+
type: 'number',
|
|
64
|
+
description: 'Takeover only: how long the action may hold the cursor/focus (500-60000, default 10000). The HUD counts up to it.',
|
|
65
|
+
},
|
|
66
|
+
keyInput: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
enum: ['none', 'inject'],
|
|
69
|
+
description:
|
|
70
|
+
'Takeover only: "inject" types the text with synthetic KEYBOARD input (SendInput, Unicode) into the '
|
|
71
|
+
+ 'foreground window, for targets with no message door and no UIA pattern (terminals). Requires '
|
|
72
|
+
+ 'takeover:true and the keyInjectAllowed setting; the target must be the foreground window or the '
|
|
73
|
+
+ 'call is refused with keyinject_unavailable. Never moves the mouse, never clicks. The result '
|
|
74
|
+
+ 'reports effect=reported-by-send, not "verified".',
|
|
75
|
+
},
|
|
51
76
|
};
|
|
52
77
|
|
|
53
78
|
/**
|
|
@@ -104,14 +129,19 @@ export function localDefineTool(options) {
|
|
|
104
129
|
schema: options.output.schema,
|
|
105
130
|
render: options.output.render,
|
|
106
131
|
},
|
|
107
|
-
|
|
132
|
+
// THE SECOND ARGUMENT IS THE CALL CONTEXT, and dropping it silently disables cancellation: the plugin
|
|
133
|
+
// asks the host for `exec.signal` to abort a takeover in flight, and a wrapper that forwards only
|
|
134
|
+
// `args` makes that code path unreachable -- the abort arrives, nothing is listening, and the call
|
|
135
|
+
// runs to completion. Measured: the first version of this shim did exactly that, and test/signal-test.mjs
|
|
136
|
+
// caught it as "the cancellation was not reported" while everything else looked green.
|
|
137
|
+
async execute(args, exec) {
|
|
108
138
|
const problems = validateArguments(parameters, args);
|
|
109
139
|
if (problems.length) {
|
|
110
140
|
const err = new Error(`${options.name}: ${problems.join('; ')}`);
|
|
111
141
|
err.name = 'ToolArgsError';
|
|
112
142
|
throw err;
|
|
113
143
|
}
|
|
114
|
-
return userExecute(args);
|
|
144
|
+
return userExecute(args, exec);
|
|
115
145
|
},
|
|
116
146
|
};
|
|
117
147
|
}
|