MCPcopy Create free account
hub / github.com/GCWing/BitFun / open_app

Method open_app

src/apps/desktop/src/computer_use/desktop_host/mod.rs:1091–1189  ·  view source on GitHub ↗
(
        &self,
        app_name: &str,
    )

Source from the content-addressed store, hash-verified

1089 }
1090
1091 async fn open_app(
1092 &self,
1093 app_name: &str,
1094 ) -> BitFunResult<bitfun_core::agentic::tools::computer_use_host::OpenAppResult> {
1095 use bitfun_core::agentic::tools::computer_use_host::OpenAppResult;
1096 let name = app_name.to_string();
1097
1098 #[cfg(target_os = "macos")]
1099 {
1100 let result = tokio::task::spawn_blocking(move || -> BitFunResult<OpenAppResult> {
1101 let output = std::process::Command::new("/usr/bin/osascript")
1102 .args([
1103 "-e",
1104 &format!(
1105 r#"tell application "{}" to activate
1106delay 1
1107tell application "System Events" to get unix id of first process whose frontmost is true"#,
1108 name
1109 ),
1110 ])
1111 .output()
1112 .map_err(|e| BitFunError::tool(format!("open_app osascript: {}", e)))?;
1113
1114 if output.status.success() {
1115 let stdout = String::from_utf8_lossy(&output.stdout);
1116 let pid = stdout.trim().parse::<i32>().ok();
1117 Ok(OpenAppResult {
1118 app_name: name,
1119 success: true,
1120 process_id: pid,
1121 error_message: None,
1122 })
1123 } else {
1124 let stderr = String::from_utf8_lossy(&output.stderr);
1125 Ok(OpenAppResult {
1126 app_name: name,
1127 success: false,
1128 process_id: None,
1129 error_message: Some(stderr.trim().to_string()),
1130 })
1131 }
1132 })
1133 .await
1134 .map_err(|e| BitFunError::tool(e.to_string()))??;
1135 return Ok(result);
1136 }
1137
1138 #[cfg(target_os = "windows")]
1139 {
1140 let result = tokio::task::spawn_blocking(move || -> BitFunResult<OpenAppResult> {
1141 let output = bitfun_core::util::process_manager::create_command("cmd")
1142 .args(["/c", "start", "", &name])
1143 .output()
1144 .map_err(|e| BitFunError::tool(format!("open_app: {}", e)))?;
1145 Ok(OpenAppResult {
1146 app_name: name,
1147 success: output.status.success(),
1148 process_id: None,

Callers

nothing calls this directly

Calls 5

outputMethod · 0.80
trimMethod · 0.80
create_commandFunction · 0.50
successMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected