dsh-windows-parallel-mcp 0.3.0 → 0.4.1

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/README.ko.md CHANGED
@@ -5,23 +5,21 @@
5
5
  > 에이전트가 **자신의** Windows 창을 조작하도록 하는 DSH 플러그인입니다. 기본은 조용히, 요청 시에는 눈에 보이게 동작합니다. 창이 창 메시지를 받으면 포커스를 전혀 빼앗지 않고, UI Automation으로만 도달 가능하면 포커스가 한 번의 제한된 플래시로 이동한 뒤 자동 복구됩니다. 테이크오버를 명시적으로 요청하면 커서가 동작 지점으로 이동해 항상 복원되며 HUD가 세 가지 중단 수단을 제공합니다. 그 밖의 경우에는 코드와 이유를 붙여 거부합니다.
6
6
 
7
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).
8
+ > **Current release: 0.4.1** — this document describes the contract as of that version. What
9
+ > changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
19
10
 
20
11
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
21
12
  on request. Where a window accepts a window message, you never lose focus at all. Where it only
22
13
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
23
14
  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.
15
+ HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason — never with
16
+ silence: every refusal carries a code from a closed set of thirteen and the next step.
17
+
18
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
20
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
21
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
22
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
25
23
 
26
24
  Source, the measurement scripts behind every number below, and the release history live at
27
25
  **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
@@ -188,6 +186,29 @@ call, not at plugin load.
188
186
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
189
187
  degradation.
190
188
 
189
+ ## Typed surface
190
+
191
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
192
+ contract: the five actions, every argument including the takeover fields, and all thirteen refusal
193
+ codes as a closed union.
194
+
195
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
196
+ presence of a file:
197
+
198
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
199
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
200
+ is the only entry point and the legacy field below is never consulted;
201
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
202
+ consumer still type-checks.
203
+
204
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
205
+
206
+ The declarations are also checked against the implementation, in the direction that catches drift:
207
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
208
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
209
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
210
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
211
+
191
212
  ## Settings
192
213
 
193
214
  | key | default | effect |
package/README.md CHANGED
@@ -1,23 +1,21 @@
1
1
  # dsh-windows-parallel-mcp
2
2
 
3
3
  **English** · [中文](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) · [Русский](README.ru.md)
4
- > **0.2.0 — the promise changes shape, deliberately.** Through 0.1.x this plugin's claim was "no
5
- > physical input at all". 0.2.0 keeps that as the **default** and adds an **opt-in takeover tier**:
6
- > with `takeoverAllowed` on and `takeover:true` on the call, the real cursor is moved to the action
7
- > point (so you can see where the agent points) and always restored, the focus is held for the
8
- > duration, and a three-phase HUD with a stop button and a global abort key is mandatory. Keyboard
9
- > injection exists only inside that tier, only when asked (`keyInput:"inject"`), and only for
10
- > targets with no other door — and, measured, it does **not** work on this host's terminal, so the
11
- > terminal stays refused rather than becoming a promise. Both gates default off: an upgrade cannot
12
- > start moving your cursor by itself. 0.1.6 split `unreachable` into `uia_tree_empty` and
13
- > `uia_probe_failed`; 0.1.5 made a click act on the point it names; 0.1.3 added `effect=` — who
14
- > reported the success — and let it enter the judgment. Full history: [CHANGELOG.md](CHANGELOG.md).
4
+ > **Current release: 0.4.1** — this document describes the contract as of that version. What
5
+ > changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
15
6
 
16
7
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
17
8
  on request. Where a window accepts a window message, you never lose focus at all. Where it only
18
9
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
19
10
  explicitly ask for the takeover tier, the cursor moves to the point and is always restored, with a
20
- HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason.
11
+ HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason — never with
12
+ silence: every refusal carries a code from a closed set of thirteen and the next step.
13
+
14
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
15
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
16
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
17
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
18
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
21
19
 
22
20
  Source, the measurement scripts behind every number below, and the release history live at
23
21
  **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
@@ -184,6 +182,29 @@ call, not at plugin load.
184
182
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
185
183
  degradation.
186
184
 
