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/worker-client.js
CHANGED
|
@@ -34,13 +34,16 @@ export class ReadOnlyError extends Error {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/** Every command that can put input on the desktop, so the
|
|
38
|
-
* are enforced here rather than remembered per tool. The
|
|
39
|
-
* here too: they move the real cursor and type, so they must
|
|
40
|
-
* honour the kill latch exactly like act/commit_batch do. */
|
|
37
|
+
/** Every command that can put input on the desktop, so the session gates (read-only, the
|
|
38
|
+
* permission card, the kill latch) are enforced here rather than remembered per tool. The
|
|
39
|
+
* pixel/keyboard commands belong here too: they move the real cursor and type, so they must
|
|
40
|
+
* claim the activity overlay and honour the kill latch exactly like act/commit_batch do. */
|
|
41
41
|
const ACTION_COMMANDS = new Set([
|
|
42
42
|
'act', 'commit_batch', 'launch', 'close_window',
|
|
43
|
-
'pointer_click', 'pointer_drag', 'pointer_scroll', 'type_text', 'key',
|
|
43
|
+
'pointer_click', 'pointer_drag', 'pointer_scroll', 'pointer_mouse', 'type_text', 'key', 'window_action',
|
|
44
|
+
// Writing or clearing the clipboard is input on shared state: read-only mode must refuse it, and
|
|
45
|
+
// it deserves the same claim/kill discipline as typing. Reading is deliberately NOT here.
|
|
46
|
+
'clipboard_write', 'clipboard_clear',
|
|
44
47
|
// 'foreground' was removed with its worker command: no tool ever sent it, and an unsendable
|
|
45
48
|
// entry in the input whitelist is a policy blind spot (the worker command set dropped
|
|
46
49
|
// foreground/pointer_state/pointer_move/text_caret together).
|
|
@@ -66,6 +69,9 @@ const OBSERVE_COMMANDS = new Set([
|
|
|
66
69
|
// Resolves what currently sits under a point (used by the destructive-text guard before a
|
|
67
70
|
// click). It reads the desktop, it does not move the cursor, so it observes like a snapshot.
|
|
68
71
|
'pointer_target',
|
|
72
|
+
// A clipboard read is a read of shared state, not an action: it must keep working in read-only
|
|
73
|
+
// mode. The privacy gate (only after the model pressed ctrl+c itself) lives in the tool.
|
|
74
|
+
'clipboard_read',
|
|
69
75
|
]);
|
|
70
76
|
|
|
71
77
|
export class CuaWorker {
|
|
@@ -78,7 +84,7 @@ export class CuaWorker {
|
|
|
78
84
|
stderrTail = '';
|
|
79
85
|
stats = { started: 0, requests: 0, timeouts: 0, refused: 0, noise: 0, halted: 0, readOnlyRefused: 0 };
|
|
80
86
|
|
|
81
|
-
constructor({ script, onEvent, logger, halt, busy, onActionStart, onObserve, readOnly }) {
|
|
87
|
+
constructor({ script, onEvent, logger, halt, busy, onActionStart, onObserve, readOnly, disarmed }) {
|
|
82
88
|
this.scriptPath = script ?? WORKER;
|
|
83
89
|
this.onEvent = onEvent ?? (() => {});
|
|
84
90
|
this.log = logger ?? (() => {});
|
|
@@ -89,6 +95,10 @@ export class CuaWorker {
|
|
|
89
95
|
// Fixed for the session's lifetime: the flag is read once from the env at activation (Store)
|
|
90
96
|
// and wired in by index.js, so a plain boolean is enough — unlike halt it needs no callback.
|
|
91
97
|
this.readOnly = readOnly === true;
|
|
98
|
+
// The activation permission gate. A callback, not a boolean, because unlike read-only this
|
|
99
|
+
// decision can change during the session (the panel can re-ask); the choke point reads it at
|
|
100
|
+
// call time so a re-arm applies to the very next command.
|
|
101
|
+
this.disarmed = disarmed ?? (() => false);
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
get running() {
|
|
@@ -149,12 +159,18 @@ export class CuaWorker {
|
|
|
149
159
|
}
|
|
150
160
|
|
|
151
161
|
async call(cmd, args = {}, { timeoutMs = 30000 } = {}) {
|
|
152
|
-
if (!this.running) this.start();
|
|
153
|
-
const id = ++this.id;
|
|
154
|
-
const line = JSON.stringify({ id, cmd, args });
|
|
155
|
-
this.stats.requests++;
|
|
156
162
|
const isAction = ACTION_COMMANDS.has(cmd);
|
|
163
|
+
// Both session gates run BEFORE the lazy spawn: refusing an action must not pay a full
|
|
164
|
+
// powershell spawn just to throw the answer away. Observation is unaffected (it starts the
|
|
165
|
+
// worker as before).
|
|
157
166
|
if (isAction) {
|
|
167
|
+
// The activation permission gate sits at the same layer as read-only mode: the refusal must
|
|
168
|
+
// not consume the one-shot halt latch and must never reach busy()/onActionStart — an
|
|
169
|
+
// un-armed session claims nothing, so it never lights the overlay.
|
|
170
|
+
if (this.disarmed() === true) {
|
|
171
|
+
this.stats.readOnlyRefused++;
|
|
172
|
+
throw new ReadOnlyError('桌面控制未获准(启动时的权限请求未被允许),投递类动作一律拒绝;观察命令照常');
|
|
173
|
+
}
|
|
158
174
|
// Read-only observation mode sits one layer ABOVE the halt latch: the refusal must not
|
|
159
175
|
// consume the one-shot latch (that message belongs to the first action after a real stop)
|
|
160
176
|
// and must never reach busy()/onActionStart — a read-only session claims nothing, so it
|
|
@@ -163,6 +179,12 @@ export class CuaWorker {
|
|
|
163
179
|
this.stats.readOnlyRefused++;
|
|
164
180
|
throw new ReadOnlyError(`当前为只读观察模式,快照/find_text/parse/ocr 可用,投递类动作一律拒绝(${cmd})`);
|
|
165
181
|
}
|
|
182
|
+
}
|
|
183
|
+
if (!this.running) this.start();
|
|
184
|
+
const id = ++this.id;
|
|
185
|
+
const line = JSON.stringify({ id, cmd, args });
|
|
186
|
+
this.stats.requests++;
|
|
187
|
+
if (isAction) {
|
|
166
188
|
const message = typeof this.halt === 'function' ? this.halt() : null;
|
|
167
189
|
if (typeof message === 'string' && message !== '') {
|
|
168
190
|
this.stats.halted++;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
M168.384 12.9517C168.138 12.8317 168.033 13.0607 167.889 13.1767C167.84 13.2142 167.799 13.2632 167.757 13.3082C167.399 13.6912 166.98 13.9427 166.433 13.9127C165.632 13.8677 164.949 14.1192 164.345 14.7312C164.217 13.9767 163.79 13.5262 163.141 13.2372C162.802 13.0872 162.458 12.9367 162.22 12.6102C162.054 12.3776 162.009 12.1186 161.926 11.8631C161.873 11.7091 161.82 11.5516 161.643 11.5251C161.45 11.4951 161.375 11.6566 161.299 11.7916C160.997 12.3436 160.88 12.9517 160.892 13.5677C160.918 14.9532 161.503 16.0568 162.666 16.8418C162.798 16.9318 162.832 17.0218 162.79 17.1533C162.711 17.4238 162.617 17.6863 162.534 17.9568C162.481 18.1293 162.402 18.1673 162.217 18.0918C161.579 17.8253 161.028 17.4308 160.541 16.9543C159.714 16.1548 158.967 15.2722 158.035 14.5812C157.816 14.4197 157.597 14.2697 157.37 14.1267C156.419 13.2032 157.495 12.4446 157.744 12.3546C158.004 12.2606 157.834 11.9376 156.993 11.9416C156.151 11.9451 155.381 12.2271 154.4 12.6027C154.256 12.6592 154.105 12.7002 153.951 12.7342C153.06 12.5652 152.135 12.5277 151.169 12.6367C149.35 12.8392 147.897 13.6992 146.829 15.1672C145.546 16.9318 145.244 18.9368 145.613 21.0279C146.002 23.232 147.127 25.0565 148.855 26.4831C150.648 27.9621 152.713 28.6871 155.068 28.5481C156.499 28.4656 158.091 28.2741 159.888 26.7536C160.341 26.9791 160.816 27.0691 161.605 27.1366C162.212 27.1931 162.797 27.1066 163.25 27.0126C163.96 26.8626 163.911 26.2056 163.654 26.0851C161.575 25.1165 162.031 25.5105 161.616 25.1915C162.673 23.9415 164.287 21.7194 164.785 18.6938C164.834 18.3598 164.896 17.8893 164.889 17.6188C164.885 17.4538 164.923 17.3898 165.111 17.3708C165.632 17.3108 166.138 17.1683 166.603 16.9128C167.95 16.1768 168.494 14.9677 168.622 13.5187C168.641 13.2972 168.618 13.0682 168.384 12.9517ZM156.642 25.9951C154.626 24.4105 153.649 23.889 153.245 23.9115C152.868 23.934 152.936 24.366 153.019 24.6475C153.106 24.9255 153.219 25.117 153.377 25.361C153.487 25.5225 153.562 25.7625 153.268 25.9431C152.619 26.3446 151.49 25.808 151.437 25.7815C150.124 25.008 149.025 23.987 148.251 22.5905C147.504 21.2464 147.07 19.8044 146.998 18.2653C146.979 17.8938 147.089 17.7623 147.459 17.6948C147.946 17.6048 148.448 17.5858 148.934 17.6573C150.992 17.9578 152.743 18.8773 154.211 20.3344C155.049 21.1639 155.683 22.1554 156.336 23.124C157.03 24.1525 157.777 25.1325 158.729 25.9361C159.065 26.2176 159.333 26.4316 159.589 26.5896C158.816 26.6761 157.525 26.6946 156.642 25.9961V25.9951ZM157.608 19.7814C157.608 19.6164 157.74 19.4849 157.906 19.4849C157.943 19.4849 157.977 19.4924 158.008 19.5034C158.049 19.5184 158.087 19.5409 158.117 19.5749C158.17 19.6274 158.2 19.7024 158.2 19.7814C158.2 19.9464 158.068 20.0779 157.902 20.0779C157.736 20.0779 157.608 19.9464 157.608 19.7814ZM160.608 21.3204C160.416 21.3994 160.223 21.4669 160.038 21.4744C159.751 21.4894 159.438 21.3729 159.268 21.2304C159.004 21.0089 158.815 20.8849 158.736 20.4984C158.702 20.3334 158.721 20.0779 158.751 19.9314C158.819 19.6159 158.744 19.4134 158.521 19.2294C158.34 19.0793 158.11 19.0378 157.857 19.0378C157.762 19.0378 157.676 18.9963 157.611 18.9628C157.506 18.9103 157.419 18.7788 157.502 18.6173C157.528 18.5648 157.657 18.4373 157.687 18.4148C158.03 18.2193 158.426 18.2833 158.793 18.4298C159.132 18.5688 159.389 18.8238 159.759 19.1844C160.136 19.6199 160.204 19.7399 160.419 20.0669C160.589 20.3224 160.744 20.5849 160.85 20.8854C160.914 21.0729 160.831 21.2264 160.608 21.3204Z
|