From 86158816349a14a4b916341b829a1016b6deb9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Thu, 5 Nov 2026 08:05:29 +0800 Subject: [PATCH] Screens: a brain without a screen of its own uses its hands' screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit computer_use_* name the computer whenever the screen is another computer's, and with no computer named the step goes to a screen that is really there (the bot's desktop, this computer's, then a 手腳 computer) instead of a brain's missing one. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa --- src/agent.rs | 12 +++++++++++- src/computer.rs | 5 ++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/agent.rs b/src/agent.rs index 7b799dc..8db8928 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -145,9 +145,19 @@ fn screen_target(job: &Job, args: &str) -> Result { if let Some(t) = job.computers.iter().find(|t| t.name == job.default_computer && has_screen(t)) { return Ok(t.clone()); } + // Not named: a screen that is really there — the bot's desktop, this computer's, then one of + // the account's other computers (a brain on a server has no screen of its own). + let real = |t: &&tools::Target| match t.place { + tools::Place::Box { .. } => crate::cloudbox::available(), + tools::Place::Local { .. } => computer::screen_supported(), + _ => false, + }; job.computers .iter() - .find(|t| matches!(t.place, tools::Place::Box { .. })) + .find(|t| matches!(t.place, tools::Place::Box { .. }) && real(t)) + .or_else(|| job.computers.iter().find(|t| matches!(t.place, tools::Place::Local { .. }) && real(t))) + .or_else(|| job.computers.iter().find(|t| matches!(t.place, tools::Place::Device { .. }))) + .or_else(|| job.computers.iter().find(|t| matches!(t.place, tools::Place::Box { .. }))) .or_else(|| job.computers.iter().find(|t| matches!(t.place, tools::Place::Local { .. }))) .cloned() .ok_or_else(|| "找不到可以操作螢幕的電腦".to_string()) diff --git a/src/computer.rs b/src/computer.rs index 44a1ed6..9fce0fc 100644 --- a/src/computer.rs +++ b/src/computer.rs @@ -210,7 +210,10 @@ pub fn specs_for(computers: &[String], default: &str) -> Vec { json!({"name": "computer_use_check_permissions", "description": "Check whether the screen can be seen and the mouse and keyboard used on that computer.", "parameters": {"type": "object", "properties": {}}}), ]; - if computers.len() > 1 { + // Named whenever there is a choice, or the one screen isn't this computer or the bot's own + // (a 手腳 computer): the bot should say whose screen it means. + let own = [crate::model::BOT_COMPUTER_NAME, crate::model::THIS_COMPUTER_NAME]; + if computers.len() > 1 || computers.iter().any(|c| !own.contains(&c.as_str())) { for t in v.iter_mut() { t["parameters"]["properties"]["computer"] = json!({"type": "string", "enum": computers, "description": format!("Whose screen. Default: {default}. {} is the bot's own Linux desktop; {} is the person's Mac (use it for the person's own apps).", crate::model::BOT_COMPUTER_NAME, crate::model::THIS_COMPUTER_NAME)});