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/locale/desktop/en.json
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Yuping · Desktop Control",
|
|
4
|
-
"description": "Lets the agent observe and operate the Windows desktop through the UI Automation element tree. The tree is the primary channel, not screenshots, so a text-only model can drive it; actions are delivered in the background without moving the cursor or stealing focus; a batch of actions runs in one call with per-step verification, and successful batches are saved as replayable recipes. Policy hard-refuses OS shutdown or sign-out, application exit, and destructive deletes."
|
|
5
|
-
}
|
|
6
|
-
}
|
package/locale/desktop/zh.json
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* The kill latch must refuse only the command that was in flight at the stop instant.
|
|
4
|
-
*
|
|
5
|
-
* Measured bug (2026-11-21): Esc armed the latch, the next mutating call consumed it and was
|
|
6
|
-
* refused, and the model — reading "本轮已被终止" — never retried. `killed` stayed true, the run
|
|
7
|
-
* could not light again, and the person saw an unresponsive overlay. A second Esc re-armed it,
|
|
8
|
-
* so every stop kept poisoning one more action.
|
|
9
|
-
*
|
|
10
|
-
* This exercises the real halt callback from src/index.js against a fake store: no desktop input,
|
|
11
|
-
* no worker spawn.
|
|
12
|
-
*/
|
|
13
|
-
import assert from 'node:assert/strict';
|
|
14
|
-
import { readFileSync } from 'node:fs';
|
|
15
|
-
import { dirname, join } from 'node:path';
|
|
16
|
-
import { fileURLToPath } from 'node:url';
|
|
17
|
-
|
|
18
|
-
const root = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
19
|
-
const source = readFileSync(join(root, 'src/index.js'), 'utf8');
|
|
20
|
-
|
|
21
|
-
// Pull the production halt callback and its window constant out of index.js so the test cannot
|
|
22
|
-
// drift from the shipped logic.
|
|
23
|
-
const latchMs = Number(source.match(/const HALT_LATCH_MS = (\d+);/)?.[1]);
|
|
24
|
-
const haltBody = source.match(/halt: \(\) => \{([\s\S]*?)\n \},/)?.[1];
|
|
25
|
-
|
|
26
|
-
let passed = 0;
|
|
27
|
-
function test(name, fn) {
|
|
28
|
-
try { fn(); passed++; console.log(`PASS ${name}`); }
|
|
29
|
-
catch (error) { console.log(`FAIL ${name}: ${error.message}`); process.exitCode = 1; }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
test('the latch window and the halt callback are present in the shipped source', () => {
|
|
33
|
-
assert.ok(Number.isFinite(latchMs) && latchMs > 0, 'HALT_LATCH_MS is missing or not a number');
|
|
34
|
-
assert.ok(typeof haltBody === 'string' && haltBody.length > 0, 'the halt callback was not found in index.js');
|
|
35
|
-
assert.match(haltBody, /killedAt/, 'the halt callback no longer considers when the latch was armed');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Build a store shaped like src/state.js and run the production halt body against it.
|
|
39
|
-
function makeHalt() {
|
|
40
|
-
const logged = [];
|
|
41
|
-
const store = { killed: false, killedAt: 0, setKilled(v) { this.killed = v; if (v) this.killedAt = Date.now(); } };
|
|
42
|
-
const logger = (m) => logged.push(m);
|
|
43
|
-
const halt = new Function('store', 'logger', 'HALT_LATCH_MS', `return () => {${haltBody}\n};`)(store, logger, latchMs);
|
|
44
|
-
return { store, halt, logged };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
test('a stopped command is refused inside the latch window', () => {
|
|
48
|
-
const { store, halt, logged } = makeHalt();
|
|
49
|
-
store.setKilled(true); // Esc fired
|
|
50
|
-
const message = halt(); // the in-flight command arrives immediately
|
|
51
|
-
assert.equal(typeof message, 'string', 'the command in flight at the stop was allowed through');
|
|
52
|
-
assert.match(message, /本轮已被终止/);
|
|
53
|
-
assert.equal(store.killed, false, 'the one-shot latch was not cleared after refusing');
|
|
54
|
-
assert.equal(logged.length, 1);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('the next instruction after the window is delivered, not refused', () => {
|
|
58
|
-
const { store, halt, logged } = makeHalt();
|
|
59
|
-
store.setKilled(true);
|
|
60
|
-
store.killedAt = Date.now() - (latchMs + 500); // the person asked for something new
|
|
61
|
-
const message = halt();
|
|
62
|
-
assert.equal(message, null, 'a fresh instruction was refused because of an old stop');
|
|
63
|
-
assert.equal(store.killed, false, 'the stale latch was left armed');
|
|
64
|
-
assert.equal(logged.length, 0, 'a stale latch logged a stop that did not apply to this action');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('an unarmed latch never blocks anything', () => {
|
|
68
|
-
const { halt, logged } = makeHalt();
|
|
69
|
-
assert.equal(halt(), null);
|
|
70
|
-
assert.equal(logged.length, 0);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test('a latch with no timestamp is treated as stale, not as fresh', () => {
|
|
74
|
-
// Defensive: a store restored from an older build has no killedAt. Reading it as age 0 would
|
|
75
|
-
// make the very first action after an upgrade look like the stopped command.
|
|
76
|
-
const { store, halt } = makeHalt();
|
|
77
|
-
store.killed = true;
|
|
78
|
-
store.killedAt = 0;
|
|
79
|
-
assert.equal(halt(), null, 'a timestamp-less latch blocked a new instruction');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('Esc clears the latch even when no command ever consumes it', () => {
|
|
83
|
-
// The overlay is dismissed by Esc, so nothing else would ever clear a latch nobody read: the
|
|
84
|
-
// panel kept showing 已终止. index.js schedules a clear after the window.
|
|
85
|
-
assert.match(source, /clearAt/, 'index.js does not schedule a latch clear after Esc');
|
|
86
|
-
assert.match(source, /HALT_LATCH_MS \+ 250/, 'the scheduled clear does not wait for the latch window to pass');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('Esc is sampled while the run is live, not only while the overlay is painted', () => {
|
|
90
|
-
// The overlay self-closes after DSH_NATIVE_UIA_IDLE_MS (20 s default) of tool silence, so a
|
|
91
|
-
// model thinking pause set activity.active=false. Gating the watchdog on that made Esc dead
|
|
92
|
-
// exactly when a person watches the agent work — the reported "运行中按 ESC 没反应".
|
|
93
|
-
const esc = source.match(/const escTimer = setInterval\(\(\) => \{([\s\S]*?)\n \}, (\d+)\)/)?.[1] ?? '';
|
|
94
|
-
assert.ok(esc !== '', 'the Esc watchdog block was not found');
|
|
95
|
-
assert.doesNotMatch(esc, /!activity\.active/, 'the watchdog still gates on the rendered overlay');
|
|
96
|
-
assert.match(esc, /store\.running !== true && store\.busy !== true/,
|
|
97
|
-
'the watchdog does not gate on the live run plus in-flight commands');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
console.log(`\n${passed}/7 halt-latch regressions passed (no desktop input)`);
|
package/src/native-uia-remote.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Plain JS has no decorator syntax, so the shipped decorator factory is invoked
|
|
5
|
-
* with a standard-decorators context the way TypeScript's __esDecorate does.
|
|
6
|
-
* This is the one step with no shipped precedent for a hand-written contribution.
|
|
7
|
-
*/
|
|
8
|
-
const PENDING = [];
|
|
9
|
-
let decorated = false;
|
|
10
|
-
function mark(Ctor, method, options) {
|
|
11
|
-
const queued = [];
|
|
12
|
-
Remote(options ?? method)(Ctor.prototype[method], {
|
|
13
|
-
kind: 'method',
|
|
14
|
-
name: method,
|
|
15
|
-
private: false,
|
|
16
|
-
static: false,
|
|
17
|
-
addInitializer: (fn) => queued.push(fn),
|
|
18
|
-
});
|
|
19
|
-
PENDING.push(queued);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function decorateMethods() {
|
|
23
|
-
if (decorated) return;
|
|
24
|
-
mark(NativeUiaRemote, 'state');
|
|
25
|
-
mark(NativeUiaRemote, 'action');
|
|
26
|
-
mark(NativeUiaRemote, 'subscribe', { mode: 'stream' });
|
|
27
|
-
decorated = true;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class NativeUiaRemote extends TypertRemoteService {
|
|
31
|
-
constructor(ctx, { store, commands, policy }) {
|
|
32
|
-
super(ctx, 'nativeUia');
|
|
33
|
-
decorateMethods();
|
|
34
|
-
this.store = store;
|
|
35
|
-
this.commands = commands;
|
|
36
|
-
this.policy = policy;
|
|
37
|
-
for (const queued of PENDING) {
|
|
38
|
-
for (const fn of queued) fn.call(this);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
state() {
|
|
43
|
-
return this.store.snapshot(this.policy);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async action(body) {
|
|
47
|
-
return this.commands.action(body);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async *subscribe(signal) {
|
|
51
|
-
this.store.line('御屏面板经宿主通道订阅(ctx.remote.nativeUia.subscribe)');
|
|
52
|
-
const queue = [];
|
|
53
|
-
let wake = null;
|
|
54
|
-
const bump = (kind) => (payload) => {
|
|
55
|
-
queue.push({ kind, payload });
|
|
56
|
-
if (wake !== null) { const run = wake; wake = null; run(); }
|
|
57
|
-
};
|
|
58
|
-
const handlers = [
|
|
59
|
-
['step', bump('step')],
|
|
60
|
-
['blocked', bump('blocked')],
|
|
61
|
-
['log', bump('log')],
|
|
62
|
-
['state', bump('state')],
|
|
63
|
-
['screenshot', bump('screenshot')],
|
|
64
|
-
];
|
|
65
|
-
for (const [event, handler] of handlers) this.store.on(event, handler);
|
|
66
|
-
try {
|
|
67
|
-
yield { kind: 'snapshot', payload: this.store.snapshot(this.policy) };
|
|
68
|
-
while (signal === undefined || signal.aborted !== true) {
|
|
69
|
-
while (queue.length > 0) {
|
|
70
|
-
const item = queue.shift();
|
|
71
|
-
if (item.kind === 'state' || item.kind === 'step') item.payload = this.store.snapshot(this.policy);
|
|
72
|
-
yield item;
|
|
73
|
-
}
|
|
74
|
-
await new Promise((resolve) => { wake = resolve; });
|
|
75
|
-
}
|
|
76
|
-
} finally {
|
|
77
|
-
for (const [event, handler] of handlers) this.store.off(event, handler);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
package/src/panel-face.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 御屏裸包名行的宿主半边(面板 face):什么都不注册。
|
|
3
|
-
*
|
|
4
|
-
* 一个包两行组件(与灵犀同构):
|
|
5
|
-
* · 裸名行(本入口)= 卡片 + 会话面板 —— client-modules 只从已挂载 loader 条目上发现
|
|
6
|
-
* `dsh.client`,且强制一包一个 client 源,所以面板必须挂这一行;它的存在就是页签开关。
|
|
7
|
-
* · /desktop 行(src/index.js)= 桌面操控工具,可单独关。
|
|
8
|
-
*/
|
|
9
|
-
export const name = 'dsh-native-uia';
|
|
10
|
-
export const inject = [];
|
|
11
|
-
|
|
12
|
-
export function apply() {
|
|
13
|
-
console.log('[dsh-native-uia] 面板行已挂载(页签由 client/client.js 注册,数据来自本机控制页服务)');
|
|
14
|
-
}
|