clearcote 0.51.1 → 0.52.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/dist/attention.d.ts +26 -0
- package/dist/attention.d.ts.map +1 -0
- package/dist/attention.js +82 -0
- package/dist/attention.js.map +1 -0
- package/dist/cloud.d.ts +10 -3
- package/dist/cloud.d.ts.map +1 -1
- package/dist/cloud.js +9 -1
- package/dist/cloud.js.map +1 -1
- package/dist/forms.d.ts +8 -0
- package/dist/forms.d.ts.map +1 -1
- package/dist/forms.js +56 -0
- package/dist/forms.js.map +1 -1
- package/dist/frames.d.ts +33 -0
- package/dist/frames.d.ts.map +1 -0
- package/dist/frames.js +415 -0
- package/dist/frames.js.map +1 -0
- package/dist/hold.d.ts +14 -7
- package/dist/hold.d.ts.map +1 -1
- package/dist/hold.js +33 -6
- package/dist/hold.js.map +1 -1
- package/dist/humanize.d.ts +49 -20
- package/dist/humanize.d.ts.map +1 -1
- package/dist/humanize.js +2024 -261
- package/dist/humanize.js.map +1 -1
- package/dist/hzoptions.d.ts +78 -0
- package/dist/hzoptions.d.ts.map +1 -0
- package/dist/hzoptions.js +171 -0
- package/dist/hzoptions.js.map +1 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/isolated.d.ts +6 -0
- package/dist/isolated.d.ts.map +1 -1
- package/dist/isolated.js +57 -1
- package/dist/isolated.js.map +1 -1
- package/dist/keys.d.ts +69 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +201 -0
- package/dist/keys.js.map +1 -0
- package/dist/motion.d.ts +130 -12
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +258 -19
- package/dist/motion.js.map +1 -1
- package/dist/motionscore.d.ts +81 -0
- package/dist/motionscore.d.ts.map +1 -1
- package/dist/motionscore.js +279 -2
- package/dist/motionscore.js.map +1 -1
- package/dist/pacing.d.ts +5 -0
- package/dist/pacing.d.ts.map +1 -1
- package/dist/pacing.js +10 -0
- package/dist/pacing.js.map +1 -1
- package/dist/scroll.d.ts +143 -0
- package/dist/scroll.d.ts.map +1 -0
- package/dist/scroll.js +426 -0
- package/dist/scroll.js.map +1 -0
- package/dist/trace.d.ts +12 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +60 -0
- package/dist/trace.js.map +1 -0
- package/package.json +1 -1
package/dist/motion.d.ts
CHANGED
|
@@ -32,27 +32,62 @@ export interface Persona {
|
|
|
32
32
|
maxCorrections: number;
|
|
33
33
|
/** Handedness/approach curvature bias (signed, radians-ish) applied to path bow. */
|
|
34
34
|
approachBias: number;
|
|
35
|
-
/**
|
|
35
|
+
/** The HUMAN BANDS every timing draw is clamped to (ms); the per-identity medians inside them come from
|
|
36
|
+
* the salted timing stream ({@link timingTraits}). Grab hesitation after mouse.down: */
|
|
36
37
|
grabMinMs: number;
|
|
37
38
|
grabMaxMs: number;
|
|
38
|
-
/** Pre-release settle
|
|
39
|
+
/** Pre-release settle before mouse.up (ms). */
|
|
39
40
|
releaseMinMs: number;
|
|
40
41
|
releaseMaxMs: number;
|
|
41
|
-
/** Click press-hold
|
|
42
|
+
/** Click press-hold band — mousedown→mouseup (ms), 55–230; a scripted click is ~2 ms. */
|
|
42
43
|
clickHoldMinMs: number;
|
|
43
44
|
clickHoldMaxMs: number;
|
|
44
|
-
/** Per-key dwell
|
|
45
|
+
/** Per-key dwell band — keydown→keyup (ms), 45–120; scripted typing ~2–3 ms. */
|
|
45
46
|
keyDwellMinMs: number;
|
|
46
47
|
keyDwellMaxMs: number;
|
|
47
48
|
}
|
|
48
49
|
/** Derive a stable motor persona from a fingerprint seed (or random when unseeded). */
|
|
49
50
|
export declare function makePersona(seed?: string | number): Persona;
|
|
50
|
-
/**
|
|
51
|
-
|
|
51
|
+
/** Per-identity timing medians (ms) and tempo, stable per seed (see timingTraits). */
|
|
52
|
+
export interface TimingTraits {
|
|
53
|
+
/** Median mousedown→mouseup hold, 70–140. */
|
|
54
|
+
clickHoldMs: number;
|
|
55
|
+
/** Median keydown→keyup dwell, 60–95. */
|
|
56
|
+
keyDwellMs: number;
|
|
57
|
+
/** Median grab hesitation after a drag's mousedown, 180–280. */
|
|
58
|
+
grabMs: number;
|
|
59
|
+
/** Median settle before a drag's mouseup, 120–180. */
|
|
60
|
+
releaseMs: number;
|
|
61
|
+
/** Median gap between the two presses of a double click, 90–140. */
|
|
62
|
+
dblclickGapMs: number;
|
|
63
|
+
/** Scale on deliberation pauses (select popup, datetime segments), 0.8–1.25. */
|
|
64
|
+
pauseScale: number;
|
|
65
|
+
/** Per-character fat-finger rate, 0.005–0.04. */
|
|
66
|
+
typoRate: number;
|
|
67
|
+
}
|
|
68
|
+
/** The persona's timing traits, drawn from a salted stream of its seed. Before this every identity shared
|
|
69
|
+
* ONE fixed window per timing (click hold 60–150, key dwell 45–120, grab 130–360, release 90–230,
|
|
70
|
+
* double-click gap 70–170, select-popup pauses, datetime gaps, the 2 % typo rate). Each value is the
|
|
71
|
+
* identity's MEDIAN; samples around it are log-normal and clamped to the persona's human band. Same values
|
|
72
|
+
* as Python `_motion.timing_traits` and .NET `Motion.TimingTraitsOf`. */
|
|
73
|
+
export declare function timingTraits(p: Persona): TimingTraits;
|
|
74
|
+
/** `median * exp(sigma * N(0,1))` clamped to [lo, hi]: a right-skewed human timing around a per-identity median. */
|
|
75
|
+
export declare function lognormalMs(median: number, sigma: number, lo: number, hi: number, rng: Rng): number;
|
|
76
|
+
/** The preset's tempo on `p` (HumanizeOptions: careful 1.4 / default 1 / quick 0.7, set by applyToPersona after
|
|
77
|
+
* makePersona; 1 on a bare persona, so every vector is unchanged). */
|
|
78
|
+
export declare function tempoOf(p: Persona | null | undefined): number;
|
|
79
|
+
/** A human mousedown→mouseup click hold (ms): log-normal (σ 0.25) around the persona's own median
|
|
80
|
+
* (70–140 ms), clamped to its band (55–230 ms). */
|
|
52
81
|
export declare function clickHold(p: Persona, rng?: Rng): number;
|
|
53
|
-
/** A human per-key keydown→keyup dwell (ms)
|
|
54
|
-
*
|
|
82
|
+
/** A human per-key keydown→keyup dwell (ms): log-normal (σ 0.22) around the persona's own median
|
|
83
|
+
* (60–95 ms), clamped to its band (45–120 ms). */
|
|
55
84
|
export declare function keyDwell(p: Persona, rng?: Rng): number;
|
|
85
|
+
/** The gap between the two presses of a double click (ms): log-normal (σ 0.15) around the persona's
|
|
86
|
+
* median (90–140), clamped to 70–170. */
|
|
87
|
+
export declare function dblclickGap(p: Persona, rng?: Rng): number;
|
|
88
|
+
/** A deliberation pause (ms) from [lo, hi], scaled by the persona's tempo (pauseScale 0.8–1.25).
|
|
89
|
+
* Without a persona: the plain window. */
|
|
90
|
+
export declare function pauseMs(p: Persona | null | undefined, lo: number, hi: number, rng?: Rng): number;
|
|
56
91
|
/** Share of eligible key pairs this persona types with ROLLOVER: the next key goes down before the
|
|
57
92
|
* previous one comes up, the way people type fast common pairs. Stable per seed, 0.12–0.38.
|
|
58
93
|
*
|
|
@@ -143,7 +178,31 @@ export declare function planDrag(from: Point, to: Point, p: Persona, opts?: {
|
|
|
143
178
|
settle?: boolean;
|
|
144
179
|
rng?: Rng;
|
|
145
180
|
}): Step[];
|
|
146
|
-
/**
|
|
181
|
+
/** The drag-start hesitation window (ms): a hand that has just closed on a handle holds 100-300 ms. */
|
|
182
|
+
export declare const HESITATION_MS: readonly [number, number];
|
|
183
|
+
/** ... creeping a few px, never this far, before the leg proper. */
|
|
184
|
+
export declare const HESITATION_MAX_PX = 8;
|
|
185
|
+
/** The still-but-not-frozen moment between the grab and the drag leg from->to: samples spanning
|
|
186
|
+
* 100-300 ms (centred per persona; `durMs`, 40-300, overrides the length but the persona's draw is still
|
|
187
|
+
* made), creeping < 8 px toward `to` with a little sideways wobble. Same numbers as Python
|
|
188
|
+
* `_motion.drag_hesitation` and .NET `Motion.DragHesitation` (sdk/testdata/humanize_scroll_vectors.json).
|
|
189
|
+
* Measured on r38 / SDK 0.51.0 (SC 232): every drag's first held move was already the full-speed leg. */
|
|
190
|
+
export declare function dragHesitation(from: Point, to: Point, p: Persona, rng?: Rng, durMs?: number | null): Step[];
|
|
191
|
+
/** When (ms from the start of `steps`) the walk first leaves the `radius` circle around `from`. */
|
|
192
|
+
export declare function legExitMs(from: Point, steps: Step[], radius?: number): number;
|
|
193
|
+
/** The held part of a drag: the hesitation creep, then the planDrag leg, planned together so the pointer
|
|
194
|
+
* stays inside 8 px of the press for `windowMs` (clamped 100-300: the persona's grab dwell) and then goes.
|
|
195
|
+
* Same as Python `hesitate_then_drag`. */
|
|
196
|
+
export declare function hesitateThenDrag(from: Point, to: Point, p: Persona, windowMs: number, settle?: boolean, rng?: Rng): {
|
|
197
|
+
steps: Step[];
|
|
198
|
+
creep: number;
|
|
199
|
+
};
|
|
200
|
+
/** Where a reading hand parks the pointer before a wheel: x ~ 0.5w ± 0.10w clamped [0.12w, 0.88w], y ~ 0.34h
|
|
201
|
+
* ± 0.09h clamped [0.10h, 0.62h] (two gaussians, x first). One model in all three SDKs (Python
|
|
202
|
+
* `wheel_anchor_point`, .NET `Motion.WheelAnchorPoint`); before 0.52 Node used 0.48/0.36 and other clamps. */
|
|
203
|
+
export declare function wheelAnchorPoint(vw: number, vh: number, rng?: Rng): [number, number];
|
|
204
|
+
/** Grab/release dwell times (ms) for a held-button drag: log-normal (σ 0.2) around the persona's medians,
|
|
205
|
+
* inside its grab/release bands. */
|
|
147
206
|
export declare function dragDwell(p: Persona, rng?: Rng): {
|
|
148
207
|
grabMs: number;
|
|
149
208
|
releaseMs: number;
|
|
@@ -154,9 +213,27 @@ export interface Box {
|
|
|
154
213
|
width: number;
|
|
155
214
|
height: number;
|
|
156
215
|
}
|
|
157
|
-
/**
|
|
158
|
-
|
|
159
|
-
|
|
216
|
+
/** Per-identity aiming traits, stable per seed (see aimTraits). */
|
|
217
|
+
export interface AimTraits {
|
|
218
|
+
/** Landing dispersion, sd as a share of the box, 0.10–0.20. */
|
|
219
|
+
spread: number;
|
|
220
|
+
/** Pull toward the side the cursor came from, share of the box, 0.06–0.16. */
|
|
221
|
+
undershoot: number;
|
|
222
|
+
/** Handedness: lateral offset as a share of the box width (approachBias × 0.4, −0.1–0.1). */
|
|
223
|
+
sideBias: number;
|
|
224
|
+
/** Share of visible checkbox / radio clicks that land on the label text, 0.25–0.55 (lane F's label aim). */
|
|
225
|
+
labelShare: number;
|
|
226
|
+
}
|
|
227
|
+
/** The persona's aiming traits from a salted stream of its seed. Same values as Python `aim_traits` and
|
|
228
|
+
* .NET `Motion.AimTraitsOf`. */
|
|
229
|
+
export declare function aimTraits(p: Persona): AimTraits;
|
|
230
|
+
/** A human click point inside `box`: a 2D gaussian toward the centre with the persona's dispersion
|
|
231
|
+
* (sd 0.10–0.20 of the box), nudged toward the approach side (undershoot 6–16 %) and sideways by its
|
|
232
|
+
* handedness (approachBias), clamped a couple px inside the edges. The SEED fixes the persona's spread,
|
|
233
|
+
* undershoot and handedness (it was one dispersion for everyone); each click's draw is unseeded (Math.random
|
|
234
|
+
* unless `rng` is given), like every per-action draw, so no two visits of one identity replay the same
|
|
235
|
+
* landing sequence. Without a persona: sd 0.15, 12 % undershoot, no handedness. */
|
|
236
|
+
export declare function clickPoint(box: Box, from: Point, p?: Persona | null, rng?: Rng): Point;
|
|
160
237
|
export interface Viewport {
|
|
161
238
|
width: number;
|
|
162
239
|
height: number;
|
|
@@ -167,4 +244,45 @@ export interface Viewport {
|
|
|
167
244
|
* biggest reason a challenge/slider is shown to headless automation). Returns ~`ms` of samples.
|
|
168
245
|
*/
|
|
169
246
|
export declare function planAmbient(from: Point, vp: Viewport, p: Persona, ms: number, rng?: Rng): Step[];
|
|
247
|
+
/** The pointer keeps within this many px of where a hover arrived while it dwells there. */
|
|
248
|
+
export declare const DWELL_RADIUS_PX = 3;
|
|
249
|
+
/** A move-off after a click is kept this far inside the viewport. */
|
|
250
|
+
export declare const MOVE_OFF_MARGIN_PX = 8;
|
|
251
|
+
/** Per-identity after-action traits, stable per seed (see afterTraits). */
|
|
252
|
+
export interface AfterTraits {
|
|
253
|
+
/** Centre of this hand's hover dwell, 250–700 ms (draws stay in 150–900). */
|
|
254
|
+
dwellMs: number;
|
|
255
|
+
/** Share of clicks followed by a move-off, 0.64–0.82 (a 40-click run stays in 60–85 %). */
|
|
256
|
+
moveOffRate: number;
|
|
257
|
+
/** Centre of the release → move-off gap, 300–600 ms (draws stay in 200–700). */
|
|
258
|
+
moveOffDelayMs: number;
|
|
259
|
+
/** Scale on the attention model's read pause, 0.85–1.15. */
|
|
260
|
+
readTempo: number;
|
|
261
|
+
}
|
|
262
|
+
/** The persona's after-action traits: the first four draws of its salted after-action stream.
|
|
263
|
+
*
|
|
264
|
+
* Measured on r42 / SDK 0.51.0 (SC 232 review): a hover stopped dead on arrival (0 samples after the
|
|
265
|
+
* glide's last one) and the pointer never left the pressed pixel after a click. Same values as Python
|
|
266
|
+
* `after_traits` and .NET `Motion.AfterTraitsOf`. */
|
|
267
|
+
export declare function afterTraits(p: Persona): AfterTraits;
|
|
268
|
+
/** The persona's after-action stream positioned AFTER its four trait draws. Used by the shared vectors only, to
|
|
269
|
+
* compare the SDKs draw for draw: the humanizer's per-action draws are unseeded (Math.random), as in planMove --
|
|
270
|
+
* the seed fixes traits only, or every session of an identity would replay one sequence. */
|
|
271
|
+
export declare function afterRng(p: Persona): Rng;
|
|
272
|
+
/** How long a hover dwells on arrival: the persona's centre × 0.6–1.4, kept in 150–800 ms (150–900 as the page
|
|
273
|
+
* measures it, with the glide's slow tail). */
|
|
274
|
+
export declare function dwellMs(p: Persona, rng?: Rng): number;
|
|
275
|
+
/** Plan the pointer's rest on a hover target: OU drift + 8–12 Hz tremor around `at` for about `ms` (at
|
|
276
|
+
* least 3 samples), every sample within DWELL_RADIUS_PX of `at` and inside `box` (1 px in; null: no box).
|
|
277
|
+
* The hand is not braced on a hover the way it is before a press: drift ×2, tremor ×1.5 of a glide's. */
|
|
278
|
+
export declare function planDwell(at: Point, box: Box | null, p: Persona, ms: number, rng?: Rng): Step[];
|
|
279
|
+
/** Does this click get a move-off? In `afterTraits(p).moveOffRate` of clicks: a draw against the rate,
|
|
280
|
+
* nudged by how far the page's running share (`hits` of `n` earlier clicks) has drifted from it. */
|
|
281
|
+
export declare function moveOffRoll(p: Persona, rng?: Rng, hits?: number, n?: number): boolean;
|
|
282
|
+
/** The release → move-off gap: the persona's centre × 0.7–1.3, kept in 200–660 ms (200–700 as the page measures it). */
|
|
283
|
+
export declare function moveOffDelayMs(p: Persona, rng?: Rng): number;
|
|
284
|
+
/** Where the hand drifts after a click: 40–200 px from `from` at an angle in the downward half-plane
|
|
285
|
+
* (20–160°, y down: the gateway's moveOnTarget model), kept MOVE_OFF_MARGIN_PX inside `vp`; mirrored
|
|
286
|
+
* upward when the clamp would leave it on the spot (a click near the bottom edge). */
|
|
287
|
+
export declare function planMoveOff(from: Point, vp: Viewport, p: Persona, rng?: Rng): Point;
|
|
170
288
|
//# sourceMappingURL=motion.d.ts.map
|
package/dist/motion.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../src/motion.ts"],"names":[],"mappings":"AA6BA;iGACiG;AACjG,MAAM,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC;AAE/B,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAQ/C;AAED,+FAA+F;AAC/F,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAUlE;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAK1C;AAED,sGAAsG;AACtG,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,SAAS,EAAE,MAAM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AE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAE,GAAiB,GAAG,IAAI,EAAE,CA0B5G;AAED;oGACoG;AACpG,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,GAAE,GAAiB,EAAE,IAAI,SAAI,EAAE,CAAC,SAAI,GAAG,OAAO,CAGxF;AAED,wHAAwH;AACxH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,GAAE,GAAiB,GAAG,MAAM,CAGzE;AAED;;sFAEsF;AACtF,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,GAAE,GAAiB,GAAG,KAAK,CAahG"}
|
package/dist/motion.js
CHANGED
|
@@ -59,6 +59,7 @@ export function gaussFrom(rng) {
|
|
|
59
59
|
return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);
|
|
60
60
|
}
|
|
61
61
|
const lerp = (a, b, t) => a + (b - a) * t;
|
|
62
|
+
const clampV = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
62
63
|
/** Derive a stable motor persona from a fingerprint seed (or random when unseeded). */
|
|
63
64
|
export function makePersona(seed) {
|
|
64
65
|
const seedInt = hashSeed(seed);
|
|
@@ -81,21 +82,62 @@ export function makePersona(seed) {
|
|
|
81
82
|
grabMaxMs: 360,
|
|
82
83
|
releaseMinMs: 90,
|
|
83
84
|
releaseMaxMs: 230,
|
|
84
|
-
clickHoldMinMs:
|
|
85
|
-
clickHoldMaxMs:
|
|
85
|
+
clickHoldMinMs: 55,
|
|
86
|
+
clickHoldMaxMs: 230,
|
|
86
87
|
keyDwellMinMs: 45,
|
|
87
88
|
keyDwellMaxMs: 120,
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
// Salt for the timing stream. Like the rollover and shape salts, a separate mulberry32(seed ^ salt) stream
|
|
92
|
+
// keeps makePersona's draw ORDER (and so every existing seed's motor identity) unchanged.
|
|
93
|
+
const TIMING_SALT = 0xc2b2ae35;
|
|
94
|
+
/** The persona's timing traits, drawn from a salted stream of its seed. Before this every identity shared
|
|
95
|
+
* ONE fixed window per timing (click hold 60–150, key dwell 45–120, grab 130–360, release 90–230,
|
|
96
|
+
* double-click gap 70–170, select-popup pauses, datetime gaps, the 2 % typo rate). Each value is the
|
|
97
|
+
* identity's MEDIAN; samples around it are log-normal and clamped to the persona's human band. Same values
|
|
98
|
+
* as Python `_motion.timing_traits` and .NET `Motion.TimingTraitsOf`. */
|
|
99
|
+
export function timingTraits(p) {
|
|
100
|
+
const r = mulberry32((p.seed ^ TIMING_SALT) >>> 0);
|
|
101
|
+
const clickHoldMs = lerp(70, 140, r());
|
|
102
|
+
const keyDwellMs = lerp(60, 95, r());
|
|
103
|
+
const grabMs = lerp(180, 280, r());
|
|
104
|
+
const releaseMs = lerp(120, 180, r());
|
|
105
|
+
const dblclickGapMs = lerp(90, 140, r());
|
|
106
|
+
const pauseScale = lerp(0.8, 1.25, r());
|
|
107
|
+
const typoRate = lerp(0.005, 0.04, r());
|
|
108
|
+
return { clickHoldMs, keyDwellMs, grabMs, releaseMs, dblclickGapMs, pauseScale, typoRate };
|
|
109
|
+
}
|
|
110
|
+
/** `median * exp(sigma * N(0,1))` clamped to [lo, hi]: a right-skewed human timing around a per-identity median. */
|
|
111
|
+
export function lognormalMs(median, sigma, lo, hi, rng) {
|
|
112
|
+
return clampV(median * Math.exp(sigma * gaussFrom(rng)), lo, hi);
|
|
113
|
+
}
|
|
114
|
+
/** The preset's tempo on `p` (HumanizeOptions: careful 1.4 / default 1 / quick 0.7, set by applyToPersona after
|
|
115
|
+
* makePersona; 1 on a bare persona, so every vector is unchanged). */
|
|
116
|
+
export function tempoOf(p) {
|
|
117
|
+
const t = p?.tempo;
|
|
118
|
+
return typeof t === "number" && t > 0 ? t : 1;
|
|
119
|
+
}
|
|
120
|
+
/** A human mousedown→mouseup click hold (ms): log-normal (σ 0.25) around the persona's own median
|
|
121
|
+
* (70–140 ms), clamped to its band (55–230 ms). */
|
|
92
122
|
export function clickHold(p, rng = Math.random) {
|
|
93
|
-
return p.
|
|
123
|
+
return lognormalMs(timingTraits(p).clickHoldMs * tempoOf(p), 0.25, p.clickHoldMinMs, p.clickHoldMaxMs, rng);
|
|
94
124
|
}
|
|
95
|
-
/** A human per-key keydown→keyup dwell (ms)
|
|
96
|
-
*
|
|
125
|
+
/** A human per-key keydown→keyup dwell (ms): log-normal (σ 0.22) around the persona's own median
|
|
126
|
+
* (60–95 ms), clamped to its band (45–120 ms). */
|
|
97
127
|
export function keyDwell(p, rng = Math.random) {
|
|
98
|
-
return p.
|
|
128
|
+
return lognormalMs(timingTraits(p).keyDwellMs * tempoOf(p), 0.22, p.keyDwellMinMs, p.keyDwellMaxMs, rng);
|
|
129
|
+
}
|
|
130
|
+
/** The gap between the two presses of a double click (ms): log-normal (σ 0.15) around the persona's
|
|
131
|
+
* median (90–140), clamped to 70–170. */
|
|
132
|
+
export function dblclickGap(p, rng = Math.random) {
|
|
133
|
+
const t = tempoOf(p);
|
|
134
|
+
return lognormalMs(timingTraits(p).dblclickGapMs * t, 0.15, 70 * t, 170 * t, rng);
|
|
135
|
+
}
|
|
136
|
+
/** A deliberation pause (ms) from [lo, hi], scaled by the persona's tempo (pauseScale 0.8–1.25).
|
|
137
|
+
* Without a persona: the plain window. */
|
|
138
|
+
export function pauseMs(p, lo, hi, rng = Math.random) {
|
|
139
|
+
const v = lerp(lo, hi, rng());
|
|
140
|
+
return p ? v * timingTraits(p).pauseScale * tempoOf(p) : v;
|
|
99
141
|
}
|
|
100
142
|
// Salt for the rollover stream. Drawing from mulberry32(seed ^ salt) instead of adding a field to
|
|
101
143
|
// makePersona keeps the persona draw ORDER (and so every existing seed's motor identity) unchanged.
|
|
@@ -402,24 +444,124 @@ export function planDrag(from, to, p, opts = {}) {
|
|
|
402
444
|
}
|
|
403
445
|
return out;
|
|
404
446
|
}
|
|
405
|
-
|
|
447
|
+
// Salt for the drag-start hesitation traits (Python _HESITATION_SALT, .NET HesitationSalt): a salted
|
|
448
|
+
// stream keeps makePersona's draw ORDER, and planDrag itself is untouched.
|
|
449
|
+
const HESITATION_SALT = 0xfd7046c5; // own stream (was the timing salt: hesitation moved with the click hold)
|
|
450
|
+
/** The drag-start hesitation window (ms): a hand that has just closed on a handle holds 100-300 ms. */
|
|
451
|
+
export const HESITATION_MS = [100, 300];
|
|
452
|
+
/** ... creeping a few px, never this far, before the leg proper. */
|
|
453
|
+
export const HESITATION_MAX_PX = 8;
|
|
454
|
+
/** The still-but-not-frozen moment between the grab and the drag leg from->to: samples spanning
|
|
455
|
+
* 100-300 ms (centred per persona; `durMs`, 40-300, overrides the length but the persona's draw is still
|
|
456
|
+
* made), creeping < 8 px toward `to` with a little sideways wobble. Same numbers as Python
|
|
457
|
+
* `_motion.drag_hesitation` and .NET `Motion.DragHesitation` (sdk/testdata/humanize_scroll_vectors.json).
|
|
458
|
+
* Measured on r38 / SDK 0.51.0 (SC 232): every drag's first held move was already the full-speed leg. */
|
|
459
|
+
export function dragHesitation(from, to, p, rng = Math.random, durMs) {
|
|
460
|
+
const r = mulberry32((p.seed ^ HESITATION_SALT) >>> 0);
|
|
461
|
+
const centre = lerp(130, 260, r());
|
|
462
|
+
const amp = lerp(2, 6, r());
|
|
463
|
+
const wobble = lerp(0.4, 1.2, r());
|
|
464
|
+
const d = Math.hypot(to.x - from.x, to.y - from.y);
|
|
465
|
+
const [ux, uy] = d >= 1e-6 ? [(to.x - from.x) / d, (to.y - from.y) / d] : [1, 0];
|
|
466
|
+
let dur = clamp(centre * lerp(0.8, 1.2, rng()), HESITATION_MS[0], HESITATION_MS[1]);
|
|
467
|
+
if (durMs !== undefined && durMs !== null)
|
|
468
|
+
dur = clamp(durMs, 40, HESITATION_MS[1]);
|
|
469
|
+
const reach = amp * lerp(0.6, 1.0, rng());
|
|
470
|
+
const stepMs = 1000 / p.deviceHz;
|
|
471
|
+
const n = Math.max(3, jsRound(dur / stepMs));
|
|
472
|
+
const dt = dur / n;
|
|
473
|
+
const phase = rng() * 2 * Math.PI;
|
|
474
|
+
const out = [];
|
|
475
|
+
let side = 0;
|
|
476
|
+
for (let i = 1; i <= n; i++) {
|
|
477
|
+
const tau = i / n;
|
|
478
|
+
const along = reach * minJerk(tau);
|
|
479
|
+
side = 0.8 * side + gaussFrom(rng) * wobble * 0.25;
|
|
480
|
+
const s = clamp(side + wobble * 0.5 * Math.sin(phase + 2 * Math.PI * tau), -1.5, 1.5);
|
|
481
|
+
let px = from.x + ux * along - uy * s, py = from.y + uy * along + ux * s;
|
|
482
|
+
if (Math.hypot(px - from.x, py - from.y) >= HESITATION_MAX_PX - 0.5) {
|
|
483
|
+
px = from.x + ux * (HESITATION_MAX_PX - 1);
|
|
484
|
+
py = from.y + uy * (HESITATION_MAX_PX - 1);
|
|
485
|
+
}
|
|
486
|
+
out.push({ x: px, y: py, sleepMs: dt * lerp(0.9, 1.1, rng()) });
|
|
487
|
+
}
|
|
488
|
+
return out;
|
|
489
|
+
}
|
|
490
|
+
/** When (ms from the start of `steps`) the walk first leaves the `radius` circle around `from`. */
|
|
491
|
+
export function legExitMs(from, steps, radius = HESITATION_MAX_PX) {
|
|
492
|
+
let t = 0;
|
|
493
|
+
for (const s of steps) {
|
|
494
|
+
if (Math.hypot(s.x - from.x, s.y - from.y) >= radius)
|
|
495
|
+
return t;
|
|
496
|
+
t += s.sleepMs;
|
|
497
|
+
}
|
|
498
|
+
return t;
|
|
499
|
+
}
|
|
500
|
+
/** The held part of a drag: the hesitation creep, then the planDrag leg, planned together so the pointer
|
|
501
|
+
* stays inside 8 px of the press for `windowMs` (clamped 100-300: the persona's grab dwell) and then goes.
|
|
502
|
+
* Same as Python `hesitate_then_drag`. */
|
|
503
|
+
export function hesitateThenDrag(from, to, p, windowMs, settle = true, rng = Math.random) {
|
|
504
|
+
const w = clamp(windowMs, HESITATION_MS[0], HESITATION_MS[1]);
|
|
505
|
+
let creep = dragHesitation(from, to, p, rng, w);
|
|
506
|
+
let leg = planDrag(creep[creep.length - 1], to, p, { settle, rng });
|
|
507
|
+
const t8 = legExitMs(from, leg);
|
|
508
|
+
const want = Math.max(40, w - t8);
|
|
509
|
+
const have = creep.reduce((a, s) => a + s.sleepMs, 0);
|
|
510
|
+
if (Math.abs(have - want) > 1) {
|
|
511
|
+
const k = want / have, m = Math.min(1, k);
|
|
512
|
+
creep = creep.map((s) => ({ x: from.x + (s.x - from.x) * m, y: from.y + (s.y - from.y) * m, sleepMs: s.sleepMs * k }));
|
|
513
|
+
leg = planDrag(creep[creep.length - 1], to, p, { settle, rng });
|
|
514
|
+
}
|
|
515
|
+
return { steps: creep.concat(leg), creep: creep.length };
|
|
516
|
+
}
|
|
517
|
+
/** Where a reading hand parks the pointer before a wheel: x ~ 0.5w ± 0.10w clamped [0.12w, 0.88w], y ~ 0.34h
|
|
518
|
+
* ± 0.09h clamped [0.10h, 0.62h] (two gaussians, x first). One model in all three SDKs (Python
|
|
519
|
+
* `wheel_anchor_point`, .NET `Motion.WheelAnchorPoint`); before 0.52 Node used 0.48/0.36 and other clamps. */
|
|
520
|
+
export function wheelAnchorPoint(vw, vh, rng = Math.random) {
|
|
521
|
+
const x = clamp(vw * 0.5 + gaussFrom(rng) * vw * 0.10, vw * 0.12, vw * 0.88);
|
|
522
|
+
const y = clamp(vh * 0.34 + gaussFrom(rng) * vh * 0.09, vh * 0.10, vh * 0.62);
|
|
523
|
+
return [x, y];
|
|
524
|
+
}
|
|
525
|
+
/** Grab/release dwell times (ms) for a held-button drag: log-normal (σ 0.2) around the persona's medians,
|
|
526
|
+
* inside its grab/release bands. */
|
|
406
527
|
export function dragDwell(p, rng = Math.random) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
528
|
+
const tt = timingTraits(p);
|
|
529
|
+
const t = tempoOf(p); // the preset scales the medians; applyToPersona already scaled the bands
|
|
530
|
+
const grabMs = lognormalMs(tt.grabMs * t, 0.2, p.grabMinMs, p.grabMaxMs, rng);
|
|
531
|
+
const releaseMs = lognormalMs(tt.releaseMs * t, 0.2, p.releaseMinMs, p.releaseMaxMs, rng);
|
|
532
|
+
return { grabMs, releaseMs };
|
|
533
|
+
}
|
|
534
|
+
// Salt for the aim traits (clickPoint): the persona's landing dispersion, undershoot and handedness.
|
|
535
|
+
const AIM_SALT = 0x27d4eb2f;
|
|
536
|
+
/** The persona's aiming traits from a salted stream of its seed. Same values as Python `aim_traits` and
|
|
537
|
+
* .NET `Motion.AimTraitsOf`. */
|
|
538
|
+
export function aimTraits(p) {
|
|
539
|
+
const r = mulberry32((p.seed ^ AIM_SALT) >>> 0);
|
|
540
|
+
const spread = lerp(0.10, 0.20, r());
|
|
541
|
+
const undershoot = lerp(0.06, 0.16, r());
|
|
542
|
+
const labelShare = lerp(0.25, 0.55, r()); // SC 232 integration: a trait (was one 0.4 for every identity)
|
|
543
|
+
return { spread, undershoot, sideBias: p.approachBias * 0.4, labelShare };
|
|
411
544
|
}
|
|
412
|
-
/** A human click point inside `box`: a 2D gaussian
|
|
413
|
-
* (
|
|
545
|
+
/** A human click point inside `box`: a 2D gaussian toward the centre with the persona's dispersion
|
|
546
|
+
* (sd 0.10–0.20 of the box), nudged toward the approach side (undershoot 6–16 %) and sideways by its
|
|
547
|
+
* handedness (approachBias), clamped a couple px inside the edges. The SEED fixes the persona's spread,
|
|
548
|
+
* undershoot and handedness (it was one dispersion for everyone); each click's draw is unseeded (Math.random
|
|
549
|
+
* unless `rng` is given), like every per-action draw, so no two visits of one identity replay the same
|
|
550
|
+
* landing sequence. Without a persona: sd 0.15, 12 % undershoot, no handedness. */
|
|
414
551
|
export function clickPoint(box, from, p, rng = Math.random) {
|
|
552
|
+
let spread = 0.15, under = 0.12, side = 0;
|
|
553
|
+
if (p) {
|
|
554
|
+
const at = aimTraits(p);
|
|
555
|
+
spread = at.spread;
|
|
556
|
+
under = at.undershoot;
|
|
557
|
+
side = at.sideBias;
|
|
558
|
+
}
|
|
415
559
|
const cx = box.x + box.width / 2, cy = box.y + box.height / 2;
|
|
416
560
|
const dx = cx - from.x, dy = cy - from.y;
|
|
417
561
|
const d = Math.hypot(dx, dy) || 1;
|
|
418
|
-
// undershoot bias: pull ~12% of the half-width back toward the approach direction
|
|
419
562
|
const ux = -dx / d, uy = -dy / d;
|
|
420
|
-
const
|
|
421
|
-
const
|
|
422
|
-
const y = cy + by + gaussFrom(rng) * box.height * 0.16;
|
|
563
|
+
const x = cx + ux * box.width * under + side * box.width + gaussFrom(rng) * box.width * spread;
|
|
564
|
+
const y = cy + uy * box.height * under + gaussFrom(rng) * box.height * spread;
|
|
423
565
|
// For a box narrower/shorter than the 4 px inset the clamp bounds would invert (lo > hi) and return
|
|
424
566
|
// a point OUTSIDE the element — just use the center for such tiny targets.
|
|
425
567
|
return {
|
|
@@ -470,4 +612,101 @@ export function planAmbient(from, vp, p, ms, rng = Math.random) {
|
|
|
470
612
|
}
|
|
471
613
|
return out;
|
|
472
614
|
}
|
|
615
|
+
// ------------------------------------------------------------------ after-action (SC 232 lane C)
|
|
616
|
+
// Salt for the after-action stream (hover dwell, move-off after a click, the attention model). A separate
|
|
617
|
+
// mulberry32(seed ^ salt) stream keeps makePersona's draw ORDER (every existing seed's motor identity)
|
|
618
|
+
// unchanged. Same values in Python `_motion.py` and .NET `Motion.cs`.
|
|
619
|
+
const AFTER_SALT = 0x165667b1; // own stream (was the timing salt: dwell moved with the click hold)
|
|
620
|
+
/** The pointer keeps within this many px of where a hover arrived while it dwells there. */
|
|
621
|
+
export const DWELL_RADIUS_PX = 3;
|
|
622
|
+
/** A move-off after a click is kept this far inside the viewport. */
|
|
623
|
+
export const MOVE_OFF_MARGIN_PX = 8;
|
|
624
|
+
/** The persona's after-action traits: the first four draws of its salted after-action stream.
|
|
625
|
+
*
|
|
626
|
+
* Measured on r42 / SDK 0.51.0 (SC 232 review): a hover stopped dead on arrival (0 samples after the
|
|
627
|
+
* glide's last one) and the pointer never left the pressed pixel after a click. Same values as Python
|
|
628
|
+
* `after_traits` and .NET `Motion.AfterTraitsOf`. */
|
|
629
|
+
export function afterTraits(p) {
|
|
630
|
+
const r = mulberry32((p.seed ^ AFTER_SALT) >>> 0);
|
|
631
|
+
const dwellMs = lerp(250, 700, r());
|
|
632
|
+
const moveOffRate = lerp(0.64, 0.82, r());
|
|
633
|
+
const moveOffDelayMs = lerp(300, 600, r());
|
|
634
|
+
const readTempo = lerp(0.85, 1.15, r());
|
|
635
|
+
return { dwellMs, moveOffRate, moveOffDelayMs, readTempo };
|
|
636
|
+
}
|
|
637
|
+
/** The persona's after-action stream positioned AFTER its four trait draws. Used by the shared vectors only, to
|
|
638
|
+
* compare the SDKs draw for draw: the humanizer's per-action draws are unseeded (Math.random), as in planMove --
|
|
639
|
+
* the seed fixes traits only, or every session of an identity would replay one sequence. */
|
|
640
|
+
export function afterRng(p) {
|
|
641
|
+
const r = mulberry32((p.seed ^ AFTER_SALT) >>> 0);
|
|
642
|
+
for (let i = 0; i < 4; i++)
|
|
643
|
+
r();
|
|
644
|
+
return r;
|
|
645
|
+
}
|
|
646
|
+
/** How long a hover dwells on arrival: the persona's centre × 0.6–1.4, kept in 150–800 ms (150–900 as the page
|
|
647
|
+
* measures it, with the glide's slow tail). */
|
|
648
|
+
export function dwellMs(p, rng = Math.random) {
|
|
649
|
+
return clamp(afterTraits(p).dwellMs * lerp(0.6, 1.4, rng()), 150, 800);
|
|
650
|
+
}
|
|
651
|
+
/** Plan the pointer's rest on a hover target: OU drift + 8–12 Hz tremor around `at` for about `ms` (at
|
|
652
|
+
* least 3 samples), every sample within DWELL_RADIUS_PX of `at` and inside `box` (1 px in; null: no box).
|
|
653
|
+
* The hand is not braced on a hover the way it is before a press: drift ×2, tremor ×1.5 of a glide's. */
|
|
654
|
+
export function planDwell(at, box, p, ms, rng = Math.random) {
|
|
655
|
+
const stepMs = 1000 / p.deviceHz;
|
|
656
|
+
const n = Math.max(3, jsRound(Math.max(0, ms) / (stepMs * 1.15))); // rest gaps average 1.15 frames
|
|
657
|
+
const out = [];
|
|
658
|
+
let driftX = 0, driftY = 0;
|
|
659
|
+
const tphase = rng() * 2 * Math.PI;
|
|
660
|
+
let t = 0;
|
|
661
|
+
for (let i = 0; i < n; i++) {
|
|
662
|
+
const k = stepMs / p.driftTau;
|
|
663
|
+
driftX += -k * driftX + Math.sqrt(2 * k) * p.driftAmp * 2 * gaussFrom(rng);
|
|
664
|
+
driftY += -k * driftY + Math.sqrt(2 * k) * p.driftAmp * 2 * gaussFrom(rng);
|
|
665
|
+
const ph = tphase + (2 * Math.PI * p.tremorHz * t) / 1000;
|
|
666
|
+
let dx = driftX + p.tremorAmp * 1.5 * Math.sin(ph);
|
|
667
|
+
let dy = driftY + p.tremorAmp * 1.5 * Math.sin(ph + Math.PI / 2);
|
|
668
|
+
const r = Math.hypot(dx, dy);
|
|
669
|
+
if (r > DWELL_RADIUS_PX) {
|
|
670
|
+
dx = (dx * DWELL_RADIUS_PX) / r;
|
|
671
|
+
dy = (dy * DWELL_RADIUS_PX) / r;
|
|
672
|
+
}
|
|
673
|
+
let x = at.x + dx, y = at.y + dy;
|
|
674
|
+
if (box) {
|
|
675
|
+
x = box.width >= 2 ? clamp(x, box.x + 1, box.x + box.width - 1) : at.x;
|
|
676
|
+
y = box.height >= 2 ? clamp(y, box.y + 1, box.y + box.height - 1) : at.y;
|
|
677
|
+
}
|
|
678
|
+
const sleepMs = stepMs * lerp(0.9, 1.4, rng());
|
|
679
|
+
out.push({ x, y, sleepMs });
|
|
680
|
+
t += sleepMs;
|
|
681
|
+
}
|
|
682
|
+
return out;
|
|
683
|
+
}
|
|
684
|
+
/** Does this click get a move-off? In `afterTraits(p).moveOffRate` of clicks: a draw against the rate,
|
|
685
|
+
* nudged by how far the page's running share (`hits` of `n` earlier clicks) has drifted from it. */
|
|
686
|
+
export function moveOffRoll(p, rng = Math.random, hits = 0, n = 0) {
|
|
687
|
+
const rate = afterTraits(p).moveOffRate;
|
|
688
|
+
return rng() < clamp(rate + 0.5 * (rate * n - hits), 0.05, 0.98);
|
|
689
|
+
}
|
|
690
|
+
/** The release → move-off gap: the persona's centre × 0.7–1.3, kept in 200–660 ms (200–700 as the page measures it). */
|
|
691
|
+
export function moveOffDelayMs(p, rng = Math.random) {
|
|
692
|
+
const t = tempoOf(p);
|
|
693
|
+
return clamp(afterTraits(p).moveOffDelayMs * t * lerp(0.7, 1.3, rng()), 200 * t, 660 * t);
|
|
694
|
+
}
|
|
695
|
+
/** Where the hand drifts after a click: 40–200 px from `from` at an angle in the downward half-plane
|
|
696
|
+
* (20–160°, y down: the gateway's moveOnTarget model), kept MOVE_OFF_MARGIN_PX inside `vp`; mirrored
|
|
697
|
+
* upward when the clamp would leave it on the spot (a click near the bottom edge). */
|
|
698
|
+
export function planMoveOff(from, vp, p, rng = Math.random) {
|
|
699
|
+
void p;
|
|
700
|
+
const m = MOVE_OFF_MARGIN_PX;
|
|
701
|
+
const ang = lerp(20, 160, rng()) * (Math.PI / 180); // as Python math.radians rounds it
|
|
702
|
+
const dist = lerp(40, 200, rng());
|
|
703
|
+
const dx = Math.cos(ang) * dist, dy = Math.sin(ang) * dist;
|
|
704
|
+
let x = clamp(from.x + dx, m, vp.width - m);
|
|
705
|
+
let y = clamp(from.y + dy, m, vp.height - m);
|
|
706
|
+
if (Math.hypot(x - from.x, y - from.y) < 12) {
|
|
707
|
+
x = clamp(from.x + dx, m, vp.width - m);
|
|
708
|
+
y = clamp(from.y - dy, m, vp.height - m);
|
|
709
|
+
}
|
|
710
|
+
return { x, y };
|
|
711
|
+
}
|
|
473
712
|
//# sourceMappingURL=motion.js.map
|