-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(agent): wire automate/ax_interact computer tools (3/8 of #3307) #3342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
M3gA-Mind
merged 7 commits into
tinyhumansai:main
from
M3gA-Mind:feat/voice-split-3-tool-wiring
Jun 4, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bf8bc2d
feat(computer): main-thread synthetic-input executor + CEF crash fix
M3gA-Mind b96bd27
feat(accessibility): AX/UIA perception + automate perceive→act→settle…
M3gA-Mind 608f177
feat(agent): wire automate/ax_interact computer tools into the orches…
M3gA-Mind 2bf88db
Merge remote-tracking branch 'upstream/main' into feat/voice-split-3-…
M3gA-Mind 200f837
Merge upstream/main into feat/voice-split-3-tool-wiring
M3gA-Mind 52dc7c4
fix(computer): route mouse/keyboard through the ApprovalGate (#3340 r…
M3gA-Mind 09263fc
docs(voice): reconcile Change 1.15 status (crash fixed) + tag fence
M3gA-Mind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,223 @@ | ||
| //! Tool: `automate` — accomplish a multi-step UI goal in one call. | ||
| //! | ||
| //! The orchestrator calls `automate{app, goal}` once; the Rust loop in | ||
| //! `accessibility::automate` then perceives → decides (fast model) → acts → | ||
| //! settles → verifies until the goal is met or a step budget is hit. This keeps | ||
| //! the heavy chat model out of the click loop (latency + reliability — see | ||
| //! `docs/voice-automate-plan.md`). | ||
| //! | ||
| //! Safety mirrors `ax_interact`: it actuates real controls, so it is a mutating | ||
| //! tool — opt-in via `computer_control.ax_interact_mutations`, routed through the | ||
| //! ApprovalGate, and it refuses the sensitive-app denylist (password managers, | ||
| //! Keychain, System Settings, terminals) even on auto-approved turns. | ||
|
|
||
| use super::ax_interact::is_sensitive_app; | ||
| use crate::openhuman::accessibility::automate::{self, AutomateOptions, RealBackend}; | ||
| use crate::openhuman::tools::traits::{PermissionLevel, Tool, ToolCallOptions, ToolResult}; | ||
| use async_trait::async_trait; | ||
| use serde_json::json; | ||
|
|
||
| pub struct AutomateTool { | ||
| /// When false the tool refuses to run (it is inherently mutating). Mirrors | ||
| /// `AxInteractTool::allow_mutations` so one opt-in governs both. | ||
| allow_mutations: bool, | ||
| } | ||
|
M3gA-Mind marked this conversation as resolved.
|
||
|
|
||
| impl AutomateTool { | ||
| pub fn new(allow_mutations: bool) -> Self { | ||
| Self { allow_mutations } | ||
| } | ||
| } | ||
|
|
||
| impl Default for AutomateTool { | ||
| fn default() -> Self { | ||
| Self::new(false) | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl Tool for AutomateTool { | ||
| fn name(&self) -> &str { | ||
| "automate" | ||
| } | ||
|
|
||
| fn description(&self) -> &str { | ||
| "Accomplish a MULTI-STEP goal inside a desktop app in a single call — e.g. \ | ||
| 'play <song> in Music', 'message <person> <text> in Slack'. Give the app \ | ||
| name and a plain-English goal; the system drives the app's UI step by step \ | ||
| (find elements → press/type → verify) using the platform accessibility API, \ | ||
| no screen coordinates. Prefer this over issuing many individual \ | ||
| `ax_interact` calls when the task needs several UI steps. The app should \ | ||
| usually be launched first (or include 'launch' in the goal). Refuses \ | ||
| password managers, Keychain, System Settings, and terminals." | ||
| } | ||
|
|
||
| fn parameters_schema(&self) -> serde_json::Value { | ||
| json!({ | ||
| "type": "object", | ||
| "properties": { | ||
| "app": { | ||
| "type": "string", | ||
| "description": "Display name of the target application (e.g. 'Music', 'Slack')." | ||
| }, | ||
| "goal": { | ||
| "type": "string", | ||
| "description": "Plain-English description of the multi-step outcome to achieve." | ||
| } | ||
| }, | ||
| "required": ["app", "goal"] | ||
| }) | ||
| } | ||
|
|
||
| fn permission_level(&self) -> PermissionLevel { | ||
| // Always mutating — it actuates controls. Kept as the base level so the | ||
| // approval gate fires regardless of args. | ||
| PermissionLevel::Dangerous | ||
| } | ||
|
|
||
| fn external_effect(&self) -> bool { | ||
| true | ||
| } | ||
|
M3gA-Mind marked this conversation as resolved.
|
||
|
|
||
| async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> { | ||
| self.execute_with_options(args, ToolCallOptions::default()) | ||
| .await | ||
| } | ||
|
|
||
| async fn execute_with_options( | ||
| &self, | ||
| args: serde_json::Value, | ||
| _options: ToolCallOptions, | ||
| ) -> anyhow::Result<ToolResult> { | ||
| let app = args | ||
| .get("app") | ||
| .and_then(|v| v.as_str()) | ||
| .unwrap_or("") | ||
| .trim() | ||
| .to_string(); | ||
| let goal = args | ||
| .get("goal") | ||
| .and_then(|v| v.as_str()) | ||
| .unwrap_or("") | ||
| .trim() | ||
| .to_string(); | ||
|
|
||
| log::info!("[automate] ▶ tool execute app={app:?} goal={goal:?}"); | ||
|
M3gA-Mind marked this conversation as resolved.
|
||
|
|
||
| if app.is_empty() { | ||
| return Ok(ToolResult::error("app is required")); | ||
| } | ||
| if goal.is_empty() { | ||
| return Ok(ToolResult::error("goal is required")); | ||
| } | ||
|
|
||
| // Hard safety boundary — identical to ax_interact's denylist. | ||
| if is_sensitive_app(&app) { | ||
| log::warn!("[automate] refused: sensitive app '{app}'"); | ||
| return Ok(ToolResult::error(format!( | ||
| "Refusing to automate '{app}': it is on the sensitive-app denylist \ | ||
| (password managers, Keychain, System Settings, terminals). This is a \ | ||
| hard safety boundary." | ||
| ))); | ||
| } | ||
|
|
||
| if !self.allow_mutations { | ||
| log::warn!("[automate] refused: mutations disabled"); | ||
| return Ok(ToolResult::error( | ||
| "App control isn't enabled yet. Turn on App Automation in \ | ||
| Settings → Agent Access (it grants permission to control apps), \ | ||
| then ask again. (Sets computer_control.ax_interact_mutations = true.)", | ||
| )); | ||
| } | ||
|
|
||
| let config = match crate::openhuman::config::rpc::load_config_with_timeout().await { | ||
| Ok(c) => c, | ||
| Err(e) => return Ok(ToolResult::error(format!("could not load config: {e}"))), | ||
| }; | ||
|
|
||
| let backend = RealBackend::new(config); | ||
| let outcome = automate::run(&app, &goal, &backend, AutomateOptions::default()).await; | ||
|
|
||
| let mut body = format!("{}\n\nSteps:", outcome.summary); | ||
| if outcome.steps.is_empty() { | ||
| body.push_str("\n (no steps executed)"); | ||
| } else { | ||
| for s in &outcome.steps { | ||
| body.push_str(&format!("\n - {s}")); | ||
| } | ||
| } | ||
|
|
||
| if outcome.success { | ||
| Ok(ToolResult::success(body)) | ||
| } else { | ||
| Ok(ToolResult::error(body)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn name_and_permission() { | ||
| let t = AutomateTool::new(true); | ||
| assert_eq!(t.name(), "automate"); | ||
| assert_eq!(t.permission_level(), PermissionLevel::Dangerous); | ||
| assert!(t.external_effect()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn schema_requires_app_and_goal() { | ||
| let schema = AutomateTool::new(true).parameters_schema(); | ||
| let req = schema["required"].as_array().unwrap(); | ||
| assert!(req.iter().any(|v| v == "app")); | ||
| assert!(req.iter().any(|v| v == "goal")); | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn rejects_missing_app_or_goal() { | ||
| let t = AutomateTool::new(true); | ||
| assert!( | ||
| t.execute(json!({"app": "", "goal": "x"})) | ||
| .await | ||
| .unwrap() | ||
| .is_error | ||
| ); | ||
| assert!( | ||
| t.execute(json!({"app": "Music", "goal": ""})) | ||
| .await | ||
| .unwrap() | ||
| .is_error | ||
| ); | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn refuses_when_mutations_disabled() { | ||
| let t = AutomateTool::new(false); | ||
| let r = t | ||
| .execute(json!({"app": "Music", "goal": "play a song"})) | ||
| .await | ||
| .unwrap(); | ||
| assert!(r.is_error); | ||
| assert!(r.output().contains("ax_interact_mutations")); | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn refuses_sensitive_app() { | ||
| let t = AutomateTool::new(true); | ||
| for app in [ | ||
| "Keychain Access", | ||
| "1Password", | ||
| "Terminal", | ||
| "System Settings", | ||
| ] { | ||
| let r = t | ||
| .execute(json!({"app": app, "goal": "do something"})) | ||
| .await | ||
| .unwrap(); | ||
| assert!(r.is_error, "expected refusal for {app}"); | ||
| assert!(r.output().to_lowercase().contains("denylist")); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.