Trying screen steps on this Mac from the command line, and an app CLI's crash note names redirects

`anybot --ask` with ANYBOT_ASK_HERE=1 offers this computer too (headless runs leave it out), so
screen and menu-bar steps can be tried on a Mac without the window. Tried on a Mac mini: the
menu bar's icons listed in one step, a status icon clicked by its name, AppleScript reading the
front app, Tailscale's own CLI answering — all without a screenshot.

An App Store app's CLI joined to `> file` stays in the sandbox and dies; the note now says so
(a bot blamed --json for it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha5F5gJt93t3yEx3XcS
This commit is contained in:
王性驊 2026-11-09 09:27:35 +08:00
parent b92abeb79a
commit 1952e547b8
2 changed files with 8 additions and 3 deletions

View File

@ -190,6 +190,8 @@ pub struct App {
rm: remote_ui::RemoteUi, rm: remote_ui::RemoteUi,
/// Running as `anybot --serve` (no window; the phone is the screen). /// Running as `anybot --serve` (no window; the phone is the screen).
headless: bool, headless: bool,
/// Running `anybot --ask` (one message from the command line, for testing tool use).
asking: bool,
/// The computer the person last typed to a bot on: an account computer's id, "" for this /// The computer the person last typed to a bot on: an account computer's id, "" for this
/// one, None when not known (the phone isn't a computer). It is "我的電腦" to the bots. /// one, None when not known (the phone isn't a computer). It is "我的電腦" to the bots.
typed_on: Option<String>, typed_on: Option<String>,
@ -306,6 +308,7 @@ impl App {
msg_index: 0, msg_index: 0,
rm: Default::default(), rm: Default::default(),
headless: false, headless: false,
asking: false,
typed_on: None, typed_on: None,
panel: None, panel: None,
popped: HashMap::new(), popped: HashMap::new(),
@ -917,8 +920,9 @@ impl App {
v.push(t); v.push(t);
}; };
// A brain on a server works on the bots' own computer and the person's computers, never on // A brain on a server works on the bots' own computer and the person's computers, never on
// the server itself (the person asked for it to be off the list). // the server itself (the person asked for it to be off the list). `anybot --ask` with
if !self.headless { // ANYBOT_ASK_HERE=1 offers this computer too, for trying screen steps on it.
if !self.headless || (self.asking && std::env::var_os("ANYBOT_ASK_HERE").is_some()) {
add(&mut v, tools::Target { name: self.state.this_computer_name(), place: tools::Place::Local { workdir: tools::expand_home(if b.workdir.trim().is_empty() { "~" } else { b.workdir.trim() }) } }); add(&mut v, tools::Target { name: self.state.this_computer_name(), place: tools::Place::Local { workdir: tools::expand_home(if b.workdir.trim().is_empty() { "~" } else { b.workdir.trim() }) } });
} }
for c in &self.state.remote_computers { for c in &self.state.remote_computers {
@ -3696,6 +3700,7 @@ impl App {
pub fn ask_cli(ctx: &egui::Context, text: &str) -> ! { pub fn ask_cli(ctx: &egui::Context, text: &str) -> ! {
let mut app = App::new(ctx, None); let mut app = App::new(ctx, None);
app.headless = true; app.headless = true;
app.asking = true;
let id = app.state.primary_bot; let id = app.state.primary_bot;
let start = app.state.bot(id).map(|b| b.messages.len()).unwrap_or(0); let start = app.state.bot(id).map(|b| b.messages.len()).unwrap_or(0);
app.drafts.insert(id, text.to_string()); app.drafts.insert(id, text.to_string());

View File

@ -732,7 +732,7 @@ pub fn sandbox_note(cmd: &str, out: &str) -> Option<&'static str> {
}); });
} }
if (out.contains("Trace/BPT trap") || out.contains("指令因為收到訊號而終止")) && cmd.contains(".app/Contents/MacOS/") { if (out.contains("Trace/BPT trap") || out.contains("指令因為收到訊號而終止")) && cmd.contains(".app/Contents/MacOS/") {
return Some("(這個 App 的指令列在 AnyBot 的沙盒裡會當掉,不是 App 壞了。用它的完整路徑單獨執行(不要接 ;、|、&& 或其他指令),App Store 版的 App 就會在沙盒外跑;不行就改用畫面操作。)"); return Some("(這個 App 的指令列在 AnyBot 的沙盒裡會當掉,不是 App 壞了,也不是參數的問題。用它的完整路徑單獨執行:不要接 ;、|、&&,也不要用 >、< 把輸出存到檔案(要處理輸出就先單獨執行,再用下一條指令處理),App Store 版的 App 就會在沙盒外跑;不行就改用畫面操作。)");
} }
None None
} }