Skip to main content

Crate vs_humanize

Crate vs_humanize 

Source
Expand description

Pure-math input synthesis for vibesurfer’s three input modes.

The crate is intentionally narrow: given a start and end point, some text to type, or a scroll delta, return a sequence of discrete Steps tagged with relative time. The engine crate consumes that sequence and translates each step into a platform-native event (NSEvent on macOS, GdkEvent on Linux, Input.dispatchMouseEvent over CDP on Windows).

The split keeps the math testable without WebKit and the per-platform code testable without doing humanization math. It also concentrates the realism work in one place: improving the Bezier sampler or the keystroke distribution lifts every backend at once.

§Modes

ModeSequence shape
HumanBezier path, Fitts arrival, digraph keys
CarefulSingle-shot dispatch, no path or per-key delay
RoboticEmpty sequence — caller falls back to JS path

See InputMode for details.

§Determinism

Every entry point takes a seed: u64. Same seed + same inputs produce byte-identical output. This lets tests assert exact sequences and lets the daemon persist a per-session seed so a given agent produces consistent typing patterns across runs against the same site.

Structs§

Key
One key, identified by a USB HID-ish code (engines map this to their platform’s keycode space) and an optional UTF-32 character.
KeyStep
One key event in a synthesized sequence.
MouseStep
One mouse event in a synthesized sequence.
Point
2D point in CSS pixels. The caller picks the coordinate frame (page-local or viewport-local); we just emit numbers.
Vec2
2D vector (delta).
WheelStep
One wheel-tick event.

Enums§

InputMode
Which input style to synthesize.
KeyStepKind
What kind of key event this step is.
MouseButton
Which physical button the step refers to. Vibesurfer only uses Left today, but Middle and Right are exposed so future primitives don’t need a wire-format break.
MouseStepKind
What kind of mouse event this step is.

Functions§

key_sequence
Synthesize a key sequence for typing text.
mouse_path
Synthesize a left-click mouse path from start to end.
scroll_sequence
Synthesize a scroll sequence delivering total delta over time.