feat: screen viewing, Jarvis sees the whole screen, a monitor or a window for registered people
- screenView tool (screen_view.spec.md): whole screen, monitor by number, window by part of its title or program, or the list of monitors and windows; fast, normal or detailed pictures. - The app captures with Windows Graphics Capture (app/src/screen.rs, admin.spec.md "Screen viewing"), decides for the asker (only people registered for PC control), never picks, lists or shows excluded programs (pcControl.screenExclude, password managers by default), refuses minimised windows and black pictures, and records screen.view in the activity log. - Pictures ride on the tool message (ToolExecutionResult.images); llm.py sends them to OpenAI-compatible servers as image parts after the tool messages. They stay in that reply only: not in the tool carryover, logs or prompt dumps. - The LLM reads pictures only when screen viewing is available (--vision gpu normally, cpu in a game), measured apart for the placement; otherwise screenView is a disabled tool. - Worker: screen_action / screen_action_result, 4 MiB messages. - Eval evals/test_screen_view_tool.py; Windows check tests/screen_windows.rs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,7 @@ pub fn launch_args(layout: &Layout, settings: &Settings, conf: &Conf, sets: &[St
|
||||
let models = layout.data.join("models").join("llm").to_string_lossy().into_owned();
|
||||
let mut a: Vec<String> = ["launch", "--family", FAMILY, "--model", MODEL, "--data-dir"].map(String::from).into();
|
||||
a.push(models);
|
||||
for (k, v) in [("--context", conf.context.to_string()), ("--vision", "off".into()),
|
||||
for (k, v) in [("--context", conf.context.to_string()), ("--vision", conf.vision.into()),
|
||||
("--parallel", conf.parallel.to_string()), ("--access", "local".into()),
|
||||
("--port", settings.llm.port.to_string())] {
|
||||
a.push(k.into());
|
||||
@@ -74,15 +74,34 @@ pub fn launch_args(layout: &Layout, settings: &Settings, conf: &Conf, sets: &[St
|
||||
pub struct Conf {
|
||||
pub context: u32,
|
||||
pub parallel: u32,
|
||||
/// `--vision`: `off`, `gpu` or `cpu` (`vision`).
|
||||
pub vision: &'static str,
|
||||
}
|
||||
|
||||
pub fn conf(settings: &Settings, stage: Stage) -> Conf {
|
||||
let vision = vision(stage, crate::screen::available(settings));
|
||||
match stage {
|
||||
Stage::Gaming => Conf { context: crate::placement::GAME_CONTEXT.min(settings.llm.context), parallel: 1 },
|
||||
_ => Conf { context: settings.llm.context, parallel: parallel(settings) },
|
||||
Stage::Gaming => Conf { context: crate::placement::GAME_CONTEXT.min(settings.llm.context), parallel: 1, vision },
|
||||
_ => Conf { context: settings.llm.context, parallel: parallel(settings), vision },
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the LLM reads pictures (`--vision`): nowhere unless screen viewing is available, on the
|
||||
/// card normally and on the CPU in a game (M0's game placement).
|
||||
pub fn vision(stage: Stage, screen: bool) -> &'static str {
|
||||
match (screen, stage) {
|
||||
(false, _) => "off",
|
||||
(true, Stage::Gaming) => "cpu",
|
||||
(true, _) => "gpu",
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the probe of a placement is kept in `config/llm-probe.json`: pictures on the card take
|
||||
/// memory of their own, so they are measured apart.
|
||||
pub fn probe_key(c: &Conf) -> String {
|
||||
if c.vision == "gpu" { format!("{}/{}/vision", c.context, c.parallel) } else { format!("{}/{}", c.context, c.parallel) }
|
||||
}
|
||||
|
||||
/// The engine's CPU threads from its log ("... on 16 CPU threads ...").
|
||||
fn cpu_threads(log: &str) -> Option<u32> {
|
||||
log.lines().rev().find_map(|l| {
|
||||
@@ -229,7 +248,7 @@ pub fn write_brain_config(data: &Path, base_url: &str, model: &str, settings: &c
|
||||
"ollama_base_url": base_url,
|
||||
"ollama_chat_model": model,
|
||||
"db_path": data.join("memory").join("jarvis.db").to_string_lossy(),
|
||||
"disabled_tools": crate::features::disabled_tools(&settings.features),
|
||||
"disabled_tools": crate::features::disabled_tools(settings),
|
||||
"mcps": crate::features::brain_mcps(&settings.mcp_servers),
|
||||
"_config_version": 1,
|
||||
});
|
||||
@@ -358,7 +377,7 @@ impl Llm {
|
||||
*self.baseline.lock().unwrap() = Some(now_others);
|
||||
}
|
||||
let baseline = *self.baseline.lock().unwrap();
|
||||
let key = format!("{}/{}", c.context, c.parallel);
|
||||
let key = probe_key(&c);
|
||||
let file = self.probe_file();
|
||||
let mut all: serde_json::Map<String, Value> = std::fs::read_to_string(&file).ok()
|
||||
.and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default();
|
||||
@@ -650,6 +669,22 @@ pub(crate) mod tests {
|
||||
assert!(a.iter().any(|x| x == "--no-tui") && a.iter().any(|x| x == "--yes"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pictures_are_read_only_with_screen_viewing_and_measured_apart_on_the_card() {
|
||||
assert_eq!(vision(Stage::Normal, false), "off");
|
||||
assert_eq!(vision(Stage::Gaming, false), "off");
|
||||
assert_eq!(vision(Stage::Normal, true), "gpu");
|
||||
assert_eq!(vision(Stage::Gaming, true), "cpu");
|
||||
let s = Settings::default();
|
||||
let c = conf(&s, Stage::Normal);
|
||||
assert_eq!(c.vision, "off", "nobody is registered for PC control by default");
|
||||
let a = launch_args(&layout("llm-vision"), &s, &Conf { vision: "gpu", ..c }, &[]);
|
||||
assert_eq!(a[a.iter().position(|x| x == "--vision").unwrap() + 1], "gpu");
|
||||
assert_eq!(probe_key(&Conf { context: 32768, parallel: 1, vision: "off" }), "32768/1");
|
||||
assert_eq!(probe_key(&Conf { context: 32768, parallel: 1, vision: "cpu" }), "32768/1");
|
||||
assert_eq!(probe_key(&Conf { context: 32768, parallel: 1, vision: "gpu" }), "32768/1/vision");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_chat_channel_answering_everything_gets_a_second_request_slot() {
|
||||
let mut s = Settings::default();
|
||||
@@ -679,7 +714,7 @@ pub(crate) mod tests {
|
||||
assert_eq!(v["ollama_base_url"], "http://127.0.0.1:8080/v1");
|
||||
assert_eq!(v["ollama_chat_model"], "m");
|
||||
assert!(Path::new(v["db_path"].as_str().unwrap()).starts_with(&l.data));
|
||||
assert_eq!(v["disabled_tools"], json!(crate::features::disabled_tools(&s.features)));
|
||||
assert_eq!(v["disabled_tools"], json!(crate::features::disabled_tools(&s)));
|
||||
assert_eq!(v["mcps"], crate::features::brain_mcps(&s.mcp_servers));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user