185
+ ## Typed surface
186
+
187
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
188
+ contract: the five actions, every argument including the takeover fields, and all thirteen refusal
189
+ codes as a closed union.
190
+
191
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
192
+ presence of a file:
193
+
194
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
195
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
196
+ is the only entry point and the legacy field below is never consulted;
197
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
198
+ consumer still type-checks.
199
+
200
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
201
+
202
+ The declarations are also checked against the implementation, in the direction that catches drift:
203
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
204
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
205
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
206
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
207
+
187
208
  ## Settings
188
209
 
189
210
  | key | default | effect |
package/README.pt.md CHANGED
@@ -5,23 +5,21 @@
5
5
  > Um plugin DSH que permite a um agente controlar **as suas próprias** janelas Windows — silencioso por padrão, visível sob demanda. Quando uma janela aceita mensagens do Windows, o foco nunca é roubado. Quando apenas a Automação de UI a alcança, o foco sofre um único lampejo limitado, revertido automaticamente. Quando você solicita explicitamente o modo takeover, o cursor move-se para o ponto de ação e é sempre restaurado, com um HUD que oferece três formas de interrupção. Em todos os outros casos, recusa com um código e um motivo.
6
6
 
7
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).
8
+ > **Current release: 0.4.1** — this document describes the contract as of that version. What
9
+ > changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
19
10
 
20
11
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
21
12
  on request. Where a window accepts a window message, you never lose focus at all. Where it only
22
13
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
23
14
  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.
15
+ HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason — never with
16
+ silence: every refusal carries a code from a closed set of thirteen and the next step.
17
+
18
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
20
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
21
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
22
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
25
23
 
26
24
  Source, the measurement scripts behind every number below, and the release history live at
27
25
  **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
@@ -188,6 +186,29 @@ call, not at plugin load.
188
186
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
189
187
  degradation.
190
188
 
189
+ ## Typed surface
190
+
191
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
192
+ contract: the five actions, every argument including the takeover fields, and all thirteen refusal
193
+ codes as a closed union.
194
+
195
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
196
+ presence of a file:
197
+
198
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
199
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
200
+ is the only entry point and the legacy field below is never consulted;
201
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
202
+ consumer still type-checks.
203
+
204
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
205
+
206
+ The declarations are also checked against the implementation, in the direction that catches drift:
207
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
208
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
209
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
210
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
211
+
191
212
  ## Settings
192
213
 
193
214
  | key | default | effect |
package/README.ru.md CHANGED
@@ -5,23 +5,21 @@
5
5
  > Плагин DSH, позволяющий агенту управлять **своими** окнами Windows — по умолчанию тихо, по запросу видимо. Когда окно принимает сообщения Windows, фокус никогда не перехватывается. Когда доступен только UI Automation, фокус претерпевает одну ограниченную вспышку и автоматически возвращается. При явном запросе режима takeover курсор перемещается в точку действия и всегда восстанавливается, а HUD предлагает три способа прерывания. Во всех остальных случаях действие отклоняется с кодом и причиной.
6
6
 
7
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).
8
+ > **Current release: 0.4.1** — this document describes the contract as of that version. What
9
+ > changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
19
10
 
20
11
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
21
12
  on request. Where a window accepts a window message, you never lose focus at all. Where it only
22
13
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
23
14
  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.
15
+ HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason — never with
16
+ silence: every refusal carries a code from a closed set of thirteen and the next step.
17
+
18
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
20
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
21
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
22
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
25
23
 
26
24
  Source, the measurement scripts behind every number below, and the release history live at
27
25
  **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
@@ -188,6 +186,29 @@ call, not at plugin load.
188
186
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
189
187
  degradation.
190
188
 
189
+ ## Typed surface
190
+
191
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
192
+ contract: the five actions, every argument including the takeover fields, and all thirteen refusal
193
+ codes as a closed union.
194
+
195
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
196
+ presence of a file:
197
+
198
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
199
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
200
+ is the only entry point and the legacy field below is never consulted;
201
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
202
+ consumer still type-checks.
203
+
204
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
205
+
206
+ The declarations are also checked against the implementation, in the direction that catches drift:
207
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
208
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
209
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
210
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
211
+
191
212
  ## Settings
192
213
 
193
214
  | key | default | effect |
package/README.zh.md CHANGED
@@ -5,23 +5,21 @@
5
5
  > 一个让代理驱动**自己**的 Windows 窗口的 DSH 插件——默认静默,按需可见。窗口接受窗口消息时完全不夺焦点;只有 UI Automation 可达时,焦点仅发生一次有界闪烁并自动还原;显式请求接管档时,光标移动到目标点并始终还原,HUD 提供三种中断方式。其他情况一律拒绝,并给出代码与原因。
