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:
@@ -201,6 +201,49 @@ async fn audio_and_tts_round_trip_through_the_python_server() {
|
||||
.expect("note round trip");
|
||||
assert_eq!(noted, "noted 1");
|
||||
assert_eq!(notes.texts_of(42), vec!["반말로 해".to_string()]);
|
||||
// The screenView tool's captures come to the app, which decides for the asker and sends the
|
||||
// pictures back (a large message: a 4K monitor at full detail would be about 1 MB).
|
||||
struct Grey;
|
||||
impl jarvis_app::screen::Screen for Grey {
|
||||
fn monitors(&self) -> Result<Vec<jarvis_app::screen::Monitor>, String> {
|
||||
Ok(vec![jarvis_app::screen::Monitor { number: 2, rect: jarvis_app::screen::Rect { x: 0, y: 0, w: 3840, h: 2160 },
|
||||
main: true, handle: 0 }])
|
||||
}
|
||||
fn windows(&self) -> Result<Vec<jarvis_app::screen::Window>, String> {
|
||||
Ok(vec![])
|
||||
}
|
||||
fn capture_monitor(&self, m: &jarvis_app::screen::Monitor) -> Result<jarvis_app::screen::Image, String> {
|
||||
let (w, h) = (m.rect.w as u32, m.rect.h as u32);
|
||||
Ok(jarvis_app::screen::Image { w, h, bgra: (0..w * h * 4).map(|i| (i % 251) as u8 | 0x40).collect() })
|
||||
}
|
||||
fn capture_window(&self, _: &jarvis_app::screen::Window) -> Result<jarvis_app::screen::Image, String> {
|
||||
Err("no windows".into())
|
||||
}
|
||||
}
|
||||
let mut screen_settings = jarvis_app::settings::Settings::default();
|
||||
screen_settings.pc_control.allowed_users = vec![42];
|
||||
for (rid, user, want) in [("v1", 42u64, "saw "), ("v2", 7, "등록된 사람만")] {
|
||||
assert!(c.reply(rid, user, "화면 봐 줘", "voice", false));
|
||||
let seen = tokio::time::timeout(Duration::from_secs(10), async {
|
||||
loop {
|
||||
match rx.recv().await.unwrap() {
|
||||
WorkerEvent::ScreenAction(a) => {
|
||||
assert_eq!((a.action.as_str(), a.target.as_deref(), a.monitor, a.detail.as_deref()),
|
||||
("capture", Some("monitor"), Some(2), Some("fast")));
|
||||
c.screen_action_result(&a.id, jarvis_app::screen::act(&screen_settings, &Grey, &a));
|
||||
}
|
||||
WorkerEvent::ReplyText { id, text, .. } if id == rid => return text,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("screen round trip");
|
||||
assert!(seen.contains(want), "{seen}");
|
||||
if user == 42 {
|
||||
assert!(seen.ends_with("모니터 2") && seen.split(' ').nth(1).unwrap().parse::<usize>().unwrap() > 1000, "{seen}");
|
||||
}
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(&data);
|
||||
c.close();
|
||||
let _ = child.kill().await;
|
||||
|
||||
Reference in New Issue
Block a user