@namzu/computer-use 4.0.2 → 4.1.1

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.
@@ -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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AgB,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,GA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AG,SAAS,CAAA;IACxB,OAAO;QACN,MAAM,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;QACtD,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,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.0.2",
3
+ "version": "4.1.1",
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.0.0"
56
+ "@namzu/sdk": "^61.2.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "tsc --build",
@@ -188,6 +188,11 @@ const IDENTITY_FRESH_MS = 3_000
188
188
  const MAX_REFS = 4_000
189
189
  /** The most refs one read creates; a quarter of the budget, so one read cannot evict the rest. */
190
190
  const NEW_REFS_PER_READ = 1_000
191
+ /** The driver's click count, sent only above 1 so a single click is the call it always was. */
192
+ function clickCount(action: { readonly count?: 1 | 2 | 3 }): { count?: number } {
193
+ return action.count !== undefined && action.count > 1 ? { count: action.count } : {}
194
+ }
195
+
191
196
  /** cua-driver refuses more than 50 ticks in one scroll call. */
192
197
  const MAX_SCROLL_TICKS = 50
193
198
  /** A drag glides through intermediate moves; many targets ignore one that teleports. */
@@ -453,9 +458,11 @@ export class CuaDriverAdapter implements Adapter {
453
458
  ]),
454
459
  mouseClickButtons: Object.freeze(['left' as const, 'right' as const, 'middle' as const]),
455
460
  mouseDragButtons: Object.freeze(['left' as const, 'right' as const, 'middle' as const]),
461
+ // The driver's click takes a count of 1 to 3.
462
+ maxClickCount: 3,
456
463
  windows: true,
457
464
  windowCapture: true,
458
- windowScroll: false,
465
+ windowScroll: true,
459
466
  // No display-relative region capture in cua-driver (its zoom is
460
467
  // per-window and pads the region); the tool crops a full capture.
461
468
  regionCapture: false,
@@ -504,6 +511,7 @@ export class CuaDriverAdapter implements Adapter {
504
511
  x: action.at.x,
505
512
  y: action.at.y,
506
513
  button: action.button,
514
+ ...clickCount(action),
507
515
  })
508
516
  case 'mouse_drag':
509
517
  return this.pointer('drag', {
@@ -1061,6 +1069,7 @@ export class CuaDriverAdapter implements Adapter {
1061
1069
  const send = async (
1062
1070
  name: string,
1063
1071
  args: Record<string, unknown>,
1072
+ onScreenArgs: Record<string, unknown> = {},
1064
1073
  ): Promise<WindowInputResult> => {
1065
1074
  const subject = {
1066
1075
  app: this.windowApps.get(frame.window.id) ?? frame.window.app,
@@ -1073,7 +1082,9 @@ export class CuaDriverAdapter implements Adapter {
1073
1082
  .run(this.burstRequest(subject, true), async (burst) => {
1074
1083
  await burst.checkpoint()
1075
1084
  try {
1076
- return inputDelivery(await dispatch(name, { ...args, delivery_mode: 'foreground' }))
1085
+ return inputDelivery(
1086
+ await dispatch(name, { ...args, ...onScreenArgs, delivery_mode: 'foreground' }),
1087
+ )
1077
1088
  } catch (error) {
1078
1089
  if (isDeliveredPointerAction(error)) return foregroundLostDelivery()
1079
1090
  if (error instanceof McpToolError) return failureDelivery(error)
@@ -1143,6 +1154,7 @@ export class CuaDriverAdapter implements Adapter {
1143
1154
  x: action.at.x,
1144
1155
  y: action.at.y,
1145
1156
  button: action.button,
1157
+ ...clickCount(action),
1146
1158
  })
1147
1159
  } catch (error) {
1148
1160
  if (isDeliveredPointerAction(error)) return foregroundLostDelivery()
@@ -1158,10 +1170,26 @@ export class CuaDriverAdapter implements Adapter {
1158
1170
  duration_ms: DRAG.durationMs,
1159
1171
  steps: DRAG.steps,
1160
1172
  })
1161
- case 'scroll':
1162
- throw new Error(
1163
- 'computer-use: window pixel scrolling is unavailable on this Windows driver; use foreground PAGE_DOWN or ARROW_DOWN in this window, or take a deliberate display screenshot before display scrolling.',
1164
- )
1173
+ case 'scroll': {
1174
+ // The driver posts the scroll to the window itself. It takes a point only in the
1175
+ // foreground (to pick a nested scrolling surface), so the point rides on that route alone.
1176
+ const onScreen = { x: action.at.x, y: action.at.y }
1177
+ let remaining = Math.max(1, Math.trunc(action.amount))
1178
+ let last: WindowInputResult | undefined
1179
+ while (remaining > 0) {
1180
+ const ticks = Math.min(remaining, MAX_SCROLL_TICKS)
1181
+ try {
1182
+ last = await send('scroll', { direction: action.direction, amount: ticks }, onScreen)
1183
+ } catch (error) {
1184
+ if (isDeliveredPointerAction(error)) return foregroundLostDelivery()
1185
+ throw error
1186
+ }
1187
+ // A part that was not delivered ends the scroll: the rest would land on a different view.
1188
+ if (last.delivery === 'not_delivered') return last
1189
+ remaining -= ticks
1190
+ }
1191
+ return last
1192
+ }
1165
1193
  case 'type_text': {
1166
1194
  if (action.text.length === 0) return undefined
1167
1195
  return await send('type_text', {