Skip to main content

adk_computer_use/
lib.rs

1//! # adk-computer-use
2//!
3//! First-party ADK-Rust orchestration and wire contracts for the
4//! [`computer-use-mcp`](https://github.com/zavora-ai/computer-use-mcp)
5//! desktop-automation server.
6//!
7//! This crate **does not** perform desktop actuation. Desktop policy, target
8//! validation, lease ownership, physical-user interruption, and idempotent
9//! effects remain authoritative in `computer-use-mcp`. Instead, this crate
10//! supplies the governed ADK-side layer that drives that server safely:
11//!
12//! - **Wire contracts** ([`contracts`]) — camelCase wire types with disclosure-safe
13//!   validation (digest-only postconditions, value-free sensitivity evidence,
14//!   bounded approval scopes).
15//! - **Authorization** ([`ScopeAuthorizer`], [`ComputerUseAuthContext`]) — a coarse
16//!   `computer:*` scope gate bound to an [`adk_auth`]-verified identity that
17//!   model or graph state cannot forge.
18//! - **Deterministic workflow** ([`build_reference_graph`]) — an [`adk_graph`]
19//!   graph that fans observation out in parallel, previews before mutation,
20//!   interrupts for digest-bound approval, executes exactly once, and verifies
21//!   the receipt.
22//! - **Runtime boundary** ([`ComputerUseRuntime`]) — the trait the graph drives,
23//!   with a live MCP adapter ([`ComputerUseMcpRuntime`]) or an in-process fake.
24//! - **Cancellation** ([`CancellationBridge`]) — revokes desktop authority
25//!   before stopping ADK reasoning.
26//! - **Release evaluation** ([`ComputerUseEvaluator`], [`AdkEvaluationReceipt`]) —
27//!   deterministic trajectory scoring and a tamper-evident evidence receipt.
28//!
29//! ## Quick start
30//!
31//! The graph is driven through the [`ComputerUseRuntime`] trait, so it can run
32//! against an in-process implementation with no external server. See the
33//! `minimal_graph` example for a complete, runnable version:
34//!
35//! ```no_run
36//! use std::sync::Arc;
37//! use adk_computer_use::{build_reference_graph, ScopeAuthorizer};
38//! # use adk_computer_use::ComputerUseRuntime;
39//! # fn build(runtime: Arc<dyn ComputerUseRuntime>) -> Result<(), adk_graph::GraphError> {
40//! let authorizer = Arc::new(ScopeAuthorizer::new(["computer:plan", "computer:execute:background"]));
41//! let graph = build_reference_graph(runtime, authorizer)?;
42//! # let _ = graph;
43//! # Ok(())
44//! # }
45//! ```
46//!
47//! To drive a real desktop, back the graph with [`ComputerUseMcpRuntime`] and a
48//! running `computer-use-mcp` server (see the macOS examples).
49
50mod auth;
51mod cancellation;
52pub mod contracts;
53mod error;
54mod eval;
55mod graph;
56/// Runtime adapters and response binding.
57pub mod runtime;
58
59pub use auth::{AuthorizationError, ComputerUseAuthContext, ScopeAuthorizer};
60pub use cancellation::{AgentInterrupter, CancellationBridge, CancellationError};
61pub use error::{ComputerUseError, Result};
62pub use eval::{
63    AdkEvaluationClaims, AdkEvaluationReceipt, AdkEvaluationSource, ComputerUseEvaluation,
64    ComputerUseEvaluator,
65};
66pub use graph::{build_reference_graph, build_reference_graph_with_checkpointer};
67pub use runtime::{
68    ComputerUseMcpConfig, ComputerUseMcpRuntime, ComputerUseRuntime, TraceCorrelation,
69    VerificationOutcome,
70};
71
72// Wire contracts are re-exported at the crate root for ergonomic access.
73pub use contracts::{
74    ActionClass, ActionEnvelope, ActionPostcondition, ActionPreview, ActionProvenance,
75    ActionResourceContext, ApprovalGrant, ApprovalGrantScope, Bounds, ControlLease,
76    ExecutionCapability, ExecutionMode, ExecutionReceipt, LeaseBoundaries, PolicyDecision,
77    PostconditionEvidence, ReceiptStatus, RuntimeSession, SafetyCorpus, SafetyExpectation,
78    SafetyScenario, SessionCompletionEvidence, SessionDeletionResult, SessionEvent,
79    SessionFollowUp, SessionFollowUpPage, TargetEvidence, TargetReservation,
80    TargetReservationScope, TargetSensitivityAssessment, TargetSensitivityEvidence,
81    TargetSensitivitySignal, TargetSensitivitySource,
82};