dsh-windows-parallel-mcp 0.2.0 → 0.4.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 +378 -0
- package/CHANGELOG.es.md +378 -0
- package/CHANGELOG.fr.md +378 -0
- package/CHANGELOG.it.md +378 -0
- package/CHANGELOG.ja.md +378 -0
- package/CHANGELOG.ko.md +378 -0
- package/CHANGELOG.md +70 -3
- package/CHANGELOG.pt.md +378 -0
- package/CHANGELOG.ru.md +378 -0
- package/CHANGELOG.zh.md +378 -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 +1 -0
- package/README.pt.md +275 -0
- package/README.ru.md +275 -0
- package/README.zh.md +275 -0
- package/lib/config.js +29 -1
- package/lib/engine.js +31 -4
- package/lib/host-tools.js +41 -2
- package/lib/index.js +137 -9
- package/lib/peers-schemastery.js +6 -0
- package/lib/peers-tools.js +9 -0
- package/lib/proof-window.mjs +122 -8
- package/package.json +34 -4
- package/types/index.d.ts +68 -0
package/README.ru.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# dsh-windows-parallel-mcp
|
|
2
|
+
|
|
3
|
+
[English](README.md) · [中文](README.zh.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) · **Русский**
|
|
4
|
+
|
|
5
|
+
> Плагин DSH, позволяющий агенту управлять **своими** окнами Windows — по умолчанию тихо, по запросу видимо. Когда окно принимает сообщения Windows, фокус никогда не перехватывается. Когда доступен только UI Automation, фокус претерпевает одну ограниченную вспышку и автоматически возвращается. При явном запросе режима takeover курсор перемещается в точку действия и всегда восстанавливается, а 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/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/lib/config.js
CHANGED
|
@@ -19,6 +19,21 @@
|
|
|
19
19
|
// Cordis renders. It is NOT schemastery: the settings FORM is rendered from schemastery's field
|
|
20
20
|
// metadata, so a host that cannot resolve schemastery gives the user no form — the values still work
|
|
21
21
|
// from the bundle patch. That limitation is stated in the README rather than papered over.
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* One declarable setting. `type` is a closed string union rather than a string so the three-way
|
|
25
|
+
* branch in both validators is checked as exhaustive by the reader, not just by the shim at runtime.
|
|
26
|
+
* @typedef {object} ConfigField
|
|
27
|
+
* @property {string} key
|
|
28
|
+
* @property {'boolean'|'number'|'string'} type
|
|
29
|
+
* @property {any} default
|
|
30
|
+
* @property {number} [min]
|
|
31
|
+
* @property {number} [max]
|
|
32
|
+
* @property {boolean} [volatile]
|
|
33
|
+
* @property {string} [description]
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/** @type {ConfigField[]} */
|
|
22
37
|
const FIELDS = [
|
|
23
38
|
{ key: 'enabled', type: 'boolean', default: true, volatile: true,
|
|
24
39
|
description: 'Master switch. When off, every action refuses with `paused` before the engine is reached.' },
|
|
@@ -58,9 +73,19 @@ const FIELDS = [
|
|
|
58
73
|
/** Defaults, for documentation and for tests that must not depend on a resolver. */
|
|
59
74
|
export const CONFIG_DEFAULTS = Object.fromEntries(FIELDS.map((f) => [f.key, f.default]));
|
|
60
75
|
|
|
61
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Validate one raw config object against FIELDS. Returns `{ value, issues }` standard-schema style.
|
|
78
|
+
*
|
|
79
|
+
* `@returns {any}` on purpose: the two returns below have different shapes (`{issues}` alone vs
|
|
80
|
+
* `{value}` alone), which is exactly what the standard-schema contract allows and what Cordis
|
|
81
|
+
* branches on. A precise union here is a lie about the runtime and was measured to turn two errors
|
|
82
|
+
* into three (findings §7.5).
|
|
83
|
+
* @param {any} raw
|
|
84
|
+
* @returns {any}
|
|
85
|
+
*/
|
|
62
86
|
function validateWithShim(raw) {
|
|
63
87
|
const input = raw && typeof raw === 'object' ? raw : {};
|
|
88
|
+
/** @type {Record<string, any>} */
|
|
64
89
|
const value = {};
|
|
65
90
|
const issues = [];
|
|
66
91
|
for (const field of FIELDS) {
|
|
@@ -116,6 +141,7 @@ export async function createConfigSchema() {
|
|
|
116
141
|
const mod = await import('./peers-schemastery.js');
|
|
117
142
|
const z = mod?.z;
|
|
118
143
|
if (z && typeof z.object === 'function') {
|
|
144
|
+
/** @type {Record<string, any>} */
|
|
119
145
|
const shape = {};
|
|
120
146
|
for (const field of FIELDS) {
|
|
121
147
|
let s;
|
|
@@ -149,8 +175,10 @@ export async function createConfigSchema() {
|
|
|
149
175
|
const std = schema['~standard'];
|
|
150
176
|
let configValue = schema;
|
|
151
177
|
if (std && typeof std.validate === 'function') {
|
|
178
|
+
/** @type {Set<string>} */
|
|
152
179
|
const known = new Set(FIELDS.map((f) => f.key));
|
|
153
180
|
const wrapped = Object.assign(Object.create(null), std, {
|
|
181
|
+
/** @param {any} raw @returns {any} */
|
|
154
182
|
validate(raw) {
|
|
155
183
|
const input = raw && typeof raw === 'object' ? raw : {};
|
|
156
184
|
const unknown = Object.keys(input).filter((k) => !known.has(k));
|