Skip to content

Computer use CLI for AI agents

chore: remove unused execute_by_ref::execute wrapper and DEFAULT_ACTION_TIMEOUT_MS

detail-app[bot]37dada0efdfb
diff --git a/crates/core/src/commands/execute_by_ref.rs b/crates/core/src/commands/execute_by_ref.rs
index 3893859ed..14b9ff7e4 100644
--- a/crates/core/src/commands/execute_by_ref.rs
+++ b/crates/core/src/commands/execute_by_ref.rs
@@ -9,12 +9,9 @@ use crate::{
};
use serde_json::Value;
-pub const DEFAULT_ACTION_TIMEOUT_MS: u64 = 5000;
-
-/// Config struct bundling the caller-supplied inputs to `execute` /
-/// `execute_with_timeout`, keeping both functions within the 5-parameter
-/// limit (mirrors the `RefArgs`/`ActionRequest` config-struct pattern used
-/// elsewhere in this module).
+/// Config struct bundling the caller-supplied inputs to `execute_with_timeout`,
+/// keeping it within the 5-parameter limit (mirrors the `RefArgs`/
+/// `ActionRequest` config-struct pattern used elsewhere in this module).
pub struct ExecuteByRefArgs<'a> {
pub ref_id: &'a str,
pub snapshot_id: Option<&'a str>,
@@ -34,14 +31,6 @@ pub struct ExecuteByRefArgs<'a> {
/// action's base policy. Semantic actions, including `TypeText`, are strict
/// headless; explicit `PressKey` permits focus without cursor movement. FFI
/// callers may opt in to `focus_fallback` or `headed`.
-pub fn execute(
- args: ExecuteByRefArgs<'_>,
- adapter: &dyn PlatformAdapter,
- context: &CommandContext,
-) -> Result<Value, AppError> {
- execute_with_timeout(args, DEFAULT_ACTION_TIMEOUT_MS, adapter, context)
-}
-
pub fn execute_with_timeout(
args: ExecuteByRefArgs<'_>,
timeout_ms: u64,
diff --git a/crates/core/src/commands/execute_by_ref_tests.rs b/crates/core/src/commands/execute_by_ref_tests.rs
index 45773daf1..a3cd8b0de 100644
--- a/crates/core/src/commands/execute_by_ref_tests.rs
+++ b/crates/core/src/commands/execute_by_ref_tests.rs
@@ -162,38 +162,6 @@ impl SystemOps for PolicyCaptureAdapter {
crate::adapter::exact_window_focus!();
}
-#[test]
-fn default_action_timeout_ms_is_five_seconds() {
- assert_eq!(DEFAULT_ACTION_TIMEOUT_MS, 5000);
-}
-
-/// `execute` must forward `DEFAULT_ACTION_TIMEOUT_MS` (not `None` or `0`) into
-/// the ref-action retry budget, exactly as a direct
-/// `execute_with_timeout(args, DEFAULT_ACTION_TIMEOUT_MS, ..)` call would.
-/// A transient `STALE_REF` that clears within the budget must therefore be
-/// retried until it resolves rather than surfacing on the first attempt.
-#[test]
-fn execute_forwards_default_timeout_and_retries_transient_stale_ref() {
- let _guard = HomeGuard::new();
- let snapshot_id = snapshot_with_ref("textfield", &["Click"]);
- let adapter = StaleThenOkAdapter::new(2);
-
- let value = execute(
- ExecuteByRefArgs {
- ref_id: "@e1",
- snapshot_id: Some(&snapshot_id),
- action: Action::Click,
- caller_policy: InteractionPolicy::headless(),
- },
- &adapter,
- &CommandContext::default(),
- )
- .unwrap();
-
- assert_eq!(value["action"], "click");
- assert!(adapter.resolve_calls.load(Ordering::SeqCst) >= 3);
-}
-
/// `execute_with_timeout` must run `normalize_action_timeout_ms` on the raw
/// timeout it is given, so a `0` (the CLI's "no retry budget" sentinel)
/// collapses to `None` and the ref-action pipeline makes exactly one resolve
@@ -227,7 +195,7 @@ fn explicit_press_key_keeps_its_focus_fallback_policy() {
let snapshot_id = snapshot_with_ref("textfield", &["PressKey"]);
let adapter = PolicyCaptureAdapter::new();
- execute(
+ execute_with_timeout(
ExecuteByRefArgs {
ref_id: "@e1",
snapshot_id: Some(&snapshot_id),
@@ -237,6 +205,7 @@ fn explicit_press_key_keeps_its_focus_fallback_policy() {
}),
caller_policy: InteractionPolicy::headless(),
},
+ 5000,
&adapter,
&CommandContext::default(),
)
@@ -254,13 +223,14 @@ fn effective_policy_honors_caller_policy_above_action_base() {
let snapshot_id = snapshot_with_ref("textfield", &["SetValue"]);
let adapter = PolicyCaptureAdapter::new();
- execute(
+ execute_with_timeout(
ExecuteByRefArgs {
ref_id: "@e1",
snapshot_id: Some(&snapshot_id),
action: Action::SetValue("value".into()),
caller_policy: InteractionPolicy::headed(),
},
+ 5000,
&adapter,
&CommandContext::default(),
)
diff --git a/crates/ffi/src/commands/execute_by_ref.rs b/crates/ffi/src/commands/execute_by_ref.rs
index b56e8b8f6..122c4471d 100644
--- a/crates/ffi/src/commands/execute_by_ref.rs
+++ b/crates/ffi/src/commands/execute_by_ref.rs
@@ -12,7 +12,7 @@ use std::ffi::c_char;
/// Policy: semantic actions, including `TypeText`, default to strict
/// `headless`. Explicit `PressKey` defaults to `focus_fallback`. A policy
/// discriminant may elevate to focus fallback or headed. Base and elevation
-/// are computed by `agent_desktop_core::commands::execute_by_ref::execute` via
+/// are computed by `agent_desktop_core::commands::execute_by_ref::execute_with_timeout` via
/// `Action::base_interaction_policy` + `InteractionPolicy::join`, so CLI and
/// FFI share a single source of policy truth.
///
@@ -29,7 +29,7 @@ use std::ffi::c_char;
/// focus without cursor movement. `Headed (2)` opts in to physical cursor and
/// keyboard delivery.
///
-/// Uses a fixed 5000ms auto-wait budget (`DEFAULT_ACTION_TIMEOUT_MS`) before
+/// Uses a fixed 5000ms auto-wait budget before
/// the actionability preflight, matching the CLI default. Call
/// `ad_execute_by_ref_timeout` with an explicit `timeout_ms` (-1 = default,
/// 0 = single-shot with no auto-wait) to control this.