dsh-windows-parallel-mcp 0.1.0 → 0.1.2
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.md +126 -0
- package/INSTALL.md +2 -2
- package/README.md +19 -3
- package/dsh.plugin.json +1 -1
- package/lib/config.js +125 -125
- package/lib/index.js +393 -330
- package/lib/proof-window.mjs +241 -0
- package/package.json +6 -1
- package/src/engine/engine.ps1 +363 -313
- package/src/engine/overlay.ps1 +383 -368
- package/src/engine/win.ps1 +621 -581
- package/src/engine/worker.ps1 +4 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Dates are the registry `time` values for each version, not git commit dates — a commit date records
|
|
4
|
+
when someone typed, a publish time records when a version became installable, and only the second
|
|
5
|
+
one is a promise to anyone installing it.
|
|
6
|
+
|
|
7
|
+
## 0.1.2 — 2026-11-21
|
|
8
|
+
|
|
9
|
+
The proof chain became real: what started as "the README says the cursor never moves" ended as a
|
|
10
|
+
per-call measurement, a build-time guarantee, and — recorded honestly — three judgment designs that
|
|
11
|
+
the real desktop rejected before one survived.
|
|
12
|
+
|
|
13
|
+
**Added**
|
|
14
|
+
- Every `click` carries a disturbance proof: `proof=pass|inconclusive|fail|insufficient(…)` in the
|
|
15
|
+
text plus structured `proof` / `proofDimensions`. The engine samples cursor/foreground/focus/
|
|
16
|
+
last-physical-input-age in two windows — a pre-action control (nothing running, by construction)
|
|
17
|
+
and inside the settle wait it already pays; four read-only syscalls, no new process.
|
|
18
|
+
- `lib/proof-window.mjs` — the one pure implementation of the judgment. `sampler.mjs` delegates to
|
|
19
|
+
it too: the fleet reachability numbers and the per-action proof cannot drift into two instruments
|
|
20
|
+
sharing one name. 32 synthetic unit arms pin the semantics, including cases that must FAIL —
|
|
21
|
+
a verdict function that only ever says pass is worthless, and the arms check it can say otherwise.
|
|
22
|
+
- `scripts/check-no-cursor-control.mjs` — build gate: no shipped engine file may contain
|
|
23
|
+
`SetCursorPos` / `SendInput` / `mouse_event` / `keybd_event`. Verified non-vacuous (injecting
|
|
24
|
+
SetCursorPos turns it red; removing it turns it green, no residue).
|
|
25
|
+
- `scripts/idle-baseline.mjs` — re-runnable probe of what the cursor does with NOTHING running.
|
|
26
|
+
Measured answer on the authoring machine: up to 3 unexplained gaps / 11 px. This is why the
|
|
27
|
+
runtime cursor dimension reports and never accuses.
|
|
28
|
+
- Marker placement through the shipped plugin is verified end-to-end against an independent oracle:
|
|
29
|
+
a real click puts the marker over the point it hit in physical pixels, and the marker is proven
|
|
30
|
+
(via `EnumWindows`) topmost-over-the-target while `GetForegroundWindow` stays unchanged.
|
|
31
|
+
|
|
32
|
+
**Corrected**
|
|
33
|
+
- The cursor guarantee was MEASURED OUT of the runtime sensor and INTO the build gate. Two runtime
|
|
34
|
+
rules failed on clean clicks (a strict 1 px bar: 3.16 px; a control-window noise floor: 7.07 px,
|
|
35
|
+
the floor itself duration-biased). Positions cannot attribute motion to a cause; the idle baseline
|
|
36
|
+
proves even multi-gap motion is ambient on a live desktop. Tuning the number until reds disappear
|
|
37
|
+
would have been laundering, so the rule changed shape instead: zero unexplained gaps passes,
|
|
38
|
+
anything else is inconclusive with the number surfaced, and the actual promise (no cursor control
|
|
39
|
+
exists in the shipped code) is decidable at build time.
|
|
40
|
+
- The disturbance sensor no longer contradicts the product contract: the bounded-flash tier raises
|
|
41
|
+
foreground deliberately and restores it; those switches are reported as `declared`, not failed.
|
|
42
|
+
("Never KEEP the foreground" is owned by the restore table — `restore_failed` — not by sampling.)
|
|
43
|
+
A pass verdict can no longer print "no switches" while carrying declared ones.
|
|
44
|
+
- Overlay cold-start wait raised to 6 s: the runspace JITs WPF past the old 2.5 s budget on a cold
|
|
45
|
+
worker, and the caller read a false "overlay not running".
|
|
46
|
+
- Gate philosophy for occluded desktops, applied to a TOCTOU case (a fullscreen video window moving
|
|
47
|
+
over the point between premise-probe and click): the engine's refusal is correct behaviour, so the
|
|
48
|
+
arms re-probe and convert to a NAMED SKIP. Desktop the test doesn't control never reads as red;
|
|
49
|
+
and a silent skip never reads as tested either.
|
|
50
|
+
- A real product bug in the marker path, caught by the gate going red intermittently (and fixed at
|
|
51
|
+
the cause, not the symptom): the overlay's readiness handshake **polled one flag and judged
|
|
52
|
+
another**. It waited for `OverlayHwnd` — assigned right after `Show()`, before the ex-style trio
|
|
53
|
+
is applied — but reported `running = OverlayOn`, set only after trio + hotkey + pump. So during
|
|
54
|
+
that window `status` said "not running" about an overlay that was initialising, AND read back a
|
|
55
|
+
half-styled window (`exStyle=0x00080008`, TOPMOST|LAYERED but NO TRANSPARENT — WPF's own bits
|
|
56
|
+
before the explicit trio lands). The Node half's fire-and-forget `markPoint` sequenced placement
|
|
57
|
+
behind the handshake; the handshake rejected; the marker request was skipped for a click that had
|
|
58
|
+
already answered, so nobody ever retried and the marker stayed parked at (-2000,-2000). One
|
|
59
|
+
warning, then silence forever. That was not a flake to be slept past:
|
|
60
|
+
the readiness flag is now the judgment flag (`OverlayOn`), a budget that merely expired reports a
|
|
61
|
+
third state (`starting`) instead of masquerading as a crash, and placement retries on a bounded
|
|
62
|
+
6 s deadline that stops immediately when the start is *provably* dead (a reason + not starting).
|
|
63
|
+
Patience lives where a stop condition can be named — the worker-side sleep cannot.
|
|
64
|
+
|
|
65
|
+
**Verified for this version**
|
|
66
|
+
- 12-arm gate green; live clicks through the SHIPPED plugin: proof=pass across 18–22 sample gaps
|
|
67
|
+
with `[cursor=pass fg=pass focus=pass]`; four-run stability: 3 pass + 1 ambient inconclusive
|
|
68
|
+
surfaced as WARN (anti-vacuity: weaker-than-pass never prints as INFO).
|
|
69
|
+
- The independent marker oracle now ANCHORS on the overlay handle the product reports via
|
|
70
|
+
`status` (`overlayHwnd=...`). Matching by title alone could grade a leaked same-titled window from
|
|
71
|
+
an earlier run — certifying a marker we never placed; more than one candidate is now reported as
|
|
72
|
+
ambiguous rather than silently resolved to `$hits[0]`.
|
|
73
|
+
- `lib/proof-window.mjs` confirmed inside the tarball (20 entries).
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## 0.1.1 — 2026-11-20
|
|
78
|
+
|
|
79
|
+
The same product as 0.1.0. This version exists to fix the packaging chain, not the behaviour.
|
|
80
|
+
|
|
81
|
+
**Changed**
|
|
82
|
+
- Repository line endings normalised to LF. 0.1.0 was published from a tree where an editing script
|
|
83
|
+
had converted ten files to CRLF, so the registry tarball (sha256 `84196f21…`) and this repository
|
|
84
|
+
no longer hashed the same even though the code was identical. 0.1.1 restores "the repository and
|
|
85
|
+
the published artifact are the same bytes".
|
|
86
|
+
- `publishConfig` is now explicit: `{ "access": "public", "tag": "latest" }`. The default was
|
|
87
|
+
already `latest`, but a default is a property of npm while a declaration is a property of this
|
|
88
|
+
package — the difference only shows up the first time someone publishes a prerelease.
|
|
89
|
+
|
|
90
|
+
**Verified for this version**
|
|
91
|
+
- 11 local gates green: PowerShell parse / encoding / static-call, refusal vocabulary, tool schema,
|
|
92
|
+
package contents, host half + sidecar, overlay promises, marker end-to-end, JS syntax.
|
|
93
|
+
- The overlay marker is measurably click-through: `exStyle 0x08080028`, foreground unchanged across
|
|
94
|
+
`Show()`, an independent process confirming `WindowFromPoint` at the marker's centre returns the
|
|
95
|
+
window underneath, and the marker covering the clicked point in physical pixels.
|
|
96
|
+
- The pause chord is measured, not assumed: `Ctrl+Alt+Q` is a first candidate, and on the machine
|
|
97
|
+
this was built on it was owned by another app (Win32 1409), so the engine walked a candidate list
|
|
98
|
+
and registered `Ctrl+Alt+W`. `status` reports the chord that actually registered.
|
|
99
|
+
|
|
100
|
+
**Not fixed in this version** (unchanged from 0.1.0, stated rather than implied)
|
|
101
|
+
- The settings pill and the four-value switch surface do not exist yet.
|
|
102
|
+
- `restore_failed` has no end-to-end test: it needs an elevated window that can be raised, and no
|
|
103
|
+
such window was present at build time. The decision-table branch is covered by unit tests; the
|
|
104
|
+
live path is not.
|
|
105
|
+
|
|
106
|
+
## 0.1.0 — 2026-11-20
|
|
107
|
+
|
|
108
|
+
First version with a working plugin in it. Everything before this was a reservation stub.
|
|
109
|
+
|
|
110
|
+
- One tool, `wpm`, with five actions: `windows`, `status`, `click`, `type`, `focus`.
|
|
111
|
+
- A PowerShell sidecar (Windows PowerShell 5.1, nothing to install) driven over a JSON line protocol,
|
|
112
|
+
lazily started so the host's boot path does not pay for a tool nobody called.
|
|
113
|
+
- Eight refusal codes as a three-way contract: what fires, what the schema promises, what the docs
|
|
114
|
+
explain. A gate fails when the three disagree.
|
|
115
|
+
- A click-through, always-on-top marker placed at the point a click hit, and a global pause chord.
|
|
116
|
+
- Measured: window-message tier causes 0 foreground changes in 6/6 rounds with 0 px cursor movement;
|
|
117
|
+
the UI Automation tier's focus takeover returns in 15–95 ms net against a 120 ms budget.
|
|
118
|
+
|
|
119
|
+
## 0.0.1 — 2026-11-18
|
|
120
|
+
|
|
121
|
+
Reservation stub. The name was reserved before the measurement was done; installing this version
|
|
122
|
+
gives you a README and nothing else. Kept for history, not for use.
|
|
123
|
+
|
|
124
|
+
## 0.0.0-stage — 2026-11-18
|
|
125
|
+
|
|
126
|
+
The first reservation, same story as 0.0.1.
|
package/INSTALL.md
CHANGED
|
@@ -22,8 +22,8 @@ To install from a local build, pack first and install the tarball -- this is als
|
|
|
22
22
|
profile's other local-development plugins are mounted, and it matters for more than tidiness:
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
npm pack --ignore-scripts # -> dsh-windows-parallel-mcp-0.1.
|
|
26
|
-
dsh plugin --profile <profile> add /abs/path/to/dsh-windows-parallel-mcp-0.1.
|
|
25
|
+
npm pack --ignore-scripts # -> dsh-windows-parallel-mcp-0.1.1.tgz
|
|
26
|
+
dsh plugin --profile <profile> add /abs/path/to/dsh-windows-parallel-mcp-0.1.1.tgz
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
A `link:` install keeps the package's REAL path outside the profile tree, and Node resolves bare
|
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# dsh-windows-parallel-mcp
|
|
2
2
|
|
|
3
|
-
> **0.1.
|
|
4
|
-
> below is the measured one.
|
|
5
|
-
>
|
|
3
|
+
> **0.1.2 — every real click now carries its own disturbance proof.** The name was reserved earlier
|
|
4
|
+
> under a weaker claim (see [CHANGELOG.md](CHANGELOG.md)); the claim below is the measured one.
|
|
5
|
+
> 0.1.1 is 0.1.0's behaviour with a corrected packaging chain; 0.1.2 adds the runtime proof chain —
|
|
6
|
+
> `wpm click` returns a `proof=` verdict and `proofDimensions`, measured against the desktop around
|
|
7
|
+
> your own call.
|
|
6
8
|
|
|
7
9
|
A DSH plugin that lets an agent drive **its own** Windows windows without moving your cursor. Where
|
|
8
10
|
a window accepts a window message, you never lose focus at all. Where it only exposes UI Automation,
|
|
@@ -56,6 +58,20 @@ Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_targe
|
|
|
56
58
|
`terminal_no_door`, `needs_facts`, `action_failed`, `restore_failed`. Each carries a reason and a
|
|
57
59
|
next step — see [docs/refusals.md](docs/refusals.md).
|
|
58
60
|
|
|
61
|
+
**Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
|
|
62
|
+
verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
|
|
63
|
+
samples cursor position, foreground window, keyboard focus and last-physical-input age — in a short
|
|
64
|
+
pre-action control window (when, by construction, nothing was running) and inside the settle wait it
|
|
65
|
+
already pays. The judgment is one pure function (`lib/proof-window.mjs`, unit-tested against 32
|
|
66
|
+
synthetic windows whose answers are known by construction). What it honestly can and cannot say:
|
|
67
|
+
a switch of foreground on a quiet tier fails — the control shows the desktop was not doing it, so it
|
|
68
|
+
is the action's to explain; a cursor jump is *reported*, never accused, because with nothing running
|
|
69
|
+
this desktop's cursor showed multi-gap unexplained motion on its own (a re-runnable probe ships:
|
|
70
|
+
`scripts/idle-baseline.mjs`). The cursor promise therefore lives where blame is decidable: a build
|
|
71
|
+
gate asserts no shipped file contains `SetCursorPos`/`SendInput`/`mouse_event`/`keybd_event`, so a
|
|
72
|
+
regression that adds cursor control fails at build time with certainty instead of being hunted at
|
|
73
|
+
runtime among ambient motion.
|
|
74
|
+
|
|
59
75
|
## What it does not do
|
|
60
76
|
|
|
61
77
|
- **No synthetic input.** There is no `physical` option: it is absent from the schema, not disabled
|
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-windows-parallel-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"description": "One tool, five actions: drive a Windows window without moving the cursor or stealing the keyboard. Prefers window messages (zero foreground change); falls back to UI Automation with a bounded, self-reversing focus flash (measured net return 15-95 ms).",
|
|
6
6
|
"engines": {
|
package/lib/config.js
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
// config.js — the settings surface, built on the host's schema library when it is reachable and on a
|
|
2
|
-
// standard-schema shim when it is not.
|
|
3
|
-
//
|
|
4
|
-
// WHY THIS FILE EXISTS AT ALL. The first version exported `Config` as a factory function. Cordis
|
|
5
|
-
// requires a *standard-schema value* — it calls `Config['~standard'].validate(config)` — so the
|
|
6
|
-
// plugin failed to activate with `Cannot read properties of undefined (reading 'validate')`, and the
|
|
7
|
-
// only reason it was found is that the profile was actually booted (`dsh --profile wpm-dev headless`)
|
|
8
|
-
// instead of being assumed good from a passing unit test. A plugin that never activates is the worst
|
|
9
|
-
// failure mode available: it registers no tool, prints one warning into a busy log, and looks
|
|
10
|
-
// installed.
|
|
11
|
-
//
|
|
12
|
-
// WHY NOT A HARD DEPENDENCY. `@deepseek-ai/schemastery` is a host-provided peer. Declaring it as a
|
|
13
|
-
// dependency would drag a second copy of the schema library into the profile, and declaring it as a
|
|
14
|
-
// peer would make install fail wherever the host resolves peers differently than it does here. So the
|
|
15
|
-
// import is attempted, and the shim is the documented fallback.
|
|
16
|
-
//
|
|
17
|
-
// WHAT THE SHIM IS. A standard-schema implementation over a flat, explicitly typed field list. It
|
|
18
|
-
// applies defaults, rejects wrong types and out-of-range values, and reports issues in the shape
|
|
19
|
-
// Cordis renders. It is NOT schemastery: the settings FORM is rendered from schemastery's field
|
|
20
|
-
// metadata, so a host that cannot resolve schemastery gives the user no form — the values still work
|
|
21
|
-
// from the bundle patch. That limitation is stated in the README rather than papered over.
|
|
22
|
-
const FIELDS = [
|
|
23
|
-
{ key: 'enabled', type: 'boolean', default: true, volatile: true,
|
|
24
|
-
description: 'Master switch. When off, every action refuses with `paused` before the engine is reached.' },
|
|
25
|
-
{ key: 'settleMs', type: 'number', default: 350, min: 0, max: 2000, volatile: true,
|
|
26
|
-
description: 'How long the target app gets to commit its state before the effect is judged.' },
|
|
27
|
-
{ key: 'requestTimeoutMs', type: 'number', default: 20000, min: 1000, max: 600000,
|
|
28
|
-
description: 'A worker that stops answering is killed and restarted on the next call.' },
|
|
29
|
-
{ key: 'powershellPath', type: 'string', default: '',
|
|
30
|
-
description: 'Override the PowerShell executable. Windows PowerShell 5.1 is the floor; pwsh is accepted.' },
|
|
31
|
-
{ key: 'overlay', type: 'boolean', default: true, volatile: true,
|
|
32
|
-
description: 'Show the click-through AI marker at the point each action touched. It never takes '
|
|
33
|
-
+ 'the foreground and never intercepts a click (measured). The first action pays a one-time '
|
|
34
|
-
+ 'worker round-trip while the overlay starts; after that a placement costs ~19ms and does not '
|
|
35
|
-
+ 'gate the action result.' },
|
|
36
|
-
{ key: 'logWorkerStderr', type: 'boolean', default: false, volatile: true,
|
|
37
|
-
description: 'Forward the sidecar’s stderr diagnostics to the host log.' },
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
/** Defaults, for documentation and for tests that must not depend on a resolver. */
|
|
41
|
-
export const CONFIG_DEFAULTS = Object.fromEntries(FIELDS.map((f) => [f.key, f.default]));
|
|
42
|
-
|
|
43
|
-
/** Validate one raw config object against FIELDS. Returns `{ value, issues }` standard-schema style. */
|
|
44
|
-
function validateWithShim(raw) {
|
|
45
|
-
const input = raw && typeof raw === 'object' ? raw : {};
|
|
46
|
-
const value = {};
|
|
47
|
-
const issues = [];
|
|
48
|
-
for (const field of FIELDS) {
|
|
49
|
-
const given = input[field.key];
|
|
50
|
-
if (given === undefined || given === null) { value[field.key] = field.default; continue; }
|
|
51
|
-
if (field.type === 'boolean') {
|
|
52
|
-
if (typeof given !== 'boolean') issues.push({ message: `expected a boolean`, path: [field.key] });
|
|
53
|
-
else value[field.key] = given;
|
|
54
|
-
} else if (field.type === 'number') {
|
|
55
|
-
if (typeof given !== 'number' || !Number.isFinite(given)) {
|
|
56
|
-
issues.push({ message: `expected a finite number`, path: [field.key] });
|
|
57
|
-
} else if ((field.min !== undefined && given < field.min) || (field.max !== undefined && given > field.max)) {
|
|
58
|
-
issues.push({ message: `expected ${field.min}..${field.max}`, path: [field.key] });
|
|
59
|
-
} else {
|
|
60
|
-
value[field.key] = given;
|
|
61
|
-
}
|
|
62
|
-
} else if (typeof given !== 'string') {
|
|
63
|
-
issues.push({ message: `expected a string`, path: [field.key] });
|
|
64
|
-
} else {
|
|
65
|
-
value[field.key] = given;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
for (const key of Object.keys(input)) {
|
|
69
|
-
if (!FIELDS.some((f) => f.key === key)) {
|
|
70
|
-
// Unknown keys are an issue, not silence: a typo in the bundle patch would otherwise take the
|
|
71
|
-
// default and leave the user wondering why their setting did nothing.
|
|
72
|
-
issues.push({ message: `unknown setting`, path: [key] });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return issues.length ? { issues } : { value };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const shimSchema = {
|
|
79
|
-
'~standard': {
|
|
80
|
-
version: 1,
|
|
81
|
-
vendor: 'dsh-windows-parallel-mcp',
|
|
82
|
-
validate: validateWithShim,
|
|
83
|
-
},
|
|
84
|
-
/** Marker parity with schemastery so `typeof field.volatile === 'function'` probes behave. */
|
|
85
|
-
fields: FIELDS,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Build the Config value. Tries the host's schema library first; falls back to the shim.
|
|
90
|
-
* Returns `{ schema, source }` so the caller can log which one is active -- a silent fallback is how
|
|
91
|
-
* "works on my machine" diverges from "works on the host".
|
|
92
|
-
*/
|
|
93
|
-
export async function createConfigSchema() {
|
|
94
|
-
try {
|
|
95
|
-
// Static-import bridge (see lib/peers-schemastery.js): a dynamic bare specifier does not
|
|
96
|
-
// resolve for a `link:`-installed package under the host, which is exactly why the desktop
|
|
97
|
-
// profile fell to the shim and rendered no settings form.
|
|
98
|
-
const mod = await import('./peers-schemastery.js');
|
|
99
|
-
const z = mod?.z;
|
|
100
|
-
if (z && typeof z.object === 'function') {
|
|
101
|
-
const shape = {};
|
|
102
|
-
for (const field of FIELDS) {
|
|
103
|
-
let s;
|
|
104
|
-
if (field.type === 'boolean') s = z.boolean();
|
|
105
|
-
else if (field.type === 'number') s = z.number();
|
|
106
|
-
else s = z.string();
|
|
107
|
-
if (field.min !== undefined || field.max !== undefined) {
|
|
108
|
-
if (typeof s.min === 'function' && field.min !== undefined) s = s.min(field.min);
|
|
109
|
-
if (typeof s.max === 'function' && field.max !== undefined) s = s.max(field.max);
|
|
110
|
-
}
|
|
111
|
-
if (field.description) s = s.description(field.description);
|
|
112
|
-
s = s.default(field.default);
|
|
113
|
-
// `.volatile()` marks a field as hot-reloadable on 0.1.7+. Guarded because older schema
|
|
114
|
-
// lines in the same major do not have it.
|
|
115
|
-
if (field.volatile && typeof s.volatile === 'function') s = s.volatile();
|
|
116
|
-
shape[field.key] = s;
|
|
117
|
-
}
|
|
118
|
-
const schema = z.object(shape);
|
|
119
|
-
return { schema: typeof schema.prefault === 'function' ? schema.prefault({}) : schema, source: '@deepseek-ai/schemastery' };
|
|
120
|
-
}
|
|
121
|
-
} catch {
|
|
122
|
-
// Documented fallback, reported through `source`.
|
|
123
|
-
}
|
|
124
|
-
return { schema: shimSchema, source: 'local-standard-schema-shim' };
|
|
125
|
-
}
|
|
1
|
+
// config.js — the settings surface, built on the host's schema library when it is reachable and on a
|
|
2
|
+
// standard-schema shim when it is not.
|
|
3
|
+
//
|
|
4
|
+
// WHY THIS FILE EXISTS AT ALL. The first version exported `Config` as a factory function. Cordis
|
|
5
|
+
// requires a *standard-schema value* — it calls `Config['~standard'].validate(config)` — so the
|
|
6
|
+
// plugin failed to activate with `Cannot read properties of undefined (reading 'validate')`, and the
|
|
7
|
+
// only reason it was found is that the profile was actually booted (`dsh --profile wpm-dev headless`)
|
|
8
|
+
// instead of being assumed good from a passing unit test. A plugin that never activates is the worst
|
|
9
|
+
// failure mode available: it registers no tool, prints one warning into a busy log, and looks
|
|
10
|
+
// installed.
|
|
11
|
+
//
|
|
12
|
+
// WHY NOT A HARD DEPENDENCY. `@deepseek-ai/schemastery` is a host-provided peer. Declaring it as a
|
|
13
|
+
// dependency would drag a second copy of the schema library into the profile, and declaring it as a
|
|
14
|
+
// peer would make install fail wherever the host resolves peers differently than it does here. So the
|
|
15
|
+
// import is attempted, and the shim is the documented fallback.
|
|
16
|
+
//
|
|
17
|
+
// WHAT THE SHIM IS. A standard-schema implementation over a flat, explicitly typed field list. It
|
|
18
|
+
// applies defaults, rejects wrong types and out-of-range values, and reports issues in the shape
|
|
19
|
+
// Cordis renders. It is NOT schemastery: the settings FORM is rendered from schemastery's field
|
|
20
|
+
// metadata, so a host that cannot resolve schemastery gives the user no form — the values still work
|
|
21
|
+
// from the bundle patch. That limitation is stated in the README rather than papered over.
|
|
22
|
+
const FIELDS = [
|
|
23
|
+
{ key: 'enabled', type: 'boolean', default: true, volatile: true,
|
|
24
|
+
description: 'Master switch. When off, every action refuses with `paused` before the engine is reached.' },
|
|
25
|
+
{ key: 'settleMs', type: 'number', default: 350, min: 0, max: 2000, volatile: true,
|
|
26
|
+
description: 'How long the target app gets to commit its state before the effect is judged.' },
|
|
27
|
+
{ key: 'requestTimeoutMs', type: 'number', default: 20000, min: 1000, max: 600000,
|
|
28
|
+
description: 'A worker that stops answering is killed and restarted on the next call.' },
|
|
29
|
+
{ key: 'powershellPath', type: 'string', default: '',
|
|
30
|
+
description: 'Override the PowerShell executable. Windows PowerShell 5.1 is the floor; pwsh is accepted.' },
|
|
31
|
+
{ key: 'overlay', type: 'boolean', default: true, volatile: true,
|
|
32
|
+
description: 'Show the click-through AI marker at the point each action touched. It never takes '
|
|
33
|
+
+ 'the foreground and never intercepts a click (measured). The first action pays a one-time '
|
|
34
|
+
+ 'worker round-trip while the overlay starts; after that a placement costs ~19ms and does not '
|
|
35
|
+
+ 'gate the action result.' },
|
|
36
|
+
{ key: 'logWorkerStderr', type: 'boolean', default: false, volatile: true,
|
|
37
|
+
description: 'Forward the sidecar’s stderr diagnostics to the host log.' },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
/** Defaults, for documentation and for tests that must not depend on a resolver. */
|
|
41
|
+
export const CONFIG_DEFAULTS = Object.fromEntries(FIELDS.map((f) => [f.key, f.default]));
|
|
42
|
+
|
|
43
|
+
/** Validate one raw config object against FIELDS. Returns `{ value, issues }` standard-schema style. */
|
|
44
|
+
function validateWithShim(raw) {
|
|
45
|
+
const input = raw && typeof raw === 'object' ? raw : {};
|
|
46
|
+
const value = {};
|
|
47
|
+
const issues = [];
|
|
48
|
+
for (const field of FIELDS) {
|
|
49
|
+
const given = input[field.key];
|
|
50
|
+
if (given === undefined || given === null) { value[field.key] = field.default; continue; }
|
|
51
|
+
if (field.type === 'boolean') {
|
|
52
|
+
if (typeof given !== 'boolean') issues.push({ message: `expected a boolean`, path: [field.key] });
|
|
53
|
+
else value[field.key] = given;
|
|
54
|
+
} else if (field.type === 'number') {
|
|
55
|
+
if (typeof given !== 'number' || !Number.isFinite(given)) {
|
|
56
|
+
issues.push({ message: `expected a finite number`, path: [field.key] });
|
|
57
|
+
} else if ((field.min !== undefined && given < field.min) || (field.max !== undefined && given > field.max)) {
|
|
58
|
+
issues.push({ message: `expected ${field.min}..${field.max}`, path: [field.key] });
|
|
59
|
+
} else {
|
|
60
|
+
value[field.key] = given;
|
|
61
|
+
}
|
|
62
|
+
} else if (typeof given !== 'string') {
|
|
63
|
+
issues.push({ message: `expected a string`, path: [field.key] });
|
|
64
|
+
} else {
|
|
65
|
+
value[field.key] = given;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (const key of Object.keys(input)) {
|
|
69
|
+
if (!FIELDS.some((f) => f.key === key)) {
|
|
70
|
+
// Unknown keys are an issue, not silence: a typo in the bundle patch would otherwise take the
|
|
71
|
+
// default and leave the user wondering why their setting did nothing.
|
|
72
|
+
issues.push({ message: `unknown setting`, path: [key] });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return issues.length ? { issues } : { value };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const shimSchema = {
|
|
79
|
+
'~standard': {
|
|
80
|
+
version: 1,
|
|
81
|
+
vendor: 'dsh-windows-parallel-mcp',
|
|
82
|
+
validate: validateWithShim,
|
|
83
|
+
},
|
|
84
|
+
/** Marker parity with schemastery so `typeof field.volatile === 'function'` probes behave. */
|
|
85
|
+
fields: FIELDS,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Build the Config value. Tries the host's schema library first; falls back to the shim.
|
|
90
|
+
* Returns `{ schema, source }` so the caller can log which one is active -- a silent fallback is how
|
|
91
|
+
* "works on my machine" diverges from "works on the host".
|
|
92
|
+
*/
|
|
93
|
+
export async function createConfigSchema() {
|
|
94
|
+
try {
|
|
95
|
+
// Static-import bridge (see lib/peers-schemastery.js): a dynamic bare specifier does not
|
|
96
|
+
// resolve for a `link:`-installed package under the host, which is exactly why the desktop
|
|
97
|
+
// profile fell to the shim and rendered no settings form.
|
|
98
|
+
const mod = await import('./peers-schemastery.js');
|
|
99
|
+
const z = mod?.z;
|
|
100
|
+
if (z && typeof z.object === 'function') {
|
|
101
|
+
const shape = {};
|
|
102
|
+
for (const field of FIELDS) {
|
|
103
|
+
let s;
|
|
104
|
+
if (field.type === 'boolean') s = z.boolean();
|
|
105
|
+
else if (field.type === 'number') s = z.number();
|
|
106
|
+
else s = z.string();
|
|
107
|
+
if (field.min !== undefined || field.max !== undefined) {
|
|
108
|
+
if (typeof s.min === 'function' && field.min !== undefined) s = s.min(field.min);
|
|
109
|
+
if (typeof s.max === 'function' && field.max !== undefined) s = s.max(field.max);
|
|
110
|
+
}
|
|
111
|
+
if (field.description) s = s.description(field.description);
|
|
112
|
+
s = s.default(field.default);
|
|
113
|
+
// `.volatile()` marks a field as hot-reloadable on 0.1.7+. Guarded because older schema
|
|
114
|
+
// lines in the same major do not have it.
|
|
115
|
+
if (field.volatile && typeof s.volatile === 'function') s = s.volatile();
|
|
116
|
+
shape[field.key] = s;
|
|
117
|
+
}
|
|
118
|
+
const schema = z.object(shape);
|
|
119
|
+
return { schema: typeof schema.prefault === 'function' ? schema.prefault({}) : schema, source: '@deepseek-ai/schemastery' };
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
// Documented fallback, reported through `source`.
|
|
123
|
+
}
|
|
124
|
+
return { schema: shimSchema, source: 'local-standard-schema-shim' };
|
|
125
|
+
}
|