Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): delete zero-caller API in cua-driver-core and cua-driver (#5815)

injaneity424742b125ef
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/agent_cursor.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/agent_cursor.rs
index b63ad91b51..eb88003ecc 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/agent_cursor.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/agent_cursor.rs
@@ -222,10 +222,6 @@ impl AgentCursorVisibility {
}
}
- pub fn is_ended(&self) -> bool {
- self.ended
- }
-
/// Current opacity multiplier, 0 to 1.
pub fn alpha(&self, idle_hide_ms: f64) -> f64 {
if self.ended {
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/browser/engine.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/browser/engine.rs
index 1d0940c17b..3b3e0d2ba4 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/browser/engine.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/browser/engine.rs
@@ -247,10 +247,7 @@ fn endpoint_access_class(
}
}
-/// Everything revalidation proves before a mutation proceeds. The
-/// `record`/`tab` evidence rides along for future callers even though
-/// the v1 tools only need the attached connection.
-#[allow(dead_code)]
+/// Everything revalidation proves before a mutation proceeds.
pub(crate) struct ValidatedTab {
pub conn: Arc<CdpConnection>,
pub record: TargetRecord,
@@ -621,8 +618,6 @@ pub(crate) enum FrameTreeError {
pub(crate) struct AttachedChildFrame {
pub session_id: String,
pub target_id: String,
- #[allow(dead_code)]
- pub url: String,
}
pub(crate) enum AttachError {
@@ -657,19 +652,6 @@ impl BrowserEngine {
)
}
- /// Create an engine using the runtime-owned broker shared by every
- /// protected resource adapter.
- pub fn new_with_approval_broker(
- platform: Arc<dyn BrowserPlatform>,
- approval_broker: Arc<crate::consent::ApprovalBroker>,
- ) -> Arc<Self> {
- Self::new_with_runtime_services(
- platform,
- approval_broker,
- Arc::new(crate::consent::ProtectedResourceOwnershipStore::default()),
- )
- }
-
pub fn new_with_runtime_services(
platform: Arc<dyn BrowserPlatform>,
approval_broker: Arc<crate::consent::ApprovalBroker>,
@@ -1875,7 +1857,6 @@ impl BrowserEngine {
out.push(AttachedChildFrame {
session_id: session_id.to_owned(),
target_id: target_id.to_owned(),
- url: info["url"].as_str().unwrap_or("").to_owned(),
});
}
Ok(out)
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/recording.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/recording.rs
index 90e027aadc..f8f78ee698 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/recording.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/recording.rs
@@ -488,7 +488,7 @@ struct RecordingInner {
/// NOT stop B's recording. The proxy-exit `session_end` hook passes its
/// own session id to `stop_owner()`, which no-ops when the live owner has
/// moved on. `None` means the recording was started anonymously (CLI
- /// one-shot / legacy `configure()` shim) and is owned by nobody — only an
+ /// one-shot) and is owned by nobody — only an
/// unconditional `stop_owner(None)` can tear it down. Supersedes the
/// #1775 generation token: a session id is a stable owner identity rather
/// than a monotonic counter, and it doubles as the config-override key.
@@ -535,7 +535,7 @@ pub struct RecordingState {
pub last_video_path: Option<String>,
/// Session id that owns the current (or most recent) recording, stamped on
/// `start()` from the daemon-injected `_session_id`. `None` for an
- /// anonymously-started recording (CLI one-shot / legacy shim). Surfaced so
+ /// anonymously-started recording (CLI one-shot). Surfaced so
/// callers can see who owns the live recording; the proxy-exit teardown
/// drives ownership via `session_end` (it already knows its own id) rather
/// than reading this back.
@@ -583,15 +583,13 @@ impl RecordingSession {
/// for the lifetime of the session. NOTE: the MCP `start_recording` tool
/// now defaults `record_video` to *false* (opt-in) — see
/// `recording_tools.rs` — so video only records when explicitly requested.
- /// The legacy CLI `recording start` path via `configure()` still forces
- /// video on. If ffmpeg isn't on PATH the start still succeeds —
+ /// If ffmpeg isn't on PATH the start still succeeds —
/// the per-turn capture (action.json + pre/post evidence) is independent
/// of video — but the structured state carries the ffmpeg error so
/// the caller can surface it.
///
/// `owner` stamps the session that owns this recording (the daemon-injected
- /// `_session_id`). `None` marks an anonymous start (CLI one-shot / legacy
- /// `configure()` shim) owned by nobody. See `stop_owner()` for how this
+ /// `_session_id`). `None` marks an anonymous start (CLI one-shot) owned by nobody. See `stop_owner()` for how this
/// gates teardown.
pub fn start(
&self,
@@ -626,8 +624,7 @@ impl RecordingSession {
// teardown sites call `fire_session_end` (which marks ENDED_SESSIONS)
// BEFORE `stop_owner`, so either the mark is already set and we bail
// here, or we win the lock first and the reaper's later stop_owner(owner)
- // reaps what we started. Anonymous starts (owner = None: CLI one-shot /
- // legacy shim) are never gated.
+ // reaps what we started. Anonymous starts (owner = None: CLI one-shot) are never gated.
if let Some(o) = owner {
if crate::session::is_session_ended(o) {
anyhow::bail!(
@@ -648,7 +645,7 @@ impl RecordingSession {
std::fs::create_dir_all(&dir)?;
// Single monotonic anchor shared by video, cursor sampler, and
- // per-turn `t_ms_from_session_start` math in `record()` — so all
+ // per-turn `t_ms_from_session_start` math in `finish_turn()` — so all
// three timelines line up at the millisecond.
let monotonic_start = Instant::now();
@@ -725,9 +722,8 @@ impl RecordingSession {
///
/// `requester` is the ownership guard for session-driven teardown
/// (`session_end` / proxy-exit). Semantics:
- /// - `None` — unconditional stop. Manual `stop_recording`, the legacy
- /// `configure()` shim, the CLI one-shot path, and the idle-TTL backstop
- /// all pass `None` to preserve today's manual-stop behavior.
+ /// - `None` — unconditional stop. Manual `stop_recording`, the CLI
+ /// one-shot path, and the idle-TTL backstop all pass `None` to preserve today's manual-stop behavior.
/// - `Some(sid)` where `sid` owns the live recording — stop + clear owner.
/// - `Some(sid)` where `sid` does NOT own it (a disconnecting session
/// whose recording was already clobbered by a newer `start()`, or which
@@ -800,21 +796,6 @@ impl RecordingSession {
Ok(())
}
- /// Legacy toggle API kept as a thin shim over `start()`/`stop()` so
- /// existing callers (CLI subcommand, tests) keep compiling during the
- /// rename window. Forces `record_video` on for this legacy CLI path — the
- /// MCP `start_recording` tool now defaults video OFF (see
- /// `recording_tools.rs`), but the CLI `recording start` keeps video on.
- pub fn configure(&self, enabled: bool, output_dir: Option<&str>) -> anyhow::Result<()> {
- if !enabled {
- return self.stop_owner(None);
- }
- let dir = output_dir
- .ok_or_else(|| anyhow::anyhow!("output_dir is required when enabling recording"))?;
- // Legacy CLI path: anonymous owner (no MCP session id available here).
- self.start(dir, true, None)
- }
-
/// Return a snapshot of the current state (non-blocking).
pub fn current_state(&self) -> RecordingState {
let inner = self.inner.lock().unwrap();
@@ -1049,23 +1030,6 @@ impl RecordingSession {
inner.last_error = Some(error.to_string());
}
}
-
- /// Compatibility helper for callers that only report completed calls.
- /// New dispatch paths should use `begin_turn` and `finish_turn` so the
- /// before phase is captured before the action changes application state.
- pub fn record(
- &self,
- tool_name: &str,
- args: &Value,
- result_text: &str,
- start_ms: u64,
- caller: RecordingCaller<'_>,
- ) {
- let Some(pending) = self.begin_turn(tool_name, args, start_ms, caller) else {
- return;
- };
- self.finish_turn(pending, result_text);
- }
}
impl Default for RecordingSession {
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/recording_zoom.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/recording_zoom.rs
index e2f289cd5d..34a0d3620e 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/recording_zoom.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/recording_zoom.rs
@@ -335,83 +335,6 @@ pub fn position_at(t_ms: f64, samples: &[CursorSample]) -> Option<(f64, f64)> {
// ── ActionSpan (ActionSpan.swift) ────────────────────────────────────────────
-/// Pad raw action spans by ±`ACTION_PAD_MS` and merge overlapping spans.
-/// Merged spans accumulate per-action focus waypoints for smooth pan.
-pub fn generate_action_spans(raw: &[ActionSpan]) -> Vec<ActionSpan> {
- let mut padded: Vec<ActionSpan> = raw
- .iter()
- .map(|s| ActionSpan {
- start_ms: (s.start_ms - defaults::ACTION_PAD_MS).max(0.0),
- end_ms: s.end_ms + defaults::ACTION_PAD_MS,
- window_bounds: s.window_bounds,
- click_point: s.click_point,
- focus_waypoints: None,
- })
- .collect();
- padded.sort_by(|a, b| {
- a.start_ms
- .partial_cmp(&b.start_ms)
- .unwrap_or(std::cmp::Ordering::Equal)
- });
-
- let mut result: Vec<ActionSpan> = Vec::new();
- for span in padded {
- let should_merge = result
- .last()
- .map(|last| span.start_ms <= last.end_ms + defaults::ACTION_MERGE_GAP_MS)
- .unwrap_or(false);
-
- if should_merge {
- let last_idx = result.len() - 1;
- let last = &mut result[last_idx];
- let last_mid = (last.start_ms + last.end_ms) / 2.0;
- let span_mid = (span.start_ms + span.end_ms) / 2.0;
- let mut waypoints = last.focus_waypoints.clone().unwrap_or_default();
- if waypoints.is_empty() {
- if let Some((lx, ly)) = focus_for_span(last) {
- waypoints.push(FocusWaypoint {
- t_ms: last_mid,
- x: lx,
- y: ly,
- });
- }
- }
- if let Some((sx, sy)) = focus_for_span(&span) {
- waypoints.push(FocusWaypoint {
- t_ms: span_mid,
- x: sx,
- y: sy,
- });
- }
- last.end_ms = last.end_ms.max(span.end_ms);
- if last.window_bounds.is_none() {
- last.window_bounds = span.window_bounds;
- }
- if last.click_point.is_none() {
- last.click_point = span.click_point;
- }
- last.focus_waypoints = if waypoints.is_empty() {
- None
- } else {
- Some(waypoints)
- };
- } else {
- result.push(span);
- }
- }
- result
-}
-
-fn focus_for_span(span: &ActionSpan) -> Option<(f64, f64)> {
- if let Some(cp) = span.click_point {
- return Some(cp);
- }
- if let Some(wb) = span.window_bounds {
- return Some((wb.x + wb.width / 2.0, wb.y + wb.height / 2.0));
- }
- None
-}
-
/// Piecewise-linear PTS remap: spans play at 1× speed, gaps at
/// `ACTION_FAST_SPEED`×. Monotonically increasing.
pub fn map_pts(input_ms: f64, spans: &[ActionSpan]) -> f64 {
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/server.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/server.rs
index 09007a5540..f32ec637bb 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/server.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/server.rs
@@ -611,31 +611,6 @@ pub fn tool_observation_timer(
))
}
-/// Build a private aggregate-session context from a valid, known tool call.
-/// Only the public `session` argument is considered; reserved fallback keys
-/// and all other arguments remain outside the observer seam.
-pub fn session_tool_context(
- req: &Request,
- is_known_tool: impl Fn(&str) -> bool,
- transport: crate::session::SessionTransport,
-) -> Option<crate::session::SessionToolContext> {
- if req.method != "tools/call" {
- return None;
- }
- let call = req.tool_call().ok()?;
- let known_tool = call.name == "type_text_chars"
- || crate::tool::renamed_tool(&call.name).is_some()
- || is_known_tool(&call.name);
- let client_kind = match transport {
- crate::session::SessionTransport::Cli => crate::session::SessionClientKind::Cli,
- crate::session::SessionTransport::Daemon => crate::session::SessionClientKind::Direct,
- crate::session::SessionTransport::McpStdio | crate::session::SessionTransport::McpHttp => {
- crate::session::SessionClientKind::Mcp
- }
- };
- crate::session::begin_tool_call(&call.name, &call.args, known_tool, transport, client_kind)
-}
-
fn notify_session_started(metadata: InitializeMetadata) {
if let Some(observer) = STDIO_OBSERVER.get() {
observer.on_session_started(metadata);
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/session.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/session.rs
index 7acb98101f..d937d73c20 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/session.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/session.rs
@@ -1138,22 +1138,6 @@ impl Drop for SessionReviveHookRegistration {
}
}
-/// Notify session-owned subsystems after `start_session` has successfully
-/// revived and rebound a recycled id. Unlike [`revive_session`], this does not
-/// alter core lifecycle state; it fans the completed transition out to
-/// platform-owned tombstones.
-pub fn fire_session_revive(session_id: &str) {
- let owner = lifecycle_records()
- .lock()
- .unwrap()
- .get(session_id)
- .map(|record| record.owner_transport.clone());
- if let Some(owner) = owner {
- let _ = fire_session_revive_for_owner(session_id, &owner);
- }
-}
-
-/// Notify render-side owners only while the revived episode is still live and
/// owned by the same transport. Holding the tombstone lock across callbacks
/// orders a racing end after revival, so its cleanup cannot be followed by a
/// late overlay resurrection.
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs
index febdade5df..f2e6151f05 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs
@@ -123,10 +123,6 @@ impl SessionModeCeiling {
&& (mode != PermissionMode::Unrestricted || self.unrestricted_acknowledged)
}
- pub fn delegation_enabled(&self) -> bool {
- self.delegation_enabled
- }
-
pub fn allowed_mode_names(&self) -> Vec<&'static str> {
let mut modes = [
PermissionMode::Standard,
@@ -218,24 +214,16 @@ impl EffectiveAuthorizationContext {
self.source
}
- pub fn bounded_manifest(&self) -> Option<&SessionManifest> {
- self.capability_manifest.as_deref()
- }
-
pub fn capability_manifest(&self) -> Option<&SessionManifest> {
self.capability_manifest.as_deref()
}
- pub fn bounded_manifest_sha256(&self) -> Option<&str> {
+ pub fn capability_manifest_sha256(&self) -> Option<&str> {
self.capability_manifest
.as_deref()
.map(SessionManifest::sha256)
}
- pub fn capability_manifest_sha256(&self) -> Option<&str> {
- self.bounded_manifest_sha256()
- }
-
pub fn public_session(&self) -> Option<&str> {
self.public_session.as_deref()
}
@@ -335,11 +323,6 @@ impl EffectiveAuthorizationContext {
}
Ok(())
}
-
- /// Compatibility alias for callers that commit a fully admitted dispatch.
- pub fn authorize_dispatch(&self) -> Result<(), String> {
- self.commit_authorized_dispatch()
- }
}
pub struct DelegatedSessionRequest {
@@ -438,9 +421,6 @@ pub enum SessionAuthorizationError {
InvalidTtl,
#[error("bounded mode requires an immutable capability manifest")]
MissingBoundedManifest,
- #[deprecated(note = "capability manifests are now valid in every permission profile")]
- #[error("the capability manifest is unexpected")]
- UnexpectedBoundedManifest,
#[error("the capability manifest is invalid for the selected permission mode")]
InvalidManifest,
}
@@ -1121,7 +1101,7 @@ mod tests {
.unwrap();
std::thread::sleep(Duration::from_millis(3));
assert!(context.is_expired());
- assert!(context.authorize_dispatch().is_err());
+ assert!(context.commit_authorized_dispatch().is_err());
assert_eq!(
registry.status_json()["delegated_session_counts"]["standard"],
0
@@ -1286,7 +1266,7 @@ mod tests {
.unwrap();
assert!(registry.revoke_connection(&connection));
- assert!(context.authorize_dispatch().is_err());
+ assert!(context.commit_authorized_dispatch().is_err());
assert!(context.is_expired());
}
@@ -1314,8 +1294,8 @@ mod tests {
.unwrap();
assert_eq!(registry.revoke_all(), 2);
- assert!(context_a.authorize_dispatch().is_err());
- assert!(context_b.authorize_dispatch().is_err());
+ assert!(context_a.commit_authorized_dispatch().is_err());
+ assert!(context_b.commit_authorized_dispatch().is_err());
assert_eq!(registry.revoke_all(), 0);
}
diff --git a/libs/cua-driver/rust/crates/cua-driver/src/bundle.rs b/libs/cua-driver/rust/crates/cua-driver/src/bundle.rs
index d3d0fb47e2..3acc584956 100644
--- a/libs/cua-driver/rust/crates/cua-driver/src/bundle.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/src/bundle.rs
@@ -59,15 +59,6 @@ pub fn user_home_subdirectory() -> &'static str {
}
}
-#[cfg(target_os = "windows")]
-pub fn uia_executable_name() -> &'static str {
- if is_local_installation() {
- "cua-driver-uia-local.exe"
- } else {
- "cua-driver-uia.exe"
- }
-}
-
#[cfg(target_os = "windows")]
pub fn autostart_task_name() -> &'static str {
if is_local_installation() {
diff --git a/libs/cua-driver/rust/crates/cua-driver/src/mcp_http.rs b/libs/cua-driver/rust/crates/cua-driver/src/mcp_http.rs
index 414b3e2366..2a3f941fac 100644
--- a/libs/cua-driver/rust/crates/cua-driver/src/mcp_http.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/src/mcp_http.rs
@@ -276,8 +276,6 @@ fn apply_session_identity(req: &mut Request, transport_session: &str) {
/// One parsed HTTP/1.1 request.
struct HttpRequest {
method: String,
- #[allow(dead_code)]
- path: String,
body: Vec<u8>,
/// Browser requests carry Origin; native MCP clients normally do not.
has_origin: bool,
@@ -314,8 +312,7 @@ async fn read_http_request(
let request_line = lines.next().unwrap_or("");
let mut parts = request_line.split_whitespace();
let method = parts.next().unwrap_or("").to_owned();
- let path = parts.next().unwrap_or("/").to_owned();
- let version = parts.next().unwrap_or("HTTP/1.1");
+ let version = parts.nth(1).unwrap_or("HTTP/1.1");
let mut content_length = 0usize;
let mut has_origin = false;
let mut keep_alive = version.eq_ignore_ascii_case("HTTP/1.1"); // 1.1 defaults to keep-alive
@@ -355,7 +352,6 @@ async fn read_http_request(
}
Ok(Some(HttpRequest {
method,
- path,
body,
has_origin,
keep_alive,
@@ -459,6 +455,35 @@ mod tests {
String::from_utf8(response).unwrap()
}
+ async fn parse_request(request: &str) -> (String, bool) {
+ let listener = TcpListener::bind(("127.0.0.1", 0)).await.unwrap();
+ let addr = listener.local_addr().unwrap();
+ let mut client = TcpStream::connect(addr).await.unwrap();
+ let (mut server, _) = listener.accept().await.unwrap();
+ client.write_all(request.as_bytes()).await.unwrap();
+ let req = read_http_request(&mut server, "token")
+ .await
+ .unwrap()
+ .unwrap();
+ (req.method, req.keep_alive)
+ }
+
+ #[tokio::test]
+ async fn keep_alive_follows_http_version_and_connection_header() {
+ for (request, expected) in [
+ ("POST /mcp HTTP/1.1\r\n\r\n", true),
+ ("POST /mcp HTTP/1.0\r\n\r\n", false),
+ ("POST /mcp HTTP/1.1\r\nConnection: close\r\n\r\n", false),
+ ("POST /mcp HTTP/1.0\r\nConnection: keep-alive\r\n\r\n", true),
+ ] {
+ assert_eq!(
+ parse_request(request).await,
+ ("POST".to_owned(), expected),
+ "{request:?}"
+ );
+ }
+ }
+
#[tokio::test]
async fn origin_header_is_forbidden_but_originless_request_is_unchanged() {
let _runtime_guard = crate::test_runtime_lock().lock().await;
diff --git a/libs/cua-driver/rust/crates/cua-driver/src/serve.rs b/libs/cua-driver/rust/crates/cua-driver/src/serve.rs
index 919bfbc9e6..518df3518e 100644
--- a/libs/cua-driver/rust/crates/cua-driver/src/serve.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/src/serve.rs
@@ -339,21 +339,6 @@ pub fn default_socket_path() -> String {
socket_path_for_namespace(crate::bundle::state_namespace())
}
-/// On Windows, returns the reserved named-pipe path of the uiAccess-elevated
-/// worker (`cua-driver-uia.exe`). Public CLI, MCP, and SDK clients never connect
-/// to this endpoint. It remains available only for a future daemon-internal
-/// forwarding path that authenticates the exact parent process. Until that path
-/// exists, elevated/AppContainer pixel input uses an interactively launched
-/// High-IL daemon. See #1602 / the `cua-driver-uia` crate for the worker side.
-#[cfg(target_os = "windows")]
-pub fn default_uia_pipe_path() -> String {
- if crate::bundle::is_local_installation() {
- r"\\.\pipe\cua-driver-local-uia".to_owned()
- } else {
- r"\\.\pipe\cua-driver-uia".to_owned()
- }
-}
-
/// Returns the platform default PID file path.
pub fn default_pid_file_path() -> String {
let namespace = crate::bundle::state_namespace();