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:
@@ -102,6 +102,8 @@ pub struct FeatureSettings {
|
||||
pub schedule: bool,
|
||||
/// Each person's standing instructions (admin.spec.md, "Personal notes").
|
||||
pub notes: bool,
|
||||
/// Screen viewing (admin.spec.md, "Screen viewing").
|
||||
pub screen: bool,
|
||||
}
|
||||
|
||||
/// Game detection (admin.spec.md, "Game detection"): on by default; the person's own games and
|
||||
@@ -181,6 +183,8 @@ pub struct PcControlSettings {
|
||||
pub type_text: Level,
|
||||
/// Starting programs (default ask).
|
||||
pub run: Level,
|
||||
/// Programs never seen on the screen (file names, ".exe" may be left out).
|
||||
pub screen_exclude: Vec<String>,
|
||||
}
|
||||
|
||||
/// An MCP server the brain starts (stdio). The values of `env` are in the secrets, never here.
|
||||
@@ -260,13 +264,14 @@ impl Default for Settings {
|
||||
response: PolicySettings::default(),
|
||||
memory: Map::new(),
|
||||
llm: LlmSettings { url: None, port: 8080, context: 32768 },
|
||||
features: FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false, schedule: true, notes: true },
|
||||
features: FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false, schedule: true, notes: true, screen: true },
|
||||
mcp_servers: vec![],
|
||||
collect: CollectSettings { keep_days: 30, targets: vec![], notify_channel: None, digest_hour: 9 },
|
||||
game: GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0, reserve_gb: 8.0, revert_seconds: 30, pause_in_game: false },
|
||||
schedule_channel: None,
|
||||
pc_control: PcControlSettings { allowed_users: vec![], view: Level::Auto, click: Level::Ask,
|
||||
type_text: Level::Ask, run: Level::Ask },
|
||||
type_text: Level::Ask, run: Level::Ask,
|
||||
screen_exclude: ["1Password", "Bitwarden", "KeePass", "KeePassXC"].map(String::from).into() },
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -597,6 +602,7 @@ pub fn parse_settings(raw: &Value) -> Result<Settings, SettingsError> {
|
||||
browser_share: get_bool(f, "browserShare", "features", d.features.browser_share)?,
|
||||
schedule: get_bool(f, "schedule", "features", d.features.schedule)?,
|
||||
notes: get_bool(f, "notes", "features", d.features.notes)?,
|
||||
screen: get_bool(f, "screen", "features", d.features.screen)?,
|
||||
}
|
||||
},
|
||||
mcp_servers: parse_mcp_servers(raw)?,
|
||||
@@ -624,6 +630,14 @@ fn parse_pc_control(raw: &Map<String, Value>, d: &PcControlSettings) -> Result<P
|
||||
click: level("click", d.click)?,
|
||||
type_text: level("type", d.type_text)?,
|
||||
run: level("run", d.run)?,
|
||||
screen_exclude: {
|
||||
let v: Vec<String> = get_str_list(p, "screenExclude", "pcControl", &d.screen_exclude)?.into_iter()
|
||||
.map(|e| e.trim().to_owned()).filter(|e| !e.is_empty()).collect();
|
||||
if v.len() > 100 || v.iter().any(|e| e.chars().count() > 100 || e.contains(['\\', '/'])) {
|
||||
return err("pcControl.screenExclude must be at most 100 program names (no folders)");
|
||||
}
|
||||
v
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -965,13 +979,13 @@ mod tests {
|
||||
#[test]
|
||||
fn features_and_mcp_servers_are_read_and_checked() {
|
||||
let s = parse_settings(&json!({}));
|
||||
assert_eq!(s.unwrap().features, FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false, schedule: true, notes: true });
|
||||
assert_eq!(s.unwrap().features, FeatureSettings { weather: true, web_search: true, meals: true, collect: true, browser: true, browser_share: false, schedule: true, notes: true, screen: true });
|
||||
let s = parse_settings(&json!({
|
||||
"features": {"weather": false, "meals": false, "browserShare": true, "schedule": false, "notes": false},
|
||||
"features": {"weather": false, "meals": false, "browserShare": true, "schedule": false, "notes": false, "screen": false},
|
||||
"mcpServers": [{"name": "brave", "command": "npx", "args": ["-y", "brave"], "env": ["BRAVE_API_KEY", " "]},
|
||||
{"name": "time-2", "command": "uvx", "enabled": false}]
|
||||
})).unwrap();
|
||||
assert_eq!(s.features, FeatureSettings { weather: false, web_search: true, meals: false, collect: true, browser: true, browser_share: true, schedule: false, notes: false });
|
||||
assert_eq!(s.features, FeatureSettings { weather: false, web_search: true, meals: false, collect: true, browser: true, browser_share: true, schedule: false, notes: false, screen: false });
|
||||
assert_eq!(s.mcp_servers, vec![
|
||||
McpServerSettings { name: "brave".into(), command: "npx".into(), args: vec!["-y".into(), "brave".into()],
|
||||
env: vec!["BRAVE_API_KEY".into()], enabled: true },
|
||||
@@ -981,11 +995,14 @@ mod tests {
|
||||
let pc = parse_settings(&json!({})).unwrap().pc_control;
|
||||
assert!(pc.allowed_users.is_empty());
|
||||
assert_eq!((pc.view, pc.click, pc.type_text, pc.run), (Level::Auto, Level::Ask, Level::Ask, Level::Ask));
|
||||
assert!(pc.screen_exclude.contains(&"KeePassXC".to_owned()), "password managers are never seen by default");
|
||||
let pc = parse_settings(&json!({"pcControl": {"allowedUsers": ["123456789012345678"], "view": "never",
|
||||
"click": "auto", "type": "never", "run": "auto"}})).unwrap().pc_control;
|
||||
"click": "auto", "type": "never", "run": "auto", "screenExclude": [" bank.exe ", ""]}})).unwrap().pc_control;
|
||||
assert_eq!(pc.allowed_users, vec![123456789012345678]);
|
||||
assert_eq!(pc.screen_exclude, vec!["bank.exe".to_owned()]);
|
||||
assert_eq!((pc.view, pc.click, pc.type_text, pc.run), (Level::Never, Level::Auto, Level::Never, Level::Auto));
|
||||
for bad in [json!({"pcControl": {"click": "yes"}}), json!({"pcControl": {"allowedUsers": ["1"]}})] {
|
||||
for bad in [json!({"pcControl": {"click": "yes"}}), json!({"pcControl": {"allowedUsers": ["1"]}}),
|
||||
json!({"pcControl": {"screenExclude": ["C:\\bank\\bank.exe"]}}), json!({"pcControl": {"screenExclude": "x"}})] {
|
||||
assert!(parse_settings(&bad).unwrap_err().0.contains("pcControl."), "{bad}");
|
||||
}
|
||||
// A schedule channel must be a registered one that Jarvis may send in.
|
||||
|
||||
Reference in New Issue
Block a user