dsh-native-uia 0.2.0 → 0.6.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/README.md +81 -398
- package/client/client.js +236 -48
- package/cordis.patch.yml +7 -8
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +8 -17
- package/scripts/check-lease.mjs +1 -1
- package/scripts/lib/dsh-tools-stub.mjs +14 -0
- package/scripts/lib/load-tools-source.mjs +17 -16
- package/scripts/lib/sources.mjs +62 -0
- package/scripts/load-tools.mjs +74 -0
- package/scripts/measure-parse.mjs +2 -2
- package/scripts/regression-tools.mjs +155 -6
- package/scripts/regression-worker.ps1 +29 -0
- package/scripts/verify-live-style.mjs +46 -0
- package/scripts/verify-live.mjs +12 -18
- package/scripts/verify.mjs +953 -192
- package/src/activity-window.js +71 -7
- package/src/dashboard.js +27 -69
- package/src/guard.js +39 -10
- package/src/index.js +187 -77
- package/src/notes.js +83 -0
- package/src/state.js +97 -10
- package/src/themes.js +66 -0
- package/src/tools/defs/act.js +671 -0
- package/src/tools/defs/lifecycle.js +205 -0
- package/src/tools/defs/observe.js +325 -0
- package/src/tools/defs/pointer.js +328 -0
- package/src/tools/format.js +338 -0
- package/src/tools/index.js +125 -0
- package/src/tools/ocr.js +91 -0
- package/src/tools/recipes.js +49 -0
- package/src/tools/runtime.js +42 -0
- package/src/worker-client.js +32 -10
- package/worker/assets/dsh-whale.path +1 -0
- package/worker/indicator-server.ps1 +1107 -72
- package/worker/lib/01-core.ps1 +64 -0
- package/worker/lib/02-uia.ps1 +224 -0
- package/worker/lib/03-window.ps1 +194 -0
- package/worker/lib/04-match.ps1 +435 -0
- package/worker/lib/05-value.ps1 +254 -0
- package/worker/lib/06-snapshot.ps1 +412 -0
- package/worker/lib/07-action.ps1 +329 -0
- package/worker/lib/08-command.ps1 +1495 -0
- package/worker/lib/09-pointer.ps1 +840 -0
- package/worker/lib/10-dispatch.ps1 +132 -0
- package/worker/ps-stdio.ps1 +7 -2
- package/worker/uia-worker.ps1 +599 -4220
- package/locale/desktop/en.json +0 -6
- package/locale/desktop/zh.json +0 -6
- package/scripts/regression-halt-latch.mjs +0 -100
- package/src/native-uia-remote.js +0 -80
- package/src/panel-face.js +0 -14
- package/src/tools.js +0 -1482
- package/web/control.html +0 -1413
package/src/state.js
CHANGED
|
@@ -12,7 +12,6 @@ export class Store extends EventEmitter {
|
|
|
12
12
|
steps = [];
|
|
13
13
|
blocked = [];
|
|
14
14
|
log = [];
|
|
15
|
-
screenshot = null;
|
|
16
15
|
target = null;
|
|
17
16
|
killed = false;
|
|
18
17
|
// When the kill latch was armed (ms epoch). index.js uses the age to decide whether a mutating
|
|
@@ -24,9 +23,46 @@ export class Store extends EventEmitter {
|
|
|
24
23
|
// guard.POLICY.note names the mode from the same env switch.
|
|
25
24
|
readOnly = process.env.DSH_NATIVE_UIA_READ_ONLY === '1';
|
|
26
25
|
pointerMode = 'background';
|
|
26
|
+
// Overlay look: picked on the plugin page, persisted in settings.json, and sent with every
|
|
27
|
+
// indicator command. The catalog lives in themes.js; these are only the selected ids.
|
|
28
|
+
themeId = 'brand';
|
|
29
|
+
styleId = 'orb';
|
|
30
|
+
// The thin smoke at the capsule's inner lip is decoration, not information: it carries no state
|
|
31
|
+
// and the capsule is fully legible without it. So it is the person's choice, persisted like the
|
|
32
|
+
// other look settings. Default on -- it is the intended look, and a default-off decoration is a
|
|
33
|
+
// feature nobody finds.
|
|
34
|
+
mistOn = true;
|
|
35
|
+
// Whether the activation permission request was granted. False = every delivery command is
|
|
36
|
+
// refused at the worker choke point, exactly like read-only mode; observation stays available so
|
|
37
|
+
// the person can see what the plugin WOULD control before deciding. Read at the choke point, not
|
|
38
|
+
// cached in the client, so a future re-ask (panel button) applies to the next call immediately.
|
|
39
|
+
armed = false;
|
|
27
40
|
running = false;
|
|
28
|
-
visionRoute = false;
|
|
29
41
|
counters = { stepsRun: 0, actions: 0, blocked: 0, refused: 0, stepMsTotal: 0, stepSamples: 0 };
|
|
42
|
+
// Mouse buttons currently held down by computer_mouse action:"down". A dangling press is a stuck
|
|
43
|
+
// desktop (every later click becomes a drag), so it is tracked here and released on run end.
|
|
44
|
+
heldButtons = new Set();
|
|
45
|
+
// Repetition watchdog: signature -> {total, misses}. A model that keeps clicking the same point
|
|
46
|
+
// (or re-invoking the same ref after a missed verify) needs to be told to change approach; the
|
|
47
|
+
// alternative is an unbounded loop that looks like progress in the step list.
|
|
48
|
+
attempts = new Map();
|
|
49
|
+
// When the model last pressed ctrl+c (epoch ms, 0 = never). clipboard read is allowed only after
|
|
50
|
+
// this, so a run cannot read whatever the user happened to have copied before it started.
|
|
51
|
+
ctrlCAt = 0;
|
|
52
|
+
|
|
53
|
+
noteAttempt(sig, ok) {
|
|
54
|
+
const key = String(sig);
|
|
55
|
+
const cur = this.attempts.get(key) ?? { total: 0, misses: 0 };
|
|
56
|
+
cur.total += 1;
|
|
57
|
+
cur.misses = ok ? 0 : cur.misses + 1;
|
|
58
|
+
if (this.attempts.size > 80 && !this.attempts.has(key)) this.attempts.clear();
|
|
59
|
+
this.attempts.set(key, cur);
|
|
60
|
+
return cur;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
clearAttempts() {
|
|
64
|
+
this.attempts.clear();
|
|
65
|
+
}
|
|
30
66
|
|
|
31
67
|
/* Views shared by snapshot() and the state-class SSE frames: a partial frame must carry
|
|
32
68
|
the same mapped shape a full snapshot delivers, or the panel would render two dialects.
|
|
@@ -82,11 +118,6 @@ export class Store extends EventEmitter {
|
|
|
82
118
|
this.emit('state', { reason: 'tree', tree: this.#treeView() });
|
|
83
119
|
}
|
|
84
120
|
|
|
85
|
-
setScreenshot(entry) {
|
|
86
|
-
this.screenshot = { ...entry, at: Date.now() };
|
|
87
|
-
this.emit('screenshot', this.screenshot);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
121
|
step(step) {
|
|
91
122
|
this.steps.push({ id: `s${this.steps.length + 1}`, at: Date.now(), ...step });
|
|
92
123
|
trim(this.steps, LIMITS.steps);
|
|
@@ -103,6 +134,15 @@ export class Store extends EventEmitter {
|
|
|
103
134
|
this.counters.actions += n;
|
|
104
135
|
}
|
|
105
136
|
|
|
137
|
+
holdButton(button) {
|
|
138
|
+
this.heldButtons.add(String(button || 'left'));
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
releaseButton(button) {
|
|
143
|
+
return this.heldButtons.delete(String(button || 'left'));
|
|
144
|
+
}
|
|
145
|
+
|
|
106
146
|
block(entry) {
|
|
107
147
|
this.blocked.push({ id: `b${this.blocked.length + 1}`, at: Date.now(), ...entry });
|
|
108
148
|
trim(this.blocked, LIMITS.blocked);
|
|
@@ -133,6 +173,28 @@ export class Store extends EventEmitter {
|
|
|
133
173
|
return true;
|
|
134
174
|
}
|
|
135
175
|
|
|
176
|
+
setTheme(value) {
|
|
177
|
+
if (typeof value !== 'string' || value === '') return false;
|
|
178
|
+
this.themeId = value;
|
|
179
|
+
this.emit('state', { reason: 'theme', theme: value });
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
setStyle(value) {
|
|
184
|
+
if (typeof value !== 'string' || value === '') return false;
|
|
185
|
+
this.styleId = value;
|
|
186
|
+
this.emit('state', { reason: 'style', style: value });
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
setMist(value) {
|
|
191
|
+
// Strict on purpose: a settings file holding "false" as a string must not turn the smoke back on.
|
|
192
|
+
if (typeof value !== 'boolean') return false;
|
|
193
|
+
this.mistOn = value;
|
|
194
|
+
this.emit('state', { reason: 'mist', mist: value });
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
|
|
136
198
|
snapshot(policy) {
|
|
137
199
|
const c = this.counters;
|
|
138
200
|
return {
|
|
@@ -141,16 +203,18 @@ export class Store extends EventEmitter {
|
|
|
141
203
|
running: this.running === true,
|
|
142
204
|
killed: this.killed,
|
|
143
205
|
pointerMode: this.pointerMode,
|
|
206
|
+
theme: this.themeId,
|
|
207
|
+
style: this.styleId,
|
|
208
|
+
mist: this.mistOn === true,
|
|
209
|
+
armed: this.armed === true,
|
|
144
210
|
target: this.#targetView(),
|
|
145
211
|
policy,
|
|
146
|
-
remoteChannel: this.remoteChannel ?? 'pending',
|
|
147
212
|
stats: {
|
|
148
213
|
stepsRun: c.stepsRun,
|
|
149
214
|
actions: c.actions,
|
|
150
215
|
blocked: c.blocked,
|
|
151
216
|
refused: c.refused,
|
|
152
217
|
avgStepMs: c.stepSamples > 0 ? Math.round(c.stepMsTotal / c.stepSamples) : 0,
|
|
153
|
-
visionRoute: this.visionRoute,
|
|
154
218
|
},
|
|
155
219
|
},
|
|
156
220
|
windows: this.#windowsView(),
|
|
@@ -163,7 +227,6 @@ export class Store extends EventEmitter {
|
|
|
163
227
|
ms: s.ms ?? null,
|
|
164
228
|
verify: s.verify ?? null,
|
|
165
229
|
detail: s.detail ?? null,
|
|
166
|
-
screenshotUrl: s.screenshotUrl ?? null,
|
|
167
230
|
})),
|
|
168
231
|
blocked: this.blocked.map((b) => ({
|
|
169
232
|
id: b.id,
|
|
@@ -174,4 +237,28 @@ export class Store extends EventEmitter {
|
|
|
174
237
|
log: this.log.map((l) => ({ at: new Date(l.at).toISOString().slice(11, 19), level: l.level, text: l.text })),
|
|
175
238
|
};
|
|
176
239
|
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* What the plugin-page panel polls: the run's state plus its most recent step and log lines.
|
|
243
|
+
* Deliberately not a slice of snapshot(): the panel does not draw the element tree, and polling
|
|
244
|
+
* a 900-node tree every couple of seconds would be paid for nothing.
|
|
245
|
+
*/
|
|
246
|
+
summary() {
|
|
247
|
+
const last = this.steps[this.steps.length - 1] ?? null;
|
|
248
|
+
return {
|
|
249
|
+
running: this.running === true,
|
|
250
|
+
busy: this.busy === true,
|
|
251
|
+
killed: this.killed,
|
|
252
|
+
pointerMode: this.pointerMode,
|
|
253
|
+
theme: this.themeId,
|
|
254
|
+
style: this.styleId,
|
|
255
|
+
mist: this.mistOn === true,
|
|
256
|
+
armed: this.armed === true,
|
|
257
|
+
target: this.#targetView(),
|
|
258
|
+
steps: this.counters.stepsRun,
|
|
259
|
+
blocked: this.counters.blocked,
|
|
260
|
+
lastStep: last === null ? null : { label: last.label ?? '', status: last.status ?? '' },
|
|
261
|
+
log: this.log.slice(-3).map((l) => ({ at: new Date(l.at).toISOString().slice(11, 19), level: l.level, text: l.text })),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
177
264
|
}
|
package/src/themes.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The overlay's public theming surface: two ambient palettes and four capsule shapes.
|
|
3
|
+
*
|
|
4
|
+
* Colour lives here, not in the renderer and not in the panel: the panel draws names and swatches
|
|
5
|
+
* from this list, the activity window sends the chosen palette with every overlay command, and the
|
|
6
|
+
* indicator worker only consumes what it is handed.
|
|
7
|
+
*
|
|
8
|
+
* The shape is a separate axis and is chosen from STYLES; a theme changes the AMBIENT only, so the
|
|
9
|
+
* capsule shell keeps the same black body and silver hairline in both themes, because the shell
|
|
10
|
+
* colour is not up for change yet.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Two palettes. `ring*` paints the screen-edge glow; `pill*` is identical in both, because the
|
|
15
|
+
* capsule shell colour is not part of what a theme changes.
|
|
16
|
+
*
|
|
17
|
+
* `brand` is the brand black: a near-black ramp that reads as a vignette on a light wallpaper, not
|
|
18
|
+
* as a bright line. `graphite` is the cool blue-silver one, for a dark desktop where a dark rim
|
|
19
|
+
* would vanish. The renderer must paint the ring from `ringFrom`/`ringTo` only — `pillBorder` is
|
|
20
|
+
* identical in both palettes, so a ring built from it makes the switch look dead.
|
|
21
|
+
*/
|
|
22
|
+
export const THEMES = Object.freeze([
|
|
23
|
+
Object.freeze({ id: 'brand', name: '品牌黑', ringFrom: '#2A2E34', ringTo: '#000000', pillBg: '#0B0D10', pillBorder: '#A9B4C4', pillText: '#F2F5FA' }),
|
|
24
|
+
// Cool blue-silver: the bright one, for a dark desktop where a dark rim would vanish.
|
|
25
|
+
Object.freeze({ id: 'graphite', name: '石墨银', ringFrom: '#E6EBF2', ringTo: '#8593AA', pillBg: '#0B0D10', pillBorder: '#A9B4C4', pillText: '#F2F5FA' }),
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The capsule shapes the worker can actually build.
|
|
30
|
+
*
|
|
31
|
+
* This list is the panel's catalog, so it has to match the worker's style switch exactly: an id the
|
|
32
|
+
* worker cannot build is a switch that silently does nothing, and an id missing here is a shape the
|
|
33
|
+
* person cannot reach. All four are the same size (172×44 DIP) — a shape changes the shell's look,
|
|
34
|
+
* never the silhouette.
|
|
35
|
+
*/
|
|
36
|
+
export const STYLES = Object.freeze([
|
|
37
|
+
// `orb` keeps its historical id because settings.json persists it and the gates pin it; the label
|
|
38
|
+
// says what is actually drawn (the DSH whale cut out of a near-black shell).
|
|
39
|
+
Object.freeze({ id: 'orb', name: '深黑', hint: '深黑壳,白鲸直接画在壳上' }),
|
|
40
|
+
Object.freeze({ id: 'wave', name: '声波', hint: '三根声波条' }),
|
|
41
|
+
Object.freeze({ id: 'mark', name: '标块', hint: '浅色圆角块 + 深鲸' }),
|
|
42
|
+
Object.freeze({ id: 'inverse', name: '反白', hint: '白壳黑字,浅色壁纸' }),
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
export const DEFAULT_THEME = 'brand';
|
|
46
|
+
export const DEFAULT_STYLE = 'orb';
|
|
47
|
+
|
|
48
|
+
export function themeOf(id) {
|
|
49
|
+
return THEMES.find((t) => t.id === id) ?? THEMES[0];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function styleOf(id) {
|
|
53
|
+
return STYLES.find((s) => s.id === id) ?? STYLES[0];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The exact five colours the indicator's Apply-Palette understands. */
|
|
57
|
+
export function paletteOf(id) {
|
|
58
|
+
const t = themeOf(id);
|
|
59
|
+
return {
|
|
60
|
+
ringFrom: t.ringFrom,
|
|
61
|
+
ringTo: t.ringTo,
|
|
62
|
+
pillBg: t.pillBg,
|
|
63
|
+
pillBorder: t.pillBorder,
|
|
64
|
+
pillText: t.pillText,
|
|
65
|
+
};
|
|
66
|
+
}
|