@namzu/computer-use 4.4.0 → 4.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/CHANGELOG.md +24 -0
- package/dist/SubprocessComputerUseHost.d.ts +8 -1
- package/dist/SubprocessComputerUseHost.d.ts.map +1 -1
- package/dist/SubprocessComputerUseHost.js +15 -4
- package/dist/SubprocessComputerUseHost.js.map +1 -1
- package/dist/a11y/a11y.d.ts +15 -7
- package/dist/a11y/a11y.d.ts.map +1 -1
- package/dist/a11y/a11y.js +12 -5
- package/dist/a11y/a11y.js.map +1 -1
- package/dist/a11y/index.d.ts +7 -1
- package/dist/a11y/index.d.ts.map +1 -1
- package/dist/a11y/index.js +4 -1
- package/dist/a11y/index.js.map +1 -1
- package/dist/a11y/macos-helper.d.ts +80 -0
- package/dist/a11y/macos-helper.d.ts.map +1 -0
- package/dist/a11y/macos-helper.js +436 -0
- package/dist/a11y/macos-helper.js.map +1 -0
- package/dist/a11y/macos-signing.d.ts +56 -0
- package/dist/a11y/macos-signing.d.ts.map +1 -0
- package/dist/a11y/macos-signing.js +228 -0
- package/dist/a11y/macos-signing.js.map +1 -0
- package/dist/a11y/macos.d.ts +173 -0
- package/dist/a11y/macos.d.ts.map +1 -0
- package/dist/a11y/macos.js +271 -0
- package/dist/a11y/macos.js.map +1 -0
- package/dist/a11y/windows.d.ts +14 -2
- package/dist/a11y/windows.d.ts.map +1 -1
- package/dist/a11y/windows.js +31 -6
- package/dist/a11y/windows.js.map +1 -1
- package/dist/adapters/cua-driver/adapter.d.ts.map +1 -1
- package/dist/adapters/cua-driver/adapter.js +48 -10
- package/dist/adapters/cua-driver/adapter.js.map +1 -1
- package/dist/adapters/cua-driver/ui-tree.d.ts +1 -0
- package/dist/adapters/cua-driver/ui-tree.d.ts.map +1 -1
- package/dist/adapters/cua-driver/ui-tree.js +2 -0
- package/dist/adapters/cua-driver/ui-tree.js.map +1 -1
- package/dist/adapters/darwin-ax.d.ts +94 -0
- package/dist/adapters/darwin-ax.d.ts.map +1 -0
- package/dist/adapters/darwin-ax.js +754 -0
- package/dist/adapters/darwin-ax.js.map +1 -0
- package/dist/adapters/darwin.d.ts +43 -2
- package/dist/adapters/darwin.d.ts.map +1 -1
- package/dist/adapters/darwin.js +145 -7
- package/dist/adapters/darwin.js.map +1 -1
- package/dist/adapters/png.d.ts +6 -0
- package/dist/adapters/png.d.ts.map +1 -0
- package/dist/adapters/png.js +7 -0
- package/dist/adapters/png.js.map +1 -0
- package/dist/adapters/win32-native.d.ts +53 -0
- package/dist/adapters/win32-native.d.ts.map +1 -0
- package/dist/adapters/win32-native.js +279 -0
- package/dist/adapters/win32-native.js.map +1 -0
- package/dist/adapters/win32.d.ts +19 -1
- package/dist/adapters/win32.d.ts.map +1 -1
- package/dist/adapters/win32.js +35 -8
- package/dist/adapters/win32.js.map +1 -1
- package/dist/foreground/ladder.d.ts.map +1 -1
- package/dist/foreground/ladder.js +5 -1
- package/dist/foreground/ladder.js.map +1 -1
- package/dist/foreground/types.d.ts +6 -0
- package/dist/foreground/types.d.ts.map +1 -1
- package/dist/foreground/types.js.map +1 -1
- package/dist/foreground/windows.d.ts +2 -0
- package/dist/foreground/windows.d.ts.map +1 -1
- package/dist/foreground/windows.js +24 -11
- package/dist/foreground/windows.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/native/a11y.d.ts +61 -0
- package/dist/native/a11y.d.ts.map +1 -0
- package/dist/native/a11y.js +197 -0
- package/dist/native/a11y.js.map +1 -0
- package/dist/native/env.d.ts +19 -0
- package/dist/native/env.d.ts.map +1 -0
- package/dist/native/env.js +29 -0
- package/dist/native/env.js.map +1 -0
- package/dist/native/foreground-monitor.d.ts +51 -0
- package/dist/native/foreground-monitor.d.ts.map +1 -0
- package/dist/native/foreground-monitor.js +120 -0
- package/dist/native/foreground-monitor.js.map +1 -0
- package/dist/native/presence.d.ts +24 -0
- package/dist/native/presence.d.ts.map +1 -0
- package/dist/native/presence.js +47 -0
- package/dist/native/presence.js.map +1 -0
- package/dist/native/process.d.ts +73 -0
- package/dist/native/process.d.ts.map +1 -0
- package/dist/native/process.js +302 -0
- package/dist/native/process.js.map +1 -0
- package/dist/native/protocol.d.ts +476 -0
- package/dist/native/protocol.d.ts.map +1 -0
- package/dist/native/protocol.js +601 -0
- package/dist/native/protocol.js.map +1 -0
- package/dist/native/shared.d.ts +16 -0
- package/dist/native/shared.d.ts.map +1 -0
- package/dist/native/shared.js +62 -0
- package/dist/native/shared.js.map +1 -0
- package/dist/native/watch.d.ts +35 -0
- package/dist/native/watch.d.ts.map +1 -0
- package/dist/native/watch.js +45 -0
- package/dist/native/watch.js.map +1 -0
- package/dist/presence/presence.d.ts +3 -2
- package/dist/presence/presence.d.ts.map +1 -1
- package/dist/presence/presence.js.map +1 -1
- package/dist/presence/windows.d.ts +2 -0
- package/dist/presence/windows.d.ts.map +1 -1
- package/dist/presence/windows.js +15 -0
- package/dist/presence/windows.js.map +1 -1
- package/helper-macos/main.swift +1756 -0
- package/package.json +3 -2
- package/src/SubprocessComputerUseHost.ts +26 -2
- package/src/a11y/a11y.ts +25 -11
- package/src/a11y/index.ts +28 -1
- package/src/a11y/macos-helper.ts +538 -0
- package/src/a11y/macos-signing.ts +280 -0
- package/src/a11y/macos.ts +496 -0
- package/src/a11y/windows.ts +31 -4
- package/src/adapters/cua-driver/adapter.ts +55 -15
- package/src/adapters/cua-driver/ui-tree.ts +2 -0
- package/src/adapters/darwin-ax.ts +920 -0
- package/src/adapters/darwin.ts +184 -4
- package/src/adapters/png.ts +5 -0
- package/src/adapters/win32-native.ts +329 -0
- package/src/adapters/win32.ts +53 -5
- package/src/foreground/ladder.ts +5 -1
- package/src/foreground/types.ts +6 -0
- package/src/foreground/windows.ts +25 -11
- package/src/index.ts +14 -0
- package/src/native/a11y.ts +267 -0
- package/src/native/env.ts +33 -0
- package/src/native/foreground-monitor.ts +165 -0
- package/src/native/presence.ts +58 -0
- package/src/native/process.ts +347 -0
- package/src/native/protocol.ts +1103 -0
- package/src/native/shared.ts +75 -0
- package/src/native/watch.ts +78 -0
- package/src/presence/presence.ts +3 -2
- package/src/presence/windows.ts +15 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { readFileSync, unlinkSync } from 'node:fs';
|
|
2
|
+
import { shareNativeProcess } from './shared.js';
|
|
3
|
+
const REQUEST_MS = 5_000;
|
|
4
|
+
/** `0x1a2b` and `w:000000000000_1a2b` name the same window. */
|
|
5
|
+
function windowIdOf(hwnd) {
|
|
6
|
+
const hex = hwnd.replace(/^0x/i, '').toLowerCase();
|
|
7
|
+
return `w:${hex.padStart(16, '0')}`;
|
|
8
|
+
}
|
|
9
|
+
function hwndOf(windowId) {
|
|
10
|
+
const m = /^w:([0-9a-f]+)/i.exec(windowId);
|
|
11
|
+
return `0x${(m?.[1] ?? '0').replace(/^0+(?=.)/, '').toUpperCase()}`;
|
|
12
|
+
}
|
|
13
|
+
export class NativeForegroundMonitor {
|
|
14
|
+
options;
|
|
15
|
+
process;
|
|
16
|
+
started = false;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.process = shareNativeProcess(options);
|
|
20
|
+
}
|
|
21
|
+
get running() {
|
|
22
|
+
return this.started && this.process.isUp;
|
|
23
|
+
}
|
|
24
|
+
async start() {
|
|
25
|
+
if (this.started && this.process.isUp)
|
|
26
|
+
return;
|
|
27
|
+
if (!(await this.process.ready()))
|
|
28
|
+
throw new Error('the native Windows helper did not start');
|
|
29
|
+
const caps = this.process.hello?.caps ?? [];
|
|
30
|
+
if (!caps.includes('monitor')) {
|
|
31
|
+
throw new Error('the native Windows helper in use cannot watch for a person at the keyboard');
|
|
32
|
+
}
|
|
33
|
+
const watching = await this.process.request({ op: 'monitor.start' }, REQUEST_MS);
|
|
34
|
+
if (!watching.input) {
|
|
35
|
+
throw new Error('the native Windows helper could not register for keyboard and mouse use');
|
|
36
|
+
}
|
|
37
|
+
this.started = true;
|
|
38
|
+
}
|
|
39
|
+
async state(query = {}) {
|
|
40
|
+
const [fg, poll] = await Promise.all([
|
|
41
|
+
this.process.request({ op: 'foreground.get', ...(query.pid !== undefined ? { processId: query.pid } : {}) }, REQUEST_MS),
|
|
42
|
+
this.process.request({ op: 'monitor.poll' }, REQUEST_MS),
|
|
43
|
+
]);
|
|
44
|
+
return stateOf(fg, poll);
|
|
45
|
+
}
|
|
46
|
+
async begin(args) {
|
|
47
|
+
const to = this.options.toHelperPath ?? ((p) => p);
|
|
48
|
+
const reply = await this.process.request({
|
|
49
|
+
op: 'lease.begin',
|
|
50
|
+
...(args.raise !== undefined
|
|
51
|
+
? { windowId: windowIdOf(args.raise), raise: true }
|
|
52
|
+
: args.watch !== undefined
|
|
53
|
+
? { windowId: windowIdOf(args.watch) }
|
|
54
|
+
: {}),
|
|
55
|
+
...(args.idleMs !== undefined ? { idleMs: args.idleMs } : {}),
|
|
56
|
+
leasePath: to(args.leasePath),
|
|
57
|
+
token: args.token,
|
|
58
|
+
}, REQUEST_MS);
|
|
59
|
+
const poll = await this.process.request({ op: 'monitor.poll' }, REQUEST_MS);
|
|
60
|
+
return {
|
|
61
|
+
...stateOf(reply, poll),
|
|
62
|
+
refused: reply.refused,
|
|
63
|
+
...(reply.raised !== undefined ? { raised: reply.raised } : {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async end(args) {
|
|
67
|
+
const reply = await this.process.request({
|
|
68
|
+
op: 'lease.end',
|
|
69
|
+
restore: args.restore,
|
|
70
|
+
...(args.keepCursor ? { keepCursor: true } : {}),
|
|
71
|
+
}, REQUEST_MS);
|
|
72
|
+
return {
|
|
73
|
+
inputsDuring: reply.inputsDuring ?? 0,
|
|
74
|
+
escapesDuring: 0,
|
|
75
|
+
restoredForeground: reply.restoredForeground,
|
|
76
|
+
restoredCursor: reply.restoredCursor,
|
|
77
|
+
...(reply.restoreNote !== undefined ? { restoreNote: reply.restoreNote } : {}),
|
|
78
|
+
inputMoved: reply.inputMoved,
|
|
79
|
+
frontElevated: reply.frontElevated,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Deletes the lease file when its token still matches. */
|
|
83
|
+
async release(args) {
|
|
84
|
+
try {
|
|
85
|
+
const record = JSON.parse(readFileSync(args.leasePath, 'utf8'));
|
|
86
|
+
if (record.token === args.token)
|
|
87
|
+
unlinkSync(args.leasePath);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// No file, or not ours: nothing to release.
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async dispose() {
|
|
94
|
+
this.started = false;
|
|
95
|
+
await this.process.close();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function stateOf(fg, poll) {
|
|
99
|
+
return {
|
|
100
|
+
userIdleMs: fg.userIdleMs,
|
|
101
|
+
userInputs: poll.inputs,
|
|
102
|
+
escapes: 0,
|
|
103
|
+
foreground: fg.foreground
|
|
104
|
+
? {
|
|
105
|
+
hwnd: hwndOf(fg.foreground.windowId),
|
|
106
|
+
pid: fg.foreground.processId,
|
|
107
|
+
exe: fg.foreground.exe,
|
|
108
|
+
elevated: fg.foreground.elevated,
|
|
109
|
+
integrity: fg.foreground.integrity,
|
|
110
|
+
}
|
|
111
|
+
: null,
|
|
112
|
+
cursor: fg.cursor,
|
|
113
|
+
desktop: fg.desktop,
|
|
114
|
+
selfElevated: fg.selfElevated,
|
|
115
|
+
selfIntegrity: fg.selfIntegrity,
|
|
116
|
+
inputTick: fg.inputTick,
|
|
117
|
+
...(fg.target ? { target: fg.target } : {}),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=foreground-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreground-monitor.js","sourceRoot":"","sources":["../../src/native/foreground-monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAA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Q,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ;gBAChC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS;aAClC;YACF,CAAC,CAAC,IAAI;QACP,MAAM,EAAE,EAAE,CAAC,MAAM;QACjB,OAAO,EAAE,EAAE,CAAC,OAAO;QACnB,YAAY,EAAE,EAAE,CAAC,YAAY;QAC7B,aAAa,EAAE,EAAE,CAAC,aAAa;QAC/B,SAAS,EAAE,EAAE,CAAC,SAAS;QACvB,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3C,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Presence, PresenceMark } from '../presence/presence.js';
|
|
2
|
+
import { type NativeWinProcessOptions } from './process.js';
|
|
3
|
+
/**
|
|
4
|
+
* The presence overlay drawn by the native helper: the agent's cursor and a
|
|
5
|
+
* frame round the operated window, in two layered, click-through windows the
|
|
6
|
+
* helper owns. It takes no input and never changes the foreground window.
|
|
7
|
+
*
|
|
8
|
+
* The overlay is not excluded from screen capture. A screenshot may show it,
|
|
9
|
+
* and that is honest: the picture shows where the agent pointed. (The
|
|
10
|
+
* PowerShell overlay this replaces hid itself from capture, which together
|
|
11
|
+
* with a topmost transparent window reads as evasion.)
|
|
12
|
+
*
|
|
13
|
+
* A failure to show it never fails an action.
|
|
14
|
+
*/
|
|
15
|
+
export declare class NativePresence implements Presence {
|
|
16
|
+
private readonly process;
|
|
17
|
+
constructor(options: NativeWinProcessOptions);
|
|
18
|
+
mark(mark: PresenceMark): void;
|
|
19
|
+
warm(): void;
|
|
20
|
+
hide(): void;
|
|
21
|
+
release(): void;
|
|
22
|
+
dispose(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/native/presence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAE7E;;;;;;;;;;;GAWG;AACH,qBAAa,cAAe,YAAW,QAAQ;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;gBAE9B,OAAO,EAAE,uBAAuB;IAI5C,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAc9B,IAAI,IAAI,IAAI;IAIZ,IAAI,IAAI,IAAI;IAMZ,OAAO,IAAI,IAAI;IAIT,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { NativeWinProcess } from './process.js';
|
|
2
|
+
/**
|
|
3
|
+
* The presence overlay drawn by the native helper: the agent's cursor and a
|
|
4
|
+
* frame round the operated window, in two layered, click-through windows the
|
|
5
|
+
* helper owns. It takes no input and never changes the foreground window.
|
|
6
|
+
*
|
|
7
|
+
* The overlay is not excluded from screen capture. A screenshot may show it,
|
|
8
|
+
* and that is honest: the picture shows where the agent pointed. (The
|
|
9
|
+
* PowerShell overlay this replaces hid itself from capture, which together
|
|
10
|
+
* with a topmost transparent window reads as evasion.)
|
|
11
|
+
*
|
|
12
|
+
* A failure to show it never fails an action.
|
|
13
|
+
*/
|
|
14
|
+
export class NativePresence {
|
|
15
|
+
process;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.process = new NativeWinProcess(options);
|
|
18
|
+
}
|
|
19
|
+
mark(mark) {
|
|
20
|
+
void this.process
|
|
21
|
+
.request({
|
|
22
|
+
op: 'presence.act',
|
|
23
|
+
windowId: windowIdOf(mark.hwnd),
|
|
24
|
+
kind: mark.kind,
|
|
25
|
+
...(mark.at ? { at: { x: Math.round(mark.at.x), y: Math.round(mark.at.y) } } : {}),
|
|
26
|
+
}, 4_000)
|
|
27
|
+
.catch(() => undefined);
|
|
28
|
+
}
|
|
29
|
+
warm() {
|
|
30
|
+
this.process.warm();
|
|
31
|
+
}
|
|
32
|
+
hide() {
|
|
33
|
+
// Only a helper that is running has anything to hide.
|
|
34
|
+
if (this.process.isUp)
|
|
35
|
+
void this.process.request({ op: 'presence.hide' }, 4_000).catch(() => undefined);
|
|
36
|
+
}
|
|
37
|
+
release() {
|
|
38
|
+
this.process.release();
|
|
39
|
+
}
|
|
40
|
+
async dispose() {
|
|
41
|
+
await this.process.close();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function windowIdOf(hwnd) {
|
|
45
|
+
return `w:${hwnd.toString(16).padStart(16, '0')}`;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=presence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/native/presence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAgC,MAAM,cAAc,CAAA;AAE7E;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,cAAc;IACT,OAAO,CAAkB;IAE1C,YAAY,OAAgC;QAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAC7C,CAAC;IAED,IAAI,CAAC,IAAkB;QACtB,KAAK,IAAI,CAAC,OAAO;aACf,OAAO,CACP;YACC,EAAE,EAAE,cAAc;YAClB,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClF,EACD,KAAK,CACL;aACA,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IACzB,CAAC;IAED,IAAI;QACH,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;IACpB,CAAC;IAED,IAAI;QACH,sDAAsD;QACtD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI;YACpB,KAAK,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IAClF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IAC3B,CAAC;CACD;AAED,SAAS,UAAU,CAAC,IAAY;IAC/B,OAAO,KAAK,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The helper as a process: start it, greet it, send it requests as lines and
|
|
3
|
+
* match the replies to them by id.
|
|
4
|
+
*
|
|
5
|
+
* The helper is the compiled `namzu-native` executable. It is started directly,
|
|
6
|
+
* with no shell and no script engine, and answers JSON lines on its standard
|
|
7
|
+
* output. Everything the TypeScript side asks of it goes through
|
|
8
|
+
* {@link NativeWinProcess.request}, which gives a reply body or throws an
|
|
9
|
+
* {@link A11yError} carrying the helper's own error code.
|
|
10
|
+
*/
|
|
11
|
+
import { type NativeHello, type NativeOp, type NativeReplyBodies, type NativeRequest } from './protocol.js';
|
|
12
|
+
/** The ends of a started helper; the real one is a child process. */
|
|
13
|
+
export interface NativeChannel {
|
|
14
|
+
write(line: string): void;
|
|
15
|
+
onLine(handler: (line: string) => void): void;
|
|
16
|
+
onExit(handler: () => void): void;
|
|
17
|
+
kill(): void;
|
|
18
|
+
}
|
|
19
|
+
export interface NativeWinProcessOptions {
|
|
20
|
+
/** The path of `namzu-native.exe`. */
|
|
21
|
+
readonly executable: string;
|
|
22
|
+
/** Sent in `hello`, so the helper's log can say who asked. */
|
|
23
|
+
readonly cliVersion?: string;
|
|
24
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
25
|
+
/** For tests. */
|
|
26
|
+
readonly spawnHelper?: () => NativeChannel;
|
|
27
|
+
/** Waiting for the greeting, ms. Default 10 000. */
|
|
28
|
+
readonly startTimeoutMs?: number;
|
|
29
|
+
/** How many times a helper that ended mid-session is started again. Default 3. */
|
|
30
|
+
readonly maxRestarts?: number;
|
|
31
|
+
/** A helper that ran this long before ending was healthy: the restart count starts again. Default 60 000. */
|
|
32
|
+
readonly stableAfterMs?: number;
|
|
33
|
+
}
|
|
34
|
+
export declare class NativeWinProcess {
|
|
35
|
+
private readonly options;
|
|
36
|
+
private channel;
|
|
37
|
+
private starting;
|
|
38
|
+
private up;
|
|
39
|
+
private dead;
|
|
40
|
+
private closed;
|
|
41
|
+
private restarts;
|
|
42
|
+
private runs;
|
|
43
|
+
private nextId;
|
|
44
|
+
private greeting;
|
|
45
|
+
private readonly pending;
|
|
46
|
+
constructor(options: NativeWinProcessOptions);
|
|
47
|
+
/** True once the helper greeted and has not ended since. */
|
|
48
|
+
get isUp(): boolean;
|
|
49
|
+
/** Counts the helper's starts: a marker taken before a restart is stale. */
|
|
50
|
+
get epoch(): number;
|
|
51
|
+
/** What the helper said in `hello`, once it has. */
|
|
52
|
+
get hello(): NativeHello | undefined;
|
|
53
|
+
warm(): void;
|
|
54
|
+
/** Ends the helper while nobody uses it; the next question starts it again. */
|
|
55
|
+
release(): void;
|
|
56
|
+
ready(): Promise<boolean>;
|
|
57
|
+
close(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* One request, one reply. `limitMs` is how long the helper has to answer
|
|
60
|
+
* (it is also what the request's own timeout says); a little more is
|
|
61
|
+
* allowed before the client gives up on a helper that says nothing.
|
|
62
|
+
*/
|
|
63
|
+
request<K extends NativeOp>(request: NativeRequest & {
|
|
64
|
+
readonly op: K;
|
|
65
|
+
}, limitMs: number, signal?: AbortSignal): Promise<NativeReplyBodies[K]>;
|
|
66
|
+
private sendQuit;
|
|
67
|
+
/** Tells the helper to stop work nobody waits for any more. Never throws. */
|
|
68
|
+
private cancelAtHelper;
|
|
69
|
+
private failAll;
|
|
70
|
+
private onReply;
|
|
71
|
+
private start;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/native/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAGN,KAAK,WAAW,EAChB,KAAK,QAAQ,EAEb,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAGlB,MAAM,eAAe,CAAA;AAEtB,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC7B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAA;IAC7C,MAAM,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;IACjC,IAAI,IAAI,IAAI,CAAA;CACZ;AAED,MAAM,WAAW,uBAAuB;IACvC,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IAChC,iBAAiB;IACjB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,aAAa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AAO,CAAC,cAAc;IAQtB,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,OAAO;IA+Bf,OAAO,CAAC,KAAK;CAsFb"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The helper as a process: start it, greet it, send it requests as lines and
|
|
3
|
+
* match the replies to them by id.
|
|
4
|
+
*
|
|
5
|
+
* The helper is the compiled `namzu-native` executable. It is started directly,
|
|
6
|
+
* with no shell and no script engine, and answers JSON lines on its standard
|
|
7
|
+
* output. Everything the TypeScript side asks of it goes through
|
|
8
|
+
* {@link NativeWinProcess.request}, which gives a reply body or throws an
|
|
9
|
+
* {@link A11yError} carrying the helper's own error code.
|
|
10
|
+
*/
|
|
11
|
+
import { spawn } from 'node:child_process';
|
|
12
|
+
import { createInterface } from 'node:readline';
|
|
13
|
+
import { A11yError } from '../a11y/interface.js';
|
|
14
|
+
import { LEGACY_NATIVE_PROTOCOL, NATIVE_PROTOCOL, NativeProtocolError, decodeReply, encodeRequest, } from './protocol.js';
|
|
15
|
+
/** The client gives up on a reply this long after the helper should have sent it, ms. */
|
|
16
|
+
const BACKSTOP_MS = 1_500;
|
|
17
|
+
function spawnHelperProcess(options) {
|
|
18
|
+
// The executable alone: no shell, no arguments, no window.
|
|
19
|
+
const child = spawn(options.executable, [], {
|
|
20
|
+
env: options.env,
|
|
21
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
22
|
+
windowsHide: true,
|
|
23
|
+
shell: false,
|
|
24
|
+
});
|
|
25
|
+
child.stdin.on('error', () => undefined);
|
|
26
|
+
child.on('error', () => undefined);
|
|
27
|
+
return {
|
|
28
|
+
write: (line) => {
|
|
29
|
+
child.stdin.write(`${line}\n`);
|
|
30
|
+
},
|
|
31
|
+
onLine: (handler) => createInterface({ input: child.stdout }).on('line', handler),
|
|
32
|
+
onExit: (handler) => {
|
|
33
|
+
child.once('exit', handler);
|
|
34
|
+
child.once('error', handler);
|
|
35
|
+
},
|
|
36
|
+
kill: () => {
|
|
37
|
+
try {
|
|
38
|
+
// Closing the input ends the helper by itself.
|
|
39
|
+
child.stdin.end();
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Already closed.
|
|
43
|
+
}
|
|
44
|
+
setTimeout(() => child.kill(), 2_000).unref();
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export class NativeWinProcess {
|
|
49
|
+
options;
|
|
50
|
+
channel;
|
|
51
|
+
starting;
|
|
52
|
+
up = false;
|
|
53
|
+
dead = false;
|
|
54
|
+
closed = false;
|
|
55
|
+
restarts = 0;
|
|
56
|
+
runs = 0;
|
|
57
|
+
nextId = 1;
|
|
58
|
+
greeting;
|
|
59
|
+
pending = new Map();
|
|
60
|
+
constructor(options) {
|
|
61
|
+
this.options = options;
|
|
62
|
+
}
|
|
63
|
+
/** True once the helper greeted and has not ended since. */
|
|
64
|
+
get isUp() {
|
|
65
|
+
return this.up && !this.dead && !this.closed;
|
|
66
|
+
}
|
|
67
|
+
/** Counts the helper's starts: a marker taken before a restart is stale. */
|
|
68
|
+
get epoch() {
|
|
69
|
+
return this.runs;
|
|
70
|
+
}
|
|
71
|
+
/** What the helper said in `hello`, once it has. */
|
|
72
|
+
get hello() {
|
|
73
|
+
return this.greeting;
|
|
74
|
+
}
|
|
75
|
+
warm() {
|
|
76
|
+
if (!this.dead && !this.closed)
|
|
77
|
+
void this.start();
|
|
78
|
+
}
|
|
79
|
+
/** Ends the helper while nobody uses it; the next question starts it again. */
|
|
80
|
+
release() {
|
|
81
|
+
const channel = this.channel;
|
|
82
|
+
if (!channel)
|
|
83
|
+
return;
|
|
84
|
+
// Replaced, not ended: its exit is not a crash (see the exit handler).
|
|
85
|
+
this.channel = undefined;
|
|
86
|
+
this.starting = undefined;
|
|
87
|
+
this.up = false;
|
|
88
|
+
this.failAll(new A11yError('helper_exited', 'the native helper was released'));
|
|
89
|
+
this.sendQuit(channel);
|
|
90
|
+
}
|
|
91
|
+
ready() {
|
|
92
|
+
if (this.dead || this.closed)
|
|
93
|
+
return Promise.resolve(false);
|
|
94
|
+
return this.start();
|
|
95
|
+
}
|
|
96
|
+
async close() {
|
|
97
|
+
this.closed = true;
|
|
98
|
+
const channel = this.channel;
|
|
99
|
+
this.channel = undefined;
|
|
100
|
+
this.up = false;
|
|
101
|
+
this.failAll(new A11yError('closed', 'the native helper was closed'));
|
|
102
|
+
if (channel)
|
|
103
|
+
this.sendQuit(channel);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* One request, one reply. `limitMs` is how long the helper has to answer
|
|
107
|
+
* (it is also what the request's own timeout says); a little more is
|
|
108
|
+
* allowed before the client gives up on a helper that says nothing.
|
|
109
|
+
*/
|
|
110
|
+
async request(request, limitMs, signal) {
|
|
111
|
+
if (signal?.aborted)
|
|
112
|
+
throw new A11yError('aborted', 'cancelled');
|
|
113
|
+
if (!(await this.ready()))
|
|
114
|
+
throw new A11yError('unavailable', 'the native helper is off');
|
|
115
|
+
const channel = this.channel;
|
|
116
|
+
if (!channel || !this.up)
|
|
117
|
+
throw new A11yError('helper_exited', 'the native helper ended');
|
|
118
|
+
const id = this.nextId++;
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
const settle = () => {
|
|
121
|
+
signal?.removeEventListener('abort', onAbort);
|
|
122
|
+
};
|
|
123
|
+
const onAbort = () => {
|
|
124
|
+
if (!this.pending.delete(id))
|
|
125
|
+
return;
|
|
126
|
+
clearTimeout(timer);
|
|
127
|
+
this.cancelAtHelper(id);
|
|
128
|
+
reject(new A11yError('aborted', 'cancelled'));
|
|
129
|
+
};
|
|
130
|
+
const timer = setTimeout(() => {
|
|
131
|
+
if (!this.pending.delete(id))
|
|
132
|
+
return;
|
|
133
|
+
settle();
|
|
134
|
+
this.cancelAtHelper(id);
|
|
135
|
+
reject(new A11yError('timeout', `the native helper did not answer ${request.op}`));
|
|
136
|
+
}, limitMs + BACKSTOP_MS);
|
|
137
|
+
timer.unref?.();
|
|
138
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
139
|
+
this.pending.set(id, {
|
|
140
|
+
op: request.op,
|
|
141
|
+
resolve: resolve,
|
|
142
|
+
reject,
|
|
143
|
+
timer,
|
|
144
|
+
cleanup: settle,
|
|
145
|
+
});
|
|
146
|
+
try {
|
|
147
|
+
channel.write(encodeRequest(id, request));
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
this.pending.delete(id);
|
|
151
|
+
clearTimeout(timer);
|
|
152
|
+
settle();
|
|
153
|
+
reject(new A11yError('helper_exited', 'the native helper ended'));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
sendQuit(channel) {
|
|
158
|
+
try {
|
|
159
|
+
channel.write(encodeRequest(this.nextId++, { op: 'quit' }));
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// Already gone.
|
|
163
|
+
}
|
|
164
|
+
channel.kill();
|
|
165
|
+
}
|
|
166
|
+
/** Tells the helper to stop work nobody waits for any more. Never throws. */
|
|
167
|
+
cancelAtHelper(target) {
|
|
168
|
+
try {
|
|
169
|
+
this.channel?.write(encodeRequest(this.nextId++, { op: 'cancel', target }));
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
// The helper is gone; there is nothing to cancel.
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
failAll(error) {
|
|
176
|
+
for (const [id, entry] of [...this.pending]) {
|
|
177
|
+
this.pending.delete(id);
|
|
178
|
+
clearTimeout(entry.timer);
|
|
179
|
+
entry.cleanup();
|
|
180
|
+
entry.reject(error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
onReply(line) {
|
|
184
|
+
let id;
|
|
185
|
+
try {
|
|
186
|
+
const parsed = JSON.parse(line);
|
|
187
|
+
if (typeof parsed.id !== 'number')
|
|
188
|
+
return;
|
|
189
|
+
id = parsed.id;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const entry = this.pending.get(id);
|
|
195
|
+
// An answer to a request nobody awaits (a cancel, a quit, one that timed out).
|
|
196
|
+
if (!entry)
|
|
197
|
+
return;
|
|
198
|
+
this.pending.delete(id);
|
|
199
|
+
clearTimeout(entry.timer);
|
|
200
|
+
entry.cleanup();
|
|
201
|
+
try {
|
|
202
|
+
const reply = decodeReply(entry.op, line);
|
|
203
|
+
if (reply.ok)
|
|
204
|
+
entry.resolve(reply.body);
|
|
205
|
+
else
|
|
206
|
+
entry.reject(new A11yError(reply.code, reply.message));
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
entry.reject(new A11yError('bad_reply', error instanceof NativeProtocolError
|
|
210
|
+
? error.message
|
|
211
|
+
: 'the native helper sent a bad line'));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
start() {
|
|
215
|
+
this.starting ??= new Promise((resolve) => {
|
|
216
|
+
let channel;
|
|
217
|
+
try {
|
|
218
|
+
channel = (this.options.spawnHelper ?? (() => spawnHelperProcess(this.options)))();
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
this.dead = true;
|
|
222
|
+
resolve(false);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
this.channel = channel;
|
|
226
|
+
this.runs += 1;
|
|
227
|
+
let greeted = false;
|
|
228
|
+
let greetedAt = 0;
|
|
229
|
+
let triedLegacy = false;
|
|
230
|
+
const hello = (protocol) => channel.write(encodeRequest(this.nextId++, {
|
|
231
|
+
op: 'hello',
|
|
232
|
+
protocol,
|
|
233
|
+
cliVersion: this.options.cliVersion ?? '0.0.0',
|
|
234
|
+
}));
|
|
235
|
+
const fail = () => {
|
|
236
|
+
this.dead = true;
|
|
237
|
+
this.up = false;
|
|
238
|
+
resolve(false);
|
|
239
|
+
channel.kill();
|
|
240
|
+
};
|
|
241
|
+
const timer = setTimeout(fail, this.options.startTimeoutMs ?? 10_000);
|
|
242
|
+
timer.unref?.();
|
|
243
|
+
channel.onExit(() => {
|
|
244
|
+
clearTimeout(timer);
|
|
245
|
+
// Closed, or already replaced: nothing left to do for this one.
|
|
246
|
+
if (this.channel !== channel) {
|
|
247
|
+
resolve(false);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
this.up = false;
|
|
251
|
+
this.failAll(new A11yError('helper_exited', 'the native helper ended'));
|
|
252
|
+
// A helper that was running and ended is started again by the next question,
|
|
253
|
+
// a few times; one that never came up stays off.
|
|
254
|
+
// A long, healthy run does not count against the few restarts a session gets.
|
|
255
|
+
if (greeted && Date.now() - greetedAt >= (this.options.stableAfterMs ?? 60_000))
|
|
256
|
+
this.restarts = 0;
|
|
257
|
+
if (greeted && !this.closed && this.restarts < (this.options.maxRestarts ?? 3)) {
|
|
258
|
+
this.restarts++;
|
|
259
|
+
this.channel = undefined;
|
|
260
|
+
this.starting = undefined;
|
|
261
|
+
}
|
|
262
|
+
else
|
|
263
|
+
this.dead = true;
|
|
264
|
+
resolve(false);
|
|
265
|
+
});
|
|
266
|
+
channel.onLine((line) => {
|
|
267
|
+
if (greeted) {
|
|
268
|
+
this.onReply(line);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
const reply = decodeReply('hello', line);
|
|
273
|
+
// A helper built before the rename knows only the old protocol name.
|
|
274
|
+
if (!reply.ok && reply.code === 'protocol_mismatch' && !triedLegacy) {
|
|
275
|
+
triedLegacy = true;
|
|
276
|
+
hello(LEGACY_NATIVE_PROTOCOL);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
greeted = true;
|
|
280
|
+
clearTimeout(timer);
|
|
281
|
+
if (!reply.ok) {
|
|
282
|
+
fail();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this.greeting = reply.body;
|
|
286
|
+
this.up = true;
|
|
287
|
+
greetedAt = Date.now();
|
|
288
|
+
resolve(true);
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
greeted = true;
|
|
292
|
+
clearTimeout(timer);
|
|
293
|
+
fail();
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
// The helper ids start at 1 and the greeting is the first of them.
|
|
297
|
+
hello(NATIVE_PROTOCOL);
|
|
298
|
+
});
|
|
299
|
+
return this.starting;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/native/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EACN,sBAAsB,EACtB,eAAe,EAGf,mBAAmB,EAGnB,WAAW,EACX,aAAa,GACb,MAAM,eAAe,CAAA;AA0BtB,yFAAyF;AACzF,MAAM,WAAW,GAAG,KAAK,CAAA;AAEzB,SAAS,kBAAkB,CAAC,OAAgC;IAC3D,2DAA2D;IAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,EAAE;QAC3C,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;QACjC,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,KAAK;KACZ,CAAC,CAAA;IACF,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IAClC,OAAO;QACN,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAA;Q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