6
6
 
7
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).
8
+ > **Current release: 0.4.1** — this document describes the contract as of that version. What
9
+ > changed in it, and in every version before it, is in [CHANGELOG.md](CHANGELOG.md), newest first.
19
10
 
20
11
  A DSH plugin that lets an agent drive **its own** Windows windows — quietly by default, and visibly
21
12
  on request. Where a window accepts a window message, you never lose focus at all. Where it only
22
13
  exposes UI Automation, you lose focus for one bounded flash that is reversed automatically. Where you
23
14
  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.
15
+ HUD that can stop it three ways. Everywhere else it refuses, with a code and a reason — never with
16
+ silence: every refusal carries a code from a closed set of thirteen and the next step.
17
+
18
+ **The takeover tier defaults off, and that is structural.** The cursor is only ever moved because you
19
+ opened `takeoverAllowed` **and** asked for it on the call (`takeover:true`), so an upgrade cannot
20
+ start moving your cursor by itself. Keyboard injection lives inside that tier only, only when asked
21
+ (`keyInput:"inject"`), and only for targets with no other door — and, measured, it does **not** work
22
+ on this host's terminal, so the terminal stays refused rather than becoming a promise.
25
23
 
26
24
  Source, the measurement scripts behind every number below, and the release history live at
27
25
  **<https://github.com/drscrewdriver/dsh-windows-parallel-mcp>** — issues are the right place for
@@ -188,6 +186,29 @@ call, not at plugin load.
188
186
  `engines.dsh` is an explicit two-sided range. There is no runtime version probing and no silent
189
187
  degradation.
190
188
 
189
+ ## Typed surface
190
+
191
+ `types/index.d.ts` is written by hand, not emitted from an implementation. It covers the whole
192
+ contract: the five actions, every argument including the takeover fields, and all thirteen refusal
193
+ codes as a closed union.
194
+
195
+ Its wiring is measured in both resolution modes a consumer can use, rather than assumed from the
196
+ presence of a file:
197
+
198
+ - a `nodenext` consumer resolves it through the `types` condition inside `exports`. That condition is
199
+ load-bearing: delete it and the same consumer fails with `TS7016`, because once `exports` exists it
200
+ is the only entry point and the legacy field below is never consulted;
201
+ - a classic resolver falls back to the top-level `types` field. Delete `exports` entirely and the
202
+ consumer still type-checks.
203
+
204
+ Neither field is decoration, so neither is removable on the assumption that the other covers it.
205
+
206
+ The declarations are also checked against the implementation, in the direction that catches drift:
207
+ `lib/` is type-checked under `allowJs + checkJs + strict` **against those same declarations**, so
208
+ renaming a field in one without the other fails a repo gate instead of a user's build. This stays
209
+ inside the package's zero-install-dependency promise — the compiler is borrowed from the workspace
210
+ when one is present, and the gate reports a named SKIP rather than a red when one is not.
211
+
191
212
  ## Settings
192
213
 
193
214
  | key | default | effect |
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
- /** Validate one raw config object against FIELDS. Returns `{ value, issues }` standard-schema style. */
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));
package/lib/engine.js CHANGED
@@ -41,6 +41,9 @@ export function workerScript(from = HERE) {
41
41
  * UIAutomationClient, and it needs no installation — which is the project's only citable difference
42
42
  * against competitors that require uv/Python or an MSVC runtime (findings.md TS-1). pwsh is accepted
43
43
  * when the operator points at it, because it is a superset for these calls.
44
+ * @param {string} [explicitPath]
45
+ * @param {Record<string, string|undefined>} [env]
46
+ * @returns {string}
44
47
  */
45
48
  export function resolvePowerShell(explicitPath, env = process.env) {
46
49
  if (explicitPath && existsSync(explicitPath)) return explicitPath;
@@ -80,6 +83,7 @@ export class WorkerClient {
80
83
  this.started = false;
81
84
  this.restarts = 0;
82
85
  /** Last stderr lines, kept because a worker that dies usually explains itself there. */
86
+ /** @type {string[]} */
83
87
  this.stderrTail = [];
84
88
  this.buffer = '';
85
89
  }
@@ -138,11 +142,17 @@ export class WorkerClient {
138
142
  return this;
139
143
  }
140
144
 
145
+ /**
146
+ * @param {number|null} code
147
+ * @param {string|null} signal
148
+ * @returns {string}
149
+ */
141
150
  #exitMessage(code, signal) {
142
151
  const tail = this.stderrTail.length ? ` :: ${this.stderrTail.slice(-3).join(' | ')}` : '';
143
152
  return `engine worker exited (code=${code ?? 'null'} signal=${signal ?? 'null'})${tail}`;
144
153
  }
145
154
 
155
+ /** @param {string} chunk */
146
156
  #onStdout(chunk) {
147
157
  this.buffer += chunk;
148
158
  let idx;
@@ -172,6 +182,7 @@ export class WorkerClient {
172
182
  }
173
183
  }
