Skip to content

feat: add ambient mouse API endpoint for anti-bot event diversity#149

Open
ulziibay-kernel wants to merge 1 commit intoulziibay-kernel/add-human-like-curvesfrom
ulziibay-kernel/add-mouse-deamon
Open

feat: add ambient mouse API endpoint for anti-bot event diversity#149
ulziibay-kernel wants to merge 1 commit intoulziibay-kernel/add-human-like-curvesfrom
ulziibay-kernel/add-mouse-deamon

Conversation

@ulziibay-kernel
Copy link
Contributor

@ulziibay-kernel ulziibay-kernel commented Feb 11, 2026

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.

  • 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

Builds on top of #148


Note

Medium Risk
Adds a new background input loop and changes the default MoveMouse behavior to multi-step movement, which may affect timing and interaction determinism for existing clients.

Overview
Adds a new POST /computer/ambient_mouse API 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 existing inputMu lock.

Updates MoveMouse to support human-like smooth motion by default (smooth + optional duration_sec), generating a Bezier-like trajectory and executing stepwise xdotool mousemove_relative with jittered delays; also ensures the ambient loop is cancelled during ApiService.Shutdown and adds cached display-geometry lookups for ambient actions.

Written by Cursor Bugbot for commit ab8a845. This will update automatically on new commits. Configure here.

if s.ambientCancel != nil {
s.ambientCancel()
s.ambientCancel = nil
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Fix in Cursor Fix in Web

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>
@ulziibay-kernel ulziibay-kernel force-pushed the ulziibay-kernel/add-mouse-deamon branch from de2df27 to ab8a845 Compare February 11, 2026 21:56
@ulziibay-kernel ulziibay-kernel changed the base branch from main to ulziibay-kernel/add-human-like-curves February 11, 2026 21:56
@ulziibay-kernel ulziibay-kernel changed the title feat: add mouse-ambient daemon for anti-bot event diversity feat: add ambient mouse API endpoint for anti-bot event diversity Feb 11, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants