Skip to main content

ComputerUseRuntime

Trait ComputerUseRuntime 

Source
pub trait ComputerUseRuntime: Send + Sync {
    // Required methods
    fn discover_capabilities<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn observe_visual<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn observe_semantic<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn preview_action<'life0, 'async_trait>(
        &'life0 self,
        proposed_action: Value,
    ) -> Pin<Box<dyn Future<Output = Result<ActionPreview, ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn acquire_lease<'life0, 'life1, 'async_trait>(
        &'life0 self,
        envelope: &'life1 ActionEnvelope,
    ) -> Pin<Box<dyn Future<Output = Result<ControlLease, ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn execute_action<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        envelope: &'life1 ActionEnvelope,
        lease: &'life2 ControlLease,
        approval_grant_id: Option<&'life3 str>,
    ) -> Pin<Box<dyn Future<Output = Result<ExecutionReceipt, ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             Self: 'async_trait;
    fn verify<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        receipt: &'life1 ExecutionReceipt,
        postcondition: Option<&'life2 ActionPostcondition>,
    ) -> Pin<Box<dyn Future<Output = Result<VerificationOutcome, ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn reserve_target<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _envelope: &'life1 ActionEnvelope,
    ) -> Pin<Box<dyn Future<Output = Result<Option<TargetReservation>, ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn release_target<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _reservation: &'life1 TargetReservation,
    ) -> Pin<Box<dyn Future<Output = Result<(), ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn pause_session<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _session_id: &'life1 str,
        _reason: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait { ... }
    fn stop_session<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _session_id: &'life1 str,
        _reason: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait { ... }
    fn emergency_stop<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _reason: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), ComputerUseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Available on crate feature computer-use only.
Expand description

Runtime boundary implemented by the computer-use MCP server or an in-process adapter.

The crate::build_reference_graph workflow drives this trait in a fixed, safe order: parallel observation (discover_capabilities, observe_visual, observe_semantic), then preview_action, optional reserve_target, acquire_lease, exactly one execute_action, verify, and release_target.

The reference graph validates leases, reservations, receipts, envelope expiry, and approval bindings independently of the implementation. After a reservation is accepted, it calls release_target on every later success or error path.

Implementations must treat the runtime (not graph or model state) as authoritative for policy, identity, lease ownership, exact preview binding, and idempotency. Implementations that expose these methods outside the reference graph must enforce the same invariants at that direct-call boundary.

§Errors

Every method returns ComputerUseError. Transport faults map to ComputerUseError::Mcp, payload decoding failures to ComputerUseError::Decode, and identity checks to ComputerUseError::IdentityMismatch. The cancellation control methods default to ComputerUseError::Unsupported so adapters can opt in.

Required Methods§

Source

fn discover_capabilities<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Value, ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Enumerate the execution capabilities available for the target.

Source

fn observe_visual<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Value, ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Capture a fresh visual (screenshot/annotation) observation frame.

Source

fn observe_semantic<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Value, ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Capture a fresh semantic (accessibility/window-tree) observation frame.

Source

fn preview_action<'life0, 'async_trait>( &'life0 self, proposed_action: Value, ) -> Pin<Box<dyn Future<Output = Result<ActionPreview, ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Preview a proposed action, returning the runtime-bound envelope, policy, and route.

Source

fn acquire_lease<'life0, 'life1, 'async_trait>( &'life0 self, envelope: &'life1 ActionEnvelope, ) -> Pin<Box<dyn Future<Output = Result<ControlLease, ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Acquire the one-writer control lease required before any mutation.

Source

fn execute_action<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, envelope: &'life1 ActionEnvelope, lease: &'life2 ControlLease, approval_grant_id: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = Result<ExecutionReceipt, ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Execute the previewed action exactly once under the supplied lease.

Source

fn verify<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, receipt: &'life1 ExecutionReceipt, postcondition: Option<&'life2 ActionPostcondition>, ) -> Pin<Box<dyn Future<Output = Result<VerificationOutcome, ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Report whether the action’s postcondition was independently observed to hold.

A committed receipt is an acknowledgement that the runtime accepted and performed the action. It is not evidence that the intended effect occurred, so the two are reported separately: see VerificationOutcome.

postcondition is the envelope’s declared expected state, or None when the action declared none — in which case there is nothing to verify and the honest answer is VerificationOutcome::CommittedUnverified.

Provided Methods§

Source

fn reserve_target<'life0, 'life1, 'async_trait>( &'life0 self, _envelope: &'life1 ActionEnvelope, ) -> Pin<Box<dyn Future<Output = Result<Option<TargetReservation>, ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Reserve a non-authoritative planner intent for multi-agent conflict checks.

Returns Ok(None) when the adapter does not model reservations.

Source

fn release_target<'life0, 'life1, 'async_trait>( &'life0 self, _reservation: &'life1 TargetReservation, ) -> Pin<Box<dyn Future<Output = Result<(), ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Release a previously acquired TargetReservation.

The graph reports cleanup failures, including when another operation already failed, so implementations should return an error instead of hiding an uncertain release.

Source

fn pause_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _session_id: &'life1 str, _reason: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Pause the session’s desktop authority. Defaults to unsupported.

Source

fn stop_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _session_id: &'life1 str, _reason: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Stop the session’s desktop authority. Defaults to unsupported.

Source

fn emergency_stop<'life0, 'life1, 'async_trait>( &'life0 self, _reason: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), ComputerUseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Revoke all desktop authority immediately. Defaults to unsupported.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§