utils/computer_use/computer_use_manager library
Computer Use Manager
Faithful port of neomage/src/utils/computerUse/*.ts Covers: executor.ts, computerUseLock.ts, appNames.ts
Provides:
- CLI ComputerExecutor with mouse/keyboard/screenshot/app management
- Session-level computer use lock with O_EXCL atomic acquisition
- App name filtering/sanitization for prompt injection hardening
- macOS native module integration (Rust/enigo input, Swift screenshots)
Classes
- AcquireResult
- Result of attempting to acquire the computer use lock.
- AcquireResultAcquired
- AcquireResultBlocked
- CheckResult
- Result of checking the computer use lock state.
- CheckResultBlocked
- CheckResultFree
- CheckResultHeldBySelf
- CliComputerExecutor
-
macOS CLI executor that wraps native modules.
Uses
@ant/computer-use-input(Rust/enigo) for mouse/keyboard and@ant/computer-use-swiftfor screenshots, app management, TCC. - ComputerExecutor
- Abstract interface for computer use operations.
- ComputerUseCapabilities
- Capabilities of the CLI computer use executor.
- ComputerUseController
- Sint controller managing computer use state.
- ComputerUseLock
- Lock content stored in computer-use.lock.
- ComputerUseLockManager
- Manages computer use session locking.
- DisplayGeometry
- Display geometry information.
- FrontmostApp
- Information about the frontmost application.
- InstalledApp
- Information about an installed application.
- ResolvePrepareCaptureResult
- Result of preparing capture with display resolution.
- RunningApp
- Information about a running application.
- ScreenshotResult
- Screenshot result.
Constants
-
alwaysKeepBundleIds
→ const Set<
String> - Apps commonly requested for CU automation. Always included if installed. Bundle IDs (locale-invariant). Keep <30.
- appNameMaxCount → const int
- Maximum number of app names to include in descriptions.
- appNameMaxLen → const int
- Maximum length for app display names (prompt injection hardening).
- cliCuCapabilities → const ComputerUseCapabilities
- Default CLI computer use capabilities.
- cliHostBundleId → const String
- Sentinel bundle ID when terminal detection fails.
- lockFilename → const String
- Lock file name for computer use session lock.
- longPrefillThreshold → const int
- Threshold for long prefill prompts (chars).
- moveSettleMs → const int
- Settle time after mouse move before reading position or dispatching click.
-
pathAllowlist
→ const List<
String> - Only apps under these roots are shown (macOS).
- screenshotJpegQuality → const double
- JPEG quality for screenshots.
Properties
- appNameAllowed → RegExp
-
Regex for allowed app name characters.
\p{L}\p{M}\p{N} with Unicode — not \w (ASCII-only).
Single space not \s — \s matches newlines.
final
-
namePatternBlocklist
→ List<
RegExp> -
Display-name patterns that mark background services.
final
Functions
-
filterAppsForDescription(
List< InstalledApp> installed, String? homeDir) → List<String> - Filter raw Spotlight results to user-facing apps, then sanitize. Always-keep apps bypass path/name filter AND char allowlist.
-
unhideComputerUseApps(
List< String> bundleIds) → Future<void> - Unhide apps hidden during computer use (called at turn-end).
Typedefs
- VoidCallback = void Function()
- Typedef for cleanup callbacks.