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:
javis-bot
2026-11-15 17:02:59 +09:00
parent bd7b69d4f4
commit 53bccb620d
39 changed files with 1844 additions and 68 deletions

View File

@@ -28,10 +28,11 @@ class FakeBrain:
self.answer = answer
self.calls = []
def reply(self, user, text, history, chat=None, schedule=None, task=False, notes=None, notes_backend=None):
def reply(self, user, text, history, chat=None, schedule=None, task=False, notes=None, notes_backend=None,
screen=None):
self.calls.append((user, text, history))
self.chat, self.schedule, self.task = chat, schedule, task
self.notes, self.notes_backend = notes, notes_backend
self.notes, self.notes_backend, self.screen = notes, notes_backend, screen
return self.answer(user, text)
def addressed(self, user, text, names):
@@ -1040,8 +1041,10 @@ def _jarvis_brain(tmp_path, monkeypatch, plans):
monkeypatch.setenv("JARVIS_CONFIG_PATH", str(cfg))
seen = {"judged": [], "prepared": []}
def fake_prepare(cfg, text, mem, chat_available, schedule_available=False, notes_available=False):
assert schedule_available and notes_available # the reply it is made for has these tools
def fake_prepare(cfg, text, mem, chat_available, schedule_available=False, notes_available=False,
screen_available=False):
# the reply it is made for has these tools
assert schedule_available and notes_available and screen_available
seen["judged"].append((text, chat_available))
return plans.get(text)
@@ -1099,7 +1102,8 @@ def test_a_reply_waits_for_a_pick_still_being_prepared_for_its_text(tmp_path, mo
b, seen = _jarvis_brain(tmp_path, monkeypatch, {})
import jarvis.reply.engine as engine
def slow_prepare(cfg, text, mem, chat_available, schedule_available=False, notes_available=False):
def slow_prepare(cfg, text, mem, chat_available, schedule_available=False, notes_available=False,
screen_available=False):
_time.sleep(0.4)
return plan
monkeypatch.setattr(engine, "prepare_intent", slow_prepare)
@@ -1445,3 +1449,31 @@ def test_a_scheduled_task_gets_the_persons_notes_but_no_notes_tool(store):
asyncio.run(with_worker(body, store=store, brain=brain))
assert brain.notes == ["섭씨로"] and brain.notes_backend is None and brain.task is True
@pytest.mark.unit
def test_a_screen_action_goes_to_the_app_for_the_asker_and_its_pictures_come_back(store):
results = []
brain = FakeBrain(lambda u, t: results.append(brain.screen.act("capture", target="monitor", monitor=2,
detail="normal")) or "ok")
picture = "A" * (2 * 2 ** 20) # pictures make messages larger than the other actions'
async def body(url):
async with connect(url, max_size=None) as ws:
await hello(ws)
await send(ws, type="reply", id="r1", user="100", text="q", via="voice", speak=False)
seen = await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "screen_action")
action = seen[-1]
await send(ws, type="screen_action_result", id=action["id"], ok=True,
item={"what": "모니터 2", "width": 1280, "height": 720, "parts": 1}, images=[picture, 3])
await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "reply_text")
await send(ws, type="reply", id="t1", user="100", text="q", via="task")
await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "reply_text")
return action
action = asyncio.run(with_worker(body, store=store, brain=brain))
assert {k: v for k, v in action.items() if k not in ("type", "id")} == {
"action": "capture", "user": "100", "via": "voice", "target": "monitor", "monitor": 2, "detail": "normal"}
assert results == [{"ok": True, "item": {"what": "모니터 2", "width": 1280, "height": 720, "parts": 1},
"images": [picture]}]
assert brain.screen is None # a scheduled task sees no screen