Screens: a brain without a screen of its own uses its hands' screen
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
This commit is contained in:
parent
39bd19e9df
commit
8615881634
12
src/agent.rs
12
src/agent.rs
|
|
@ -145,9 +145,19 @@ fn screen_target(job: &Job, args: &str) -> Result<tools::Target, String> {
|
||||||
if let Some(t) = job.computers.iter().find(|t| t.name == job.default_computer && has_screen(t)) {
|
if let Some(t) = job.computers.iter().find(|t| t.name == job.default_computer && has_screen(t)) {
|
||||||
return Ok(t.clone());
|
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
|
job.computers
|
||||||
.iter()
|
.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 { .. })))
|
.or_else(|| job.computers.iter().find(|t| matches!(t.place, tools::Place::Local { .. })))
|
||||||
.cloned()
|
.cloned()
|
||||||
.ok_or_else(|| "找不到可以操作螢幕的電腦".to_string())
|
.ok_or_else(|| "找不到可以操作螢幕的電腦".to_string())
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,10 @@ pub fn specs_for(computers: &[String], default: &str) -> Vec<Value> {
|
||||||
json!({"name": "computer_use_check_permissions", "description": "Check whether the screen can be seen and the mouse and keyboard used on that computer.",
|
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": {}}}),
|
"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() {
|
for t in v.iter_mut() {
|
||||||
t["parameters"]["properties"]["computer"] = json!({"type": "string", "enum": computers,
|
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)});
|
"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)});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue