feat: add ambient mouse API endpoint for anti-bot event diversity#149
feat: add ambient mouse API endpoint for anti-bot event diversity#149ulziibay-kernel wants to merge 1 commit intoulziibay-kernel/add-human-like-curvesfrom
Conversation
| if s.ambientCancel != nil { | ||
| s.ambientCancel() | ||
| s.ambientCancel = nil | ||
| } |
There was a problem hiding this comment.
Invalid config request kills existing ambient loop
Medium Severity
SetAmbientMouse unconditionally cancels the existing ambient loop (lines 50–53) before validating the new configuration via resolveAmbientConfig (line 62). If a user calls this endpoint with enabled: true but invalid parameters (e.g., min_interval_ms > max_interval_ms), the running loop is stopped and the 400 error is returned — leaving the system with no ambient loop running. The config validation needs to happen before the old loop is cancelled to avoid this destructive side effect on error.
Additional Locations (1)
Add POST /computer/ambient_mouse to toggle a background loop of diverse input events (mouse drift, scroll, micro-drag, click, key tap). The loop acquires inputMu per action so it cooperates with explicit computer-use API calls instead of contending with them. - Configurable intervals (min/max_interval_ms) and per-action weights - Display geometry cached for 30s to minimize lock hold time - Mouseup uses background context to prevent stuck mouse button on cancel - Clean shutdown via Shutdown() cancels the ambient context Co-authored-by: Cursor <cursoragent@cursor.com>
de2df27 to
ab8a845
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| } | ||
| if cfg.minIntervalMs > cfg.maxIntervalMs { | ||
| return cfg, fmt.Errorf("min_interval_ms must be <= max_interval_ms") | ||
| } |
There was a problem hiding this comment.
Missing minimum interval allows CPU-intensive tight loop
Medium Severity
resolveAmbientConfig only validates that minIntervalMs <= maxIntervalMs, but doesn't enforce a positive floor. A client can pass min_interval_ms: 0, max_interval_ms: 0, causing the ambient loop to run with zero delay between iterations — a tight busy loop that constantly acquires inputMu and shells out to xdotool, starving other API calls. The OpenAPI spec declares minimum: 50 but that isn't enforced server-side.


feat: add ambient mouse API endpoint for anti-bot event diversity
Add POST /computer/ambient_mouse to toggle a background loop of diverse
input events (mouse drift, scroll, micro-drag, click, key tap). The loop
acquires inputMu per action so it cooperates with explicit computer-use
API calls instead of contending with them.
Builds on top of #148
Note
Medium Risk
Adds a new background input loop and changes the default
MoveMousebehavior to multi-step movement, which may affect timing and interaction determinism for existing clients.Overview
Adds a new
POST /computer/ambient_mouseAPI that starts/stops a background goroutine emitting randomized input events (drift, scroll, micro-drag, click, key tap) with configurable intervals and per-action weights, coordinated via the existinginputMulock.Updates
MoveMouseto support human-like smooth motion by default (smooth+ optionalduration_sec), generating a Bezier-like trajectory and executing stepwisexdotool mousemove_relativewith jittered delays; also ensures the ambient loop is cancelled duringApiService.Shutdownand adds cached display-geometry lookups for ambient actions.Written by Cursor Bugbot for commit ab8a845. This will update automatically on new commits. Configure here.