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//! [`ComputerUseToolset`] runs Claude's computer use toolset as governed tools over an
8//! [`adk_core::ComputerActuator`] the application supplies; every action passes through the
9//! governed tool path. [`McpComputerActuator`] is such an actuator for a desktop: it acts
10//! through the plain tools (`screenshot`, `click`, `type`, ...) of a running
11//! `computer-use-mcp` server.
12//!
13//! This crate **does not** perform desktop actuation. Desktop policy, target
14//! validation, lease ownership, physical-user interruption, and idempotent
15//! effects remain authoritative in `computer-use-mcp`. Instead, this crate
16//! supplies the governed ADK-side layer that drives that server safely:
17//!
18//! - **Wire contracts** ([`contracts`]) — camelCase wire types with disclosure-safe
19//! validation (digest-only postconditions, value-free sensitivity evidence,
20//! bounded approval scopes).
21//! - **Authorization** ([`ScopeAuthorizer`], [`ComputerUseAuthContext`]) — a coarse
22//! `computer:*` scope gate bound to an [`adk_auth`]-verified identity that
23//! model or graph state cannot forge.
24//! - **Deterministic workflow** ([`build_reference_graph`]) — an [`adk_graph`]
25//! graph that fans observation out in parallel, previews before mutation,
26//! interrupts for digest-bound approval, executes exactly once, and verifies
27//! the receipt.
28//! - **Runtime boundary** ([`ComputerUseRuntime`]) — the trait the graph drives,
29//! with a live MCP adapter ([`ComputerUseMcpRuntime`]) or an in-process fake.
30//! - **Cancellation** ([`CancellationBridge`]) — revokes desktop authority
31//! before stopping ADK reasoning.
32//! - **Release evaluation** ([`ComputerUseEvaluator`], [`AdkEvaluationReceipt`]) —
33//! deterministic trajectory scoring and a tamper-evident evidence receipt.
34//!
35//! ## Quick start
36//!
37//! The graph is driven through the [`ComputerUseRuntime`] trait, so it can run
38//! against an in-process implementation with no external server. See the
39//! `minimal_graph` example for a complete, runnable version:
40//!
41//! ```no_run
42//! use std::sync::Arc;
43//! use adk_computer_use::{build_reference_graph, ScopeAuthorizer};
44//! # use adk_computer_use::ComputerUseRuntime;
45//! # fn build(runtime: Arc<dyn ComputerUseRuntime>) -> Result<(), adk_graph::GraphError> {
46//! let authorizer = Arc::new(ScopeAuthorizer::new(["computer:plan", "computer:execute:background"]));
47//! let graph = build_reference_graph(runtime, authorizer)?;
48//! # let _ = graph;
49//! # Ok(())
50//! # }
51//! ```
52//!
53//! [`ComputerUseMcpRuntime`] calls governed tools (`preview_action`, `execute_action`,
54//! control leases, target reservations, `emergency_stop`) that no released
55//! `computer-use-mcp` serves. To act on a real desktop through that server, give
56//! [`ComputerUseToolset`] an [`McpComputerActuator`].
57//!
58//! ## Stability
59//!
60//! Beta — tracks the `computer-use-mcp` wire contracts, which are not yet versioned. See
61//! [STABILITY.md](https://github.com/zavora-ai/adk-rust/blob/main/STABILITY.md).
62
63/// A [`adk_core::ComputerActuator`] over the plain tools of a `computer-use-mcp` server.
64pub mod actuator;
65mod auth;
66mod cancellation;
67pub mod contracts;
68mod error;
69mod eval;
70mod graph;
71/// Runtime adapters and response binding.
72pub mod runtime;
73/// Claude's computer use toolset as governed tools over a [`adk_core::ComputerActuator`].
74pub mod toolset;
75
76pub use actuator::{McpComputerActuator, McpComputerActuatorBuilder};
77pub use auth::{AuthorizationError, ComputerUseAuthContext, ScopeAuthorizer};
78pub use cancellation::{AgentInterrupter, CancellationBridge, CancellationError};
79pub use error::{ComputerUseError, Result};
80pub use eval::{
81 AdkEvaluationClaims, AdkEvaluationReceipt, AdkEvaluationSource, ComputerUseEvaluation,
82 ComputerUseEvaluator,
83};
84pub use graph::{build_reference_graph, build_reference_graph_with_checkpointer};
85pub use runtime::{
86 ComputerUseMcpConfig, ComputerUseMcpRuntime, ComputerUseRuntime, TraceCorrelation,
87 VerificationOutcome,
88};
89pub use toolset::{
90 COMPUTER_BATCH_HALT_TEXT, COMPUTER_TOOLSET, ComputerUseMember, ComputerUseToolset,
91};
92
93// Wire contracts are re-exported at the crate root for ergonomic access.
94pub use contracts::{
95 ActionClass, ActionEnvelope, ActionPostcondition, ActionPreview, ActionProvenance,
96 ActionResourceContext, ApprovalGrant, ApprovalGrantScope, Bounds, ControlLease,
97 CoordinateSpace, ExecutionCapability, ExecutionMode, ExecutionReceipt, LeaseBoundaries,
98 PolicyDecision, PostconditionEvidence, ReceiptStatus, RuntimeSession, SafetyCorpus,
99 SafetyExpectation, SafetyScenario, SessionCompletionEvidence, SessionDeletionResult,
100 SessionEvent, SessionFollowUp, SessionFollowUpPage, TargetEvidence, TargetReservation,
101 TargetReservationScope, TargetSensitivityAssessment, TargetSensitivityEvidence,
102 TargetSensitivitySignal, TargetSensitivitySource,
103};