174
184
 
185
+ /** @param {string} reason */
175
186
  #failAll(reason) {
176
187
  for (const [id, entry] of this.pending) {
177
188
  clearTimeout(entry.timer);
@@ -183,12 +194,18 @@ export class WorkerClient {
183
194
  /**
184
195
  * Send one request and await its response object. Resolves with the whole envelope, so the caller
185
196
  * decides what a refusal means; this layer never turns a refusal into an exception.
197
+ * @param {any} payload
198
+ * @returns {Promise<any>}
186
199
  */
187
200
  request(payload) {
188
201
  this.start();
189
202
  const id = String(++this.seq);
190
203
  const line = JSON.stringify({ id, ...payload }) + '\n';
191
- const child = this.child;
204
+ // `start()` above either established a live child or threw, so this cast states a fact the
205
+ // method just enforced rather than suppressing an unknown. The same holds for `stdin`: this
206
+ // class spawns with stdio 'pipe', and narrowing it here keeps the runtime path byte-identical
207
+ // (a defensive `if (!stdin) throw` would add a branch that can never run).
208
+ const child = /** @type {import('node:child_process').ChildProcess} */ (this.child);
192
209
  return new Promise((resolvePromise, rejectPromise) => {
193
210
  const timer = setTimeout(() => {
194
211
  this.pending.delete(id);
@@ -201,7 +218,11 @@ export class WorkerClient {
201
218
  try { child.kill(); } catch { /* already gone */ }
202
219
  }, this.requestTimeoutMs);
203
220
  this.pending.set(id, { resolve: resolvePromise, reject: rejectPromise, timer });
204
- child.stdin.write(line, 'utf8', (err) => {
221
+ // The cast sits at the call site rather than in a `const stdin = ...` line so the emitted
222
+ // JavaScript keeps exactly the statements it had: this file's shape is reviewed as a document,
223
+ // and a typing exercise is not allowed to restructure it. `stdin` is `Writable | null` upstream
224
+ // but this class always spawns with stdio 'pipe'.
225
+ /** @type {import('node:stream').Writable} */ (child.stdin).write(line, 'utf8', (err) => {
205
226
  if (!err) return;
206
227
  this.pending.delete(id);
207
228
  clearTimeout(timer);
@@ -216,8 +237,14 @@ export class WorkerClient {
216
237
  this.child = null;
217
238
  this.#failAll('engine worker disposed');
218
239
  if (!child) return;
219
- try { child.stdin.end(); } catch { }
220
- await new Promise((done) => {
240
+ // Cast at the call site, not into a `const`: same reason as in request() -- the statements here
241
+ // must stay exactly what they are. `stdin` is `Writable | null` upstream; this class always
242
+ // spawns with stdio 'pipe', so the cast states the invariant instead of adding a dead branch.
243
+ try { /** @type {import('node:stream').Writable} */ (child.stdin).end(); } catch { }
244
+ // The `@param` hint is what TS2810 asks for under checkJs: it wants "this resolve may be called
245
+ // with no argument" stated, because the promise never carries a value. Documentation only -- the
246
+ // emitted JavaScript is byte-identical to the unhinted form.
247
+ await new Promise(/** @param {(value?: void) => void} done */ (done) => {
221
248
  const t = setTimeout(() => { try { child.kill(); } catch { } done(); }, 1500);
222
249
  child.once('exit', () => { clearTimeout(t); done(); });
223
250
  });
package/lib/host-tools.js CHANGED
@@ -21,7 +21,30 @@ export const TOOL_NAME = 'wpm';
21
21
  /** The five actions, in the order the contract lists them. */
22
22
  export const ACTIONS = ['windows', 'click', 'type', 'focus', 'status'];
23
23
 
24
+ /**
25
+ * One field of the simplified parameter spec -- the shape the host's `defineTool` consumes and the
26
+ * shape `parametersToJsonSchema` translates. `required` is optional HERE and mandatory in the
27
+ * registered JSON Schema, which is the whole reason `parametersToJsonSchema` destructures it out:
28
+ * spelling that with a per-field object literal instead would make `field.required` a property that
29
+ * does not exist on most members (TS2339), i.e. the checker saying what the data already says.
30
+ * @typedef {object} ParamSpec
31
+ * @property {'string'|'number'|'boolean'} type
32
+ * @property {string} [description]
33
+ * @property {string[]} [enum]
34
+ * @property {boolean} [required]
35
+ */
36
+
37
+ /**
38
+ * The JSON Schema this plugin registers, as `parametersToJsonSchema` builds it.
39
+ * @typedef {object} SimplifiedSchema
40
+ * @property {string} [type]
41
+ * @property {Record<string, ParamSpec>} [properties]
42
+ * @property {string[]} [required]
43
+ * @property {boolean} [additionalProperties]
44
+ */
45
+
24
46
  /** Simplified parameter spec — the same shape the host's `defineTool` consumes. */
47
+ /** @type {Record<string, ParamSpec>} */
25
48
  export const PARAMETERS = {
26
49
  action: {
27
50
  type: 'string',
@@ -81,9 +104,13 @@ export const PARAMETERS = {
81
104
  * Kept separate and exported so test/schema-test.mjs can compare the shape this plugin registers
82
105
  * against src/schema/tools.json: the contract file is the source of truth, and a divergence between
83
106
  * "what the model is told" and "what the registry accepts" is invisible until a call is rejected.
107
+ * @param {Record<string, ParamSpec>} [spec]
108
+ * @returns {SimplifiedSchema}
84
109
  */
85
110
  export function parametersToJsonSchema(spec = PARAMETERS) {
111
+ /** @type {Record<string, any>} */
86
112
  const properties = {};
113
+ /** @type {string[]} */
87
114
  const required = [];
88
115
  for (const [name, field] of Object.entries(spec)) {
89
116
  const { required: isRequired, ...rest } = field;
@@ -93,8 +120,14 @@ export function parametersToJsonSchema(spec = PARAMETERS) {
93
120
  return { type: 'object', properties, required, additionalProperties: false };
94
121
  }
95
122
 
96
- /** Minimal argument validation. Returns a list of human-readable violations, empty when valid. */
123
+ /**
124
+ * Minimal argument validation. Returns a list of human-readable violations, empty when valid.
125
+ * @param {SimplifiedSchema} schema
126
+ * @param {any} args
127
+ * @returns {string[]}
128
+ */
97
129
  export function validateArguments(schema, args) {
130
+ /** @type {string[]} */
98
131
  const problems = [];
99
132
  if (args === null || typeof args !== 'object' || Array.isArray(args)) return ['arguments must be an object'];
100
133
  for (const name of schema.required ?? []) {
@@ -117,7 +150,12 @@ export function validateArguments(schema, args) {
117
150
  return problems;
118
151
  }
119
152
 
120
- /** The local shim: same input, same registry-ready output shape. */
153
+ /**
154
+ * The local shim: same input, same registry-ready output shape.
155
+ * @param {{name: string, description: string, parameters: Record<string, ParamSpec>,
156
+ * output: {schema: any, render: any}, execute: (args: any, exec: any) => any}} options
157
+ * @returns {any}
158
+ */
121
159
  export function localDefineTool(options) {
122
160
  const parameters = parametersToJsonSchema(options.parameters);
123
161
  const userExecute = options.execute;
@@ -134,6 +172,7 @@ export function localDefineTool(options) {
134
172
  // `args` makes that code path unreachable -- the abort arrives, nothing is listening, and the call
135
173
  // runs to completion. Measured: the first version of this shim did exactly that, and test/signal-test.mjs
136
174
  // caught it as "the cancellation was not reported" while everything else looked green.
175
+ /** @param {any} args @param {any} exec @returns {Promise<any>} */
137
176
  async execute(args, exec) {
138
177
  const problems = validateArguments(parameters, args);
139
178
  if (problems.length) {