Skip to main content

ComputerUseDriver

Struct ComputerUseDriver 

Source
pub struct ComputerUseDriver { /* private fields */ }
Expand description

Shared driver all seven computer-use tools hold an Arc<> to.

Implementations§

Source§

impl ComputerUseDriver

Source

pub fn new(backend: Backend) -> Self

Source

pub fn backend(&self) -> Backend

Source

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.

Source

pub async fn ensure_alive_async(&self) -> Result<(), String>

Async form of [ensure_alive]. The X11 display probe spawns a xdpyinfo/xdotool subprocess and blocks on its exit; on the async tool path that would block a worker, so run it on the blocking pool (#34).

Source

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).

Source

pub fn register_screenshot( &self, scale_factor: f64, offset_x: i32, offset_y: i32, width: u32, height: u32, kind: String, ) -> u64

Allocate a fresh registry id and record metadata.

Source

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.

Source

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.

Source

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

Source

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".

Source

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.

Source

pub async fn press_key( &self, key: &str, token: &CancellationToken, ) -> Result<()>

Press a key (or key combination like "ctrl+shift+t").

Source

pub async fn scroll( &self, direction: &str, amount: i32, token: &CancellationToken, ) -> Result<()>

Scroll amount ticks in direction (“up” / “down”).

Source

pub async fn mouse_move( &self, sx: i32, sy: i32, token: &CancellationToken, ) -> Result<()>

Move the mouse cursor to SCREEN coords (already scaled).

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more