pub struct ComputerUseDriver { /* private fields */ }Expand description
Shared driver all seven computer-use tools hold an Arc<> to.
Implementations§
Source§impl ComputerUseDriver
impl ComputerUseDriver
pub fn new(backend: Backend) -> Self
pub fn backend(&self) -> Backend
Sourcepub fn ensure_alive(&self) -> Result<(), String>
pub fn ensure_alive(&self) -> Result<(), String>
Cheap mid-call liveness check. Tools call this first inside
execute(); if the display went away after registration,
they return a clean error instead of hanging on subprocess
dispatch.
Sourcepub fn scale_coords(
&self,
x: i32,
y: i32,
screenshot_id: Option<u64>,
) -> Result<(i32, i32), String>
pub fn scale_coords( &self, x: i32, y: i32, screenshot_id: Option<u64>, ) -> Result<(i32, i32), String>
Translate model-space coords to screen-space using the metadata
registered for screenshot_id (or the latest if None).
Sourcepub fn register_screenshot(
&self,
scale_factor: f64,
offset_x: i32,
offset_y: i32,
kind: String,
) -> u64
pub fn register_screenshot( &self, scale_factor: f64, offset_x: i32, offset_y: i32, kind: String, ) -> u64
Allocate a fresh registry id and record metadata.
Sourcepub async fn capture(
&self,
spec: ScreenshotSpec,
token: &CancellationToken,
) -> Result<CaptureResult>
pub async fn capture( &self, spec: ScreenshotSpec, token: &CancellationToken, ) -> Result<CaptureResult>
Capture and return the encoded result. Respects cancellation
via token.cancelled() races in the subprocess wait.
Sourcepub async fn capture_focused_for_autoshot(
&self,
token: &CancellationToken,
) -> Option<(String, String)>
pub async fn capture_focused_for_autoshot( &self, token: &CancellationToken, ) -> Option<(String, String)>
Convenience for click/type/key tools: capture the focused
window and return (summary, base64_png) for inclusion in
the tool’s auto-screenshot. Best-effort — on error returns
None and the caller can fall back to a screenshot-less
outcome.
Sourcepub async fn check_cursor_landed(&self, sx: i32, sy: i32) -> Option<String>
pub async fn check_cursor_landed(&self, sx: i32, sy: i32) -> Option<String>
X11-only: verify the cursor actually landed where xdotool was
told to move it. Returns Some(warning) if the cursor ended
up more than CURSOR_LANDED_TOLERANCE_PX away (focus change,
window moved, WM rejected the move). None if within
tolerance or the probe itself failed (best-effort — never
blocks the click).
Source§impl ComputerUseDriver
impl ComputerUseDriver
Sourcepub async fn click(
&self,
sx: i32,
sy: i32,
button: &str,
token: &CancellationToken,
) -> Result<()>
pub async fn click( &self, sx: i32, sy: i32, button: &str, token: &CancellationToken, ) -> Result<()>
Click at the given SCREEN coordinates (already scaled by
scale_coords). button is "left" | "middle" | "right".
Sourcepub async fn type_text(
&self,
text: &str,
token: &CancellationToken,
) -> Result<()>
pub async fn type_text( &self, text: &str, token: &CancellationToken, ) -> Result<()>
Type text at the current focus. Per-keystroke delay from
TYPE_KEY_DELAY_MS — empirically needed for slow Electron /
web targets that drop characters at lower rates.
Sourcepub async fn press_key(
&self,
key: &str,
token: &CancellationToken,
) -> Result<()>
pub async fn press_key( &self, key: &str, token: &CancellationToken, ) -> Result<()>
Press a key (or key combination like "ctrl+shift+t").
Sourcepub async fn scroll(
&self,
direction: &str,
amount: i32,
token: &CancellationToken,
) -> Result<()>
pub async fn scroll( &self, direction: &str, amount: i32, token: &CancellationToken, ) -> Result<()>
Scroll amount ticks in direction (“up” / “down”).
Sourcepub async fn mouse_move(
&self,
sx: i32,
sy: i32,
token: &CancellationToken,
) -> Result<()>
pub async fn mouse_move( &self, sx: i32, sy: i32, token: &CancellationToken, ) -> Result<()>
Move the mouse cursor to SCREEN coords (already scaled).
Sourcepub async fn list_windows(
&self,
_token: &CancellationToken,
) -> Result<Vec<String>>
pub async fn list_windows( &self, _token: &CancellationToken, ) -> Result<Vec<String>>
List visible window titles. X11 only; Wayland has no portable enumeration primitive.
Auto Trait Implementations§
impl !Freeze for ComputerUseDriver
impl RefUnwindSafe for ComputerUseDriver
impl Send for ComputerUseDriver
impl Sync for ComputerUseDriver
impl Unpin for ComputerUseDriver
impl UnsafeUnpin for ComputerUseDriver
impl UnwindSafe for ComputerUseDriver
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more