@namzu/computer-use 4.1.0 → 4.2.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 +12 -0
- package/dist/SubprocessComputerUseHost.d.ts +18 -1
- package/dist/SubprocessComputerUseHost.d.ts.map +1 -1
- package/dist/SubprocessComputerUseHost.js +28 -2
- package/dist/SubprocessComputerUseHost.js.map +1 -1
- package/dist/a11y/a11y-script.d.ts +47 -0
- package/dist/a11y/a11y-script.d.ts.map +1 -0
- package/dist/a11y/a11y-script.js +738 -0
- package/dist/a11y/a11y-script.js.map +1 -0
- package/dist/a11y/a11y.d.ts +60 -0
- package/dist/a11y/a11y.d.ts.map +1 -0
- package/dist/a11y/a11y.js +400 -0
- package/dist/a11y/a11y.js.map +1 -0
- package/dist/a11y/index.d.ts +8 -0
- package/dist/a11y/index.d.ts.map +1 -0
- package/dist/a11y/index.js +5 -0
- package/dist/a11y/index.js.map +1 -0
- package/dist/a11y/interface.d.ts +198 -0
- package/dist/a11y/interface.d.ts.map +1 -0
- package/dist/a11y/interface.js +22 -0
- package/dist/a11y/interface.js.map +1 -0
- package/dist/a11y/windows.d.ts +20 -0
- package/dist/a11y/windows.d.ts.map +1 -0
- package/dist/a11y/windows.js +40 -0
- package/dist/a11y/windows.js.map +1 -0
- package/dist/adapters/cua-driver/adapter.d.ts +47 -0
- package/dist/adapters/cua-driver/adapter.d.ts.map +1 -1
- package/dist/adapters/cua-driver/adapter.js +138 -3
- package/dist/adapters/cua-driver/adapter.js.map +1 -1
- package/dist/adapters/types.d.ts +11 -0
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/adapters/win32.d.ts +3 -0
- package/dist/adapters/win32.d.ts.map +1 -1
- package/dist/adapters/win32.js +1 -0
- package/dist/adapters/win32.js.map +1 -1
- package/dist/foreground/guard.d.ts.map +1 -1
- package/dist/foreground/guard.js +1 -0
- package/dist/foreground/guard.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/presence/helper-script.d.ts +18 -11
- package/dist/presence/helper-script.d.ts.map +1 -1
- package/dist/presence/helper-script.js +301 -86
- package/dist/presence/helper-script.js.map +1 -1
- package/dist/presence/index.d.ts +3 -1
- package/dist/presence/index.d.ts.map +1 -1
- package/dist/presence/index.js +2 -1
- package/dist/presence/index.js.map +1 -1
- package/dist/presence/motion.d.ts +84 -0
- package/dist/presence/motion.d.ts.map +1 -0
- package/dist/presence/motion.js +114 -0
- package/dist/presence/motion.js.map +1 -0
- package/dist/presence/preview.d.ts +25 -0
- package/dist/presence/preview.d.ts.map +1 -0
- package/dist/presence/preview.js +32 -0
- package/dist/presence/preview.js.map +1 -0
- package/package.json +2 -2
- package/src/SubprocessComputerUseHost.ts +48 -1
- package/src/a11y/a11y-script.ts +740 -0
- package/src/a11y/a11y.ts +499 -0
- package/src/a11y/index.ts +24 -0
- package/src/a11y/interface.ts +226 -0
- package/src/a11y/windows.ts +56 -0
- package/src/adapters/cua-driver/adapter.ts +151 -6
- package/src/adapters/types.ts +8 -0
- package/src/adapters/win32.ts +4 -0
- package/src/foreground/guard.ts +1 -0
- package/src/index.ts +19 -0
- package/src/presence/helper-script.ts +327 -87
- package/src/presence/index.ts +10 -1
- package/src/presence/motion.ts +141 -0
- package/src/presence/preview.ts +42 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The numbers and the small maths of the presence overlay's motion. The helper
|
|
3
|
+
* script is C# inside a string and cannot be unit-tested from here, so the
|
|
4
|
+
* constants live here and are written into it, and the formulas are written
|
|
5
|
+
* once more in plain TypeScript as the reference the tests pin; the C# in
|
|
6
|
+
* `helper-script.ts` follows them line for line.
|
|
7
|
+
*
|
|
8
|
+
* Sizes are in logical pixels: the helper multiplies them by the operated
|
|
9
|
+
* window's display scale (its DPI divided by 96).
|
|
10
|
+
*/
|
|
11
|
+
/** The shortest glide, for a pointer that has hardly to move. */
|
|
12
|
+
export declare const GLIDE_MIN_MS = 140;
|
|
13
|
+
/** The longest glide, however far the pointer goes. */
|
|
14
|
+
export declare const GLIDE_MAX_MS = 420;
|
|
15
|
+
/** Added to the shortest glide per logical pixel travelled, up to the longest. */
|
|
16
|
+
export declare const GLIDE_MS_PER_PX = 0.45;
|
|
17
|
+
/** How far the path bows away from a straight line, as a fraction of its length. */
|
|
18
|
+
export declare const GLIDE_BOW = 0.1;
|
|
19
|
+
/** The first appearance in a window: fade in and grow from {@link APPEAR_FROM_SCALE}. */
|
|
20
|
+
export declare const APPEAR_MS = 160;
|
|
21
|
+
export declare const APPEAR_FROM_SCALE = 0.85;
|
|
22
|
+
/** How long the pointer and frame stay after the last action, then fade. */
|
|
23
|
+
export declare const HOLD_MS = 2000;
|
|
24
|
+
export declare const FADE_MS = 500;
|
|
25
|
+
/** A click: the pointer dips to {@link DIP_SCALE} and returns. */
|
|
26
|
+
export declare const DIP_SCALE = 0.88;
|
|
27
|
+
export declare const DIP_DOWN_MS = 70;
|
|
28
|
+
export declare const DIP_UP_MS = 110;
|
|
29
|
+
/** The ripple around the tip: a click's, then a key press's (smaller and softer). */
|
|
30
|
+
export declare const RIPPLE_MS = 420;
|
|
31
|
+
export declare const CLICK_RIPPLE: {
|
|
32
|
+
readonly from: 5;
|
|
33
|
+
readonly to: 26;
|
|
34
|
+
readonly alpha: 0.55;
|
|
35
|
+
readonly stroke: 2;
|
|
36
|
+
};
|
|
37
|
+
export declare const KEY_RIPPLE: {
|
|
38
|
+
readonly from: 4;
|
|
39
|
+
readonly to: 14;
|
|
40
|
+
readonly alpha: 0.35;
|
|
41
|
+
readonly stroke: 1.5;
|
|
42
|
+
};
|
|
43
|
+
/** The frame breathes by this fraction of its opacity over this period. */
|
|
44
|
+
export declare const FRAME_PULSE_MS = 2400;
|
|
45
|
+
export declare const FRAME_PULSE_DEPTH = 0.08;
|
|
46
|
+
export interface Point {
|
|
47
|
+
readonly x: number;
|
|
48
|
+
readonly y: number;
|
|
49
|
+
}
|
|
50
|
+
/** Slow, fast, slow: the glide's timing curve. `u` runs 0 to 1. */
|
|
51
|
+
export declare function easeInOut(u: number): number;
|
|
52
|
+
/** Fast, then settling: the ripple's and the appearance's curve. */
|
|
53
|
+
export declare function easeOut(u: number): number;
|
|
54
|
+
/** How long a glide over `logicalDistance` pixels takes, in whole milliseconds. */
|
|
55
|
+
export declare function glideDurationMs(logicalDistance: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* The control point of the glide's quadratic curve: the middle of the path,
|
|
58
|
+
* moved sideways by {@link GLIDE_BOW} of its length. The side depends on the
|
|
59
|
+
* line alone, never on which way it is travelled (up on the screen; to the
|
|
60
|
+
* right for a vertical line), so going to a point and back bows to the same
|
|
61
|
+
* side both times instead of zigzagging.
|
|
62
|
+
*/
|
|
63
|
+
export declare function glideControl(from: Point, to: Point): Point;
|
|
64
|
+
/** The point at `t` (0 to 1) on the quadratic curve from `from` through `control` to `to`. */
|
|
65
|
+
export declare function glidePoint(from: Point, control: Point, to: Point, t: number): Point;
|
|
66
|
+
/** The pointer's scale `ms` after a click lands: 1, dipping to {@link DIP_SCALE}, back to 1. */
|
|
67
|
+
export declare function dipScale(ms: number): number;
|
|
68
|
+
export interface RippleFrame {
|
|
69
|
+
/** Logical pixels from the tip. */
|
|
70
|
+
readonly radius: number;
|
|
71
|
+
/** 0 to 1. */
|
|
72
|
+
readonly alpha: number;
|
|
73
|
+
/** Logical pixels. */
|
|
74
|
+
readonly stroke: number;
|
|
75
|
+
}
|
|
76
|
+
/** The ripple `ms` after the action lands, or undefined before it and once it has faded. */
|
|
77
|
+
export declare function rippleFrame(kind: 'click' | 'type', ms: number): RippleFrame | undefined;
|
|
78
|
+
/** The frame's opacity factor at `ms`: it breathes between 1 and 1 minus twice the depth. */
|
|
79
|
+
export declare function framePulse(ms: number): number;
|
|
80
|
+
/** How opaque the overlay is `msSinceLastAction` after the last action: whole, then fading to nothing. */
|
|
81
|
+
export declare function idleAlpha(msSinceLastAction: number): number;
|
|
82
|
+
/** The display scale for a window: its DPI over the 96 of an unscaled display. */
|
|
83
|
+
export declare function displayScale(dpi: number): number;
|
|
84
|
+
//# sourceMappingURL=motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/presence/motion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iEAAiE;AACjE,eAAO,MAAM,YAAY,MAAM,CAAA;AAC/B,uDAAuD;AACvD,eAAO,MAAM,YAAY,MAAM,CAAA;AAC/B,kFAAkF;AAClF,eAAO,MAAM,eAAe,OAAO,CAAA;AACnC,oFAAoF;AACpF,eAAO,MAAM,SAAS,MAAM,CAAA;AAE5B,yFAAyF;AACzF,eAAO,MAAM,SAAS,MAAM,CAAA;AAC5B,eAAO,MAAM,iBAAiB,OAAO,CAAA;AAErC,4EAA4E;AAC5E,eAAO,MAAM,OAAO,OAAQ,CAAA;AAC5B,eAAO,MAAM,OAAO,MAAM,CAAA;AAE1B,kEAAkE;AAClE,eAAO,MAAM,SAAS,OAAO,CAAA;AAC7B,eAAO,MAAM,WAAW,KAAK,CAAA;AAC7B,eAAO,MAAM,SAAS,MAAM,CAAA;AAE5B,qFAAqF;AACrF,eAAO,MAAM,SAAS,MAAM,CAAA;AAC5B,eAAO,MAAM,YAAY;;;;;CAAuD,CAAA;AAChF,eAAO,MAAM,UAAU;;;;;CAAyD,CAAA;AAEhF,2EAA2E;AAC3E,eAAO,MAAM,cAAc,OAAQ,CAAA;AACnC,eAAO,MAAM,iBAAiB,OAAO,CAAA;AAErC,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CAClB;AAID,mEAAmE;AACnE,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED,oEAAoE;AACpE,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,KAAK,CAa1D;AAED,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,CAMnF;AAED,gGAAgG;AAChG,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAI3C;AAED,MAAM,WAAW,WAAW;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,cAAc;IACd,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,sBAAsB;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACvB;AAED,4FAA4F;AAC5F,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CASvF;AAED,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,0GAA0G;AAC1G,wBAAgB,SAAS,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The numbers and the small maths of the presence overlay's motion. The helper
|
|
3
|
+
* script is C# inside a string and cannot be unit-tested from here, so the
|
|
4
|
+
* constants live here and are written into it, and the formulas are written
|
|
5
|
+
* once more in plain TypeScript as the reference the tests pin; the C# in
|
|
6
|
+
* `helper-script.ts` follows them line for line.
|
|
7
|
+
*
|
|
8
|
+
* Sizes are in logical pixels: the helper multiplies them by the operated
|
|
9
|
+
* window's display scale (its DPI divided by 96).
|
|
10
|
+
*/
|
|
11
|
+
/** The shortest glide, for a pointer that has hardly to move. */
|
|
12
|
+
export const GLIDE_MIN_MS = 140;
|
|
13
|
+
/** The longest glide, however far the pointer goes. */
|
|
14
|
+
export const GLIDE_MAX_MS = 420;
|
|
15
|
+
/** Added to the shortest glide per logical pixel travelled, up to the longest. */
|
|
16
|
+
export const GLIDE_MS_PER_PX = 0.45;
|
|
17
|
+
/** How far the path bows away from a straight line, as a fraction of its length. */
|
|
18
|
+
export const GLIDE_BOW = 0.1;
|
|
19
|
+
/** The first appearance in a window: fade in and grow from {@link APPEAR_FROM_SCALE}. */
|
|
20
|
+
export const APPEAR_MS = 160;
|
|
21
|
+
export const APPEAR_FROM_SCALE = 0.85;
|
|
22
|
+
/** How long the pointer and frame stay after the last action, then fade. */
|
|
23
|
+
export const HOLD_MS = 2_000;
|
|
24
|
+
export const FADE_MS = 500;
|
|
25
|
+
/** A click: the pointer dips to {@link DIP_SCALE} and returns. */
|
|
26
|
+
export const DIP_SCALE = 0.88;
|
|
27
|
+
export const DIP_DOWN_MS = 70;
|
|
28
|
+
export const DIP_UP_MS = 110;
|
|
29
|
+
/** The ripple around the tip: a click's, then a key press's (smaller and softer). */
|
|
30
|
+
export const RIPPLE_MS = 420;
|
|
31
|
+
export const CLICK_RIPPLE = { from: 5, to: 26, alpha: 0.55, stroke: 2 };
|
|
32
|
+
export const KEY_RIPPLE = { from: 4, to: 14, alpha: 0.35, stroke: 1.5 };
|
|
33
|
+
/** The frame breathes by this fraction of its opacity over this period. */
|
|
34
|
+
export const FRAME_PULSE_MS = 2_400;
|
|
35
|
+
export const FRAME_PULSE_DEPTH = 0.08;
|
|
36
|
+
const clamp = (v, lo, hi) => (v < lo ? lo : v > hi ? hi : v);
|
|
37
|
+
/** Slow, fast, slow: the glide's timing curve. `u` runs 0 to 1. */
|
|
38
|
+
export function easeInOut(u) {
|
|
39
|
+
const t = clamp(u, 0, 1);
|
|
40
|
+
return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
|
|
41
|
+
}
|
|
42
|
+
/** Fast, then settling: the ripple's and the appearance's curve. */
|
|
43
|
+
export function easeOut(u) {
|
|
44
|
+
return 1 - (1 - clamp(u, 0, 1)) ** 3;
|
|
45
|
+
}
|
|
46
|
+
/** How long a glide over `logicalDistance` pixels takes, in whole milliseconds. */
|
|
47
|
+
export function glideDurationMs(logicalDistance) {
|
|
48
|
+
return Math.round(clamp(GLIDE_MIN_MS + logicalDistance * GLIDE_MS_PER_PX, GLIDE_MIN_MS, GLIDE_MAX_MS));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The control point of the glide's quadratic curve: the middle of the path,
|
|
52
|
+
* moved sideways by {@link GLIDE_BOW} of its length. The side depends on the
|
|
53
|
+
* line alone, never on which way it is travelled (up on the screen; to the
|
|
54
|
+
* right for a vertical line), so going to a point and back bows to the same
|
|
55
|
+
* side both times instead of zigzagging.
|
|
56
|
+
*/
|
|
57
|
+
export function glideControl(from, to) {
|
|
58
|
+
const dx = to.x - from.x;
|
|
59
|
+
const dy = to.y - from.y;
|
|
60
|
+
const len = Math.hypot(dx, dy);
|
|
61
|
+
const mid = { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 };
|
|
62
|
+
if (len < 1e-9)
|
|
63
|
+
return mid;
|
|
64
|
+
let nx = -dy / len;
|
|
65
|
+
let ny = dx / len;
|
|
66
|
+
if (ny > 1e-9 || (Math.abs(ny) <= 1e-9 && nx < 0)) {
|
|
67
|
+
nx = -nx;
|
|
68
|
+
ny = -ny;
|
|
69
|
+
}
|
|
70
|
+
return { x: mid.x + nx * len * GLIDE_BOW, y: mid.y + ny * len * GLIDE_BOW };
|
|
71
|
+
}
|
|
72
|
+
/** The point at `t` (0 to 1) on the quadratic curve from `from` through `control` to `to`. */
|
|
73
|
+
export function glidePoint(from, control, to, t) {
|
|
74
|
+
const b = 1 - t;
|
|
75
|
+
return {
|
|
76
|
+
x: b * b * from.x + 2 * b * t * control.x + t * t * to.x,
|
|
77
|
+
y: b * b * from.y + 2 * b * t * control.y + t * t * to.y,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** The pointer's scale `ms` after a click lands: 1, dipping to {@link DIP_SCALE}, back to 1. */
|
|
81
|
+
export function dipScale(ms) {
|
|
82
|
+
if (ms < 0 || ms >= DIP_DOWN_MS + DIP_UP_MS)
|
|
83
|
+
return 1;
|
|
84
|
+
if (ms < DIP_DOWN_MS)
|
|
85
|
+
return 1 - (1 - DIP_SCALE) * easeOut(ms / DIP_DOWN_MS);
|
|
86
|
+
return DIP_SCALE + (1 - DIP_SCALE) * easeOut((ms - DIP_DOWN_MS) / DIP_UP_MS);
|
|
87
|
+
}
|
|
88
|
+
/** The ripple `ms` after the action lands, or undefined before it and once it has faded. */
|
|
89
|
+
export function rippleFrame(kind, ms) {
|
|
90
|
+
if (ms < 0 || ms >= RIPPLE_MS)
|
|
91
|
+
return undefined;
|
|
92
|
+
const spec = kind === 'click' ? CLICK_RIPPLE : KEY_RIPPLE;
|
|
93
|
+
const p = ms / RIPPLE_MS;
|
|
94
|
+
return {
|
|
95
|
+
radius: spec.from + (spec.to - spec.from) * easeOut(p),
|
|
96
|
+
alpha: spec.alpha * (1 - p),
|
|
97
|
+
stroke: spec.stroke,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** The frame's opacity factor at `ms`: it breathes between 1 and 1 minus twice the depth. */
|
|
101
|
+
export function framePulse(ms) {
|
|
102
|
+
return 1 - FRAME_PULSE_DEPTH + FRAME_PULSE_DEPTH * Math.sin((2 * Math.PI * ms) / FRAME_PULSE_MS);
|
|
103
|
+
}
|
|
104
|
+
/** How opaque the overlay is `msSinceLastAction` after the last action: whole, then fading to nothing. */
|
|
105
|
+
export function idleAlpha(msSinceLastAction) {
|
|
106
|
+
if (msSinceLastAction <= HOLD_MS)
|
|
107
|
+
return 1;
|
|
108
|
+
return clamp(1 - (msSinceLastAction - HOLD_MS) / FADE_MS, 0, 1);
|
|
109
|
+
}
|
|
110
|
+
/** The display scale for a window: its DPI over the 96 of an unscaled display. */
|
|
111
|
+
export function displayScale(dpi) {
|
|
112
|
+
return dpi > 0 ? dpi / 96 : 1;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.js","sourceRoot":"","sources":["../../src/presence/motion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAC/B,uDAAuD;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAC/B,kFAAkF;AAClF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAA;AACnC,oFAAoF;AACpF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAE5B,yFAAyF;AACzF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAC5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAErC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAA;AAC5B,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAE1B,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAA;AAC7B,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAA;AAC7B,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAE5B,qFAAqF;AACrF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAC5B,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,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AAG,CAAC,CAAC;QAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;KACnB,CAAA;AACF,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CAAC,EAAU;IACpC,OAAO,CAAC,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,cAAc,CAAC,CAAA;AACjG,CAAC;AAED,0GAA0G;AAC1G,MAAM,UAAU,SAAS,CAAC,iBAAyB;IAClD,IAAI,iBAAiB,IAAI,OAAO;QAAE,OAAO,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAC,CAAC,GAAG,CAAC,iBAAiB,GAAG,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AAChE,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAAC,GAAW;IACvC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A development aid: the line that asks the presence helper to draw one state
|
|
3
|
+
* of the overlay into a PNG file instead of onto the screen. It shows the
|
|
4
|
+
* pointer (or, for `frame`, the border) on a mid-grey checker, a white and a
|
|
5
|
+
* near-black panel, so the shadow and the transparency can be judged, and it
|
|
6
|
+
* shows no window. The helper answers `{ ok: true, id, r: { path } }`.
|
|
7
|
+
*/
|
|
8
|
+
/** Display scales worth checking: 100 %, 150 % and 200 %. */
|
|
9
|
+
export declare const PREVIEW_DPIS: readonly [96, 144, 192];
|
|
10
|
+
export type PreviewDpi = (typeof PREVIEW_DPIS)[number];
|
|
11
|
+
/**
|
|
12
|
+
* What a preview draws: the pointer at rest, at the bottom of a click's dip,
|
|
13
|
+
* with a click ripple half grown, or the frame around a window.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PREVIEW_STATES: readonly ["rest", "press", "ripple", "frame"];
|
|
16
|
+
export type PreviewState = (typeof PREVIEW_STATES)[number];
|
|
17
|
+
export interface PreviewRequest {
|
|
18
|
+
readonly dpi: PreviewDpi;
|
|
19
|
+
readonly state: PreviewState;
|
|
20
|
+
/** Where the helper writes the PNG, as the helper's own operating system names it. */
|
|
21
|
+
readonly path: string;
|
|
22
|
+
}
|
|
23
|
+
/** The helper's `preview` command as one line of input. Throws on a value the helper would refuse. */
|
|
24
|
+
export declare function previewCommandLine(request: PreviewRequest): string;
|
|
25
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/presence/preview.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6DAA6D;AAC7D,eAAO,MAAM,YAAY,yBAA0B,CAAA;AACnD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,cAAc,+CAAgD,CAAA;AAC3E,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1D,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;IAC5B,sFAAsF;IACtF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACrB;AAED,sGAAsG;AACtG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAclE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A development aid: the line that asks the presence helper to draw one state
|
|
3
|
+
* of the overlay into a PNG file instead of onto the screen. It shows the
|
|
4
|
+
* pointer (or, for `frame`, the border) on a mid-grey checker, a white and a
|
|
5
|
+
* near-black panel, so the shadow and the transparency can be judged, and it
|
|
6
|
+
* shows no window. The helper answers `{ ok: true, id, r: { path } }`.
|
|
7
|
+
*/
|
|
8
|
+
/** Display scales worth checking: 100 %, 150 % and 200 %. */
|
|
9
|
+
export const PREVIEW_DPIS = [96, 144, 192];
|
|
10
|
+
/**
|
|
11
|
+
* What a preview draws: the pointer at rest, at the bottom of a click's dip,
|
|
12
|
+
* with a click ripple half grown, or the frame around a window.
|
|
13
|
+
*/
|
|
14
|
+
export const PREVIEW_STATES = ['rest', 'press', 'ripple', 'frame'];
|
|
15
|
+
/** The helper's `preview` command as one line of input. Throws on a value the helper would refuse. */
|
|
16
|
+
export function previewCommandLine(request) {
|
|
17
|
+
if (!PREVIEW_DPIS.includes(request.dpi)) {
|
|
18
|
+
throw new Error(`preview dpi must be one of ${PREVIEW_DPIS.join(', ')}`);
|
|
19
|
+
}
|
|
20
|
+
if (!PREVIEW_STATES.includes(request.state)) {
|
|
21
|
+
throw new Error(`preview state must be one of ${PREVIEW_STATES.join(', ')}`);
|
|
22
|
+
}
|
|
23
|
+
if (request.path.trim() === '')
|
|
24
|
+
throw new Error('preview needs a path');
|
|
25
|
+
return JSON.stringify({
|
|
26
|
+
cmd: 'preview',
|
|
27
|
+
dpi: request.dpi,
|
|
28
|
+
state: request.state,
|
|
29
|
+
path: request.path,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/presence/preview.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAU,CAAA;AAGnD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAA;AAU3E,sGAAsG;AACtG,MAAM,UAAU,kBAAkB,CAAC,OAAuB;IACzD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,8BAA8B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACzE,CAAC;IACD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,gCAAgC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC7E,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACvE,OAAO,IAAI,CAAC,SAAS,CAAC;QACrB,GAAG,EAAE,SAAS;QACd,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;KAClB,CAAC,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@namzu/computer-use",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Subprocess-based computer-use host for @namzu/sdk. Screenshot, mouse, and keyboard control via platform-native CLIs (screencapture/osascript on darwin, xdotool/maim on Linux X11, grim/wtype/ydotool on Wayland, PowerShell on Windows).",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"engines": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@types/node": "^22.19.17",
|
|
54
54
|
"typescript": "^5.5.0",
|
|
55
55
|
"vitest": "^4.1.11",
|
|
56
|
-
"@namzu/sdk": "^61.
|
|
56
|
+
"@namzu/sdk": "^61.3.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsc --build",
|
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
ComputerUseCapabilities,
|
|
4
4
|
ComputerUseHost,
|
|
5
5
|
ComputerUseResult,
|
|
6
|
+
ComputerUseSettleRequest,
|
|
7
|
+
ComputerUseSettleResult,
|
|
6
8
|
DisplayGeometry,
|
|
7
9
|
FocusWindowResult,
|
|
8
10
|
Rect,
|
|
@@ -16,6 +18,7 @@ import type {
|
|
|
16
18
|
WindowInputResult,
|
|
17
19
|
WindowScreenshotResult,
|
|
18
20
|
} from '@namzu/sdk'
|
|
21
|
+
import { type AccessibilityBackend, createWindowsA11yHost } from './a11y/index.js'
|
|
19
22
|
import { type Adapter, AdapterUnavailableError } from './adapters/types.js'
|
|
20
23
|
import type { Win32AdapterOptions } from './adapters/win32.js'
|
|
21
24
|
import { detectDisplayServer } from './detect/index.js'
|
|
@@ -78,6 +81,15 @@ export interface SubprocessComputerUseHostOptions {
|
|
|
78
81
|
* one built for this machine (for tests).
|
|
79
82
|
*/
|
|
80
83
|
readonly presence?: boolean | Presence
|
|
84
|
+
/**
|
|
85
|
+
* The resident accessibility host (Windows, with the driver backend): the
|
|
86
|
+
* window list and the wait for a window to settle after an input come from
|
|
87
|
+
* it, and the driver answers whenever it cannot. On by default; `false`
|
|
88
|
+
* turns it off, as does the environment variable
|
|
89
|
+
* `NAMZU_COMPUTER_USE_A11Y=off`. A ready backend replaces the one built
|
|
90
|
+
* for this machine (for tests).
|
|
91
|
+
*/
|
|
92
|
+
readonly a11y?: boolean | AccessibilityBackend
|
|
81
93
|
}
|
|
82
94
|
|
|
83
95
|
export interface SubprocessComputerUseHostForegroundOptions {
|
|
@@ -119,6 +131,7 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
|
|
|
119
131
|
private adapter: Adapter | null = null
|
|
120
132
|
private ladder: ForegroundLadder | undefined
|
|
121
133
|
private presence: Presence | undefined
|
|
134
|
+
private a11y: AccessibilityBackend | undefined
|
|
122
135
|
|
|
123
136
|
constructor(private readonly options: SubprocessComputerUseHostOptions = {}) {
|
|
124
137
|
const displayServer = detectDisplayServer(options.env, options.platform)
|
|
@@ -174,7 +187,24 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
|
|
|
174
187
|
...(option === false ? { enabled: false } : {}),
|
|
175
188
|
})
|
|
176
189
|
}
|
|
177
|
-
|
|
190
|
+
if (!this.a11y && displayServer === 'win32') {
|
|
191
|
+
const option = this.options.a11y
|
|
192
|
+
this.a11y =
|
|
193
|
+
typeof option === 'object'
|
|
194
|
+
? option
|
|
195
|
+
: createWindowsA11yHost({
|
|
196
|
+
...(this.options.env !== undefined ? { env: this.options.env } : {}),
|
|
197
|
+
...(this.options.platform !== undefined ? { platform: this.options.platform } : {}),
|
|
198
|
+
...(option === false ? { enabled: false } : {}),
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
const adapter = await loadAdapter(
|
|
202
|
+
displayServer,
|
|
203
|
+
this.options,
|
|
204
|
+
this.ladder,
|
|
205
|
+
this.presence,
|
|
206
|
+
this.a11y,
|
|
207
|
+
)
|
|
178
208
|
// Loading an adapter proves its tools exist on PATH, not that a desktop
|
|
179
209
|
// answers. A WSL process finds PowerShell and still may have no
|
|
180
210
|
// interactive Windows session to capture; an ssh session finds xdotool
|
|
@@ -322,6 +352,20 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
|
|
|
322
352
|
)
|
|
323
353
|
}
|
|
324
354
|
|
|
355
|
+
/**
|
|
356
|
+
* Waits for the window the last input went to to stop changing, in place
|
|
357
|
+
* of the tool's fixed pause. Undefined whenever the adapter cannot say
|
|
358
|
+
* (the driver backend without its accessibility host, any other platform).
|
|
359
|
+
*/
|
|
360
|
+
async settle(
|
|
361
|
+
request: ComputerUseSettleRequest,
|
|
362
|
+
signal?: AbortSignal,
|
|
363
|
+
): Promise<ComputerUseSettleResult | undefined> {
|
|
364
|
+
const adapter = this.adapter
|
|
365
|
+
if (!adapter?.settleAfterInput) return undefined
|
|
366
|
+
return adapter.settleAfterInput(request, signal)
|
|
367
|
+
}
|
|
368
|
+
|
|
325
369
|
/** Offered to the model only when `capabilities.regionCapture` is true. */
|
|
326
370
|
async captureRegion(rect: Rect, signal?: AbortSignal): Promise<ScreenshotResult> {
|
|
327
371
|
const adapter = this.requireAdapter()
|
|
@@ -402,6 +446,7 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
|
|
|
402
446
|
await adapter?.dispose?.()
|
|
403
447
|
await this.ladder?.dispose()
|
|
404
448
|
await this.presence?.dispose()
|
|
449
|
+
await this.a11y?.close()
|
|
405
450
|
}
|
|
406
451
|
|
|
407
452
|
/**
|
|
@@ -496,6 +541,7 @@ async function loadAdapter(
|
|
|
496
541
|
options: SubprocessComputerUseHostOptions,
|
|
497
542
|
ladder: ForegroundLadder | undefined,
|
|
498
543
|
presence: Presence | undefined,
|
|
544
|
+
a11y: AccessibilityBackend | undefined,
|
|
499
545
|
): Promise<Adapter> {
|
|
500
546
|
switch (displayServer) {
|
|
501
547
|
case 'darwin': {
|
|
@@ -518,6 +564,7 @@ async function loadAdapter(
|
|
|
518
564
|
...(options.platform !== undefined ? { platform: options.platform } : {}),
|
|
519
565
|
...(ladder ? { foreground: ladder } : {}),
|
|
520
566
|
...(presence ? { presence } : {}),
|
|
567
|
+
...(a11y ? { a11y } : {}),
|
|
521
568
|
})
|
|
522
569
|
}
|
|
523
570
|
case 'unknown':
|