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

@@ -135,7 +135,7 @@ class VoiceWorker:
raise ValueError("the voice worker only listens on a loopback address")
from websockets.asyncio.server import serve
await self.start()
return await serve(self.handle, host, port, max_size=2 ** 20)
return await serve(self.handle, host, port, max_size=4 * 2 ** 20) # pictures (screen_action_result)
async def handle(self, ws) -> None:
try:
@@ -354,6 +354,7 @@ class Session:
"chat_channels": self._on_chat_channels, "chat_action_result": self._on_chat_action_result,
"schedule_action_result": self._on_app_action_result,
"note_action_result": self._on_app_action_result,
"screen_action_result": self._on_app_action_result,
"memory_config": self._on_memory_config, "reply_delivered": self._on_reply_delivered,
"prepare": self._on_prepare, "llm": self._on_llm}.get(kind)
if handler is None:
@@ -523,7 +524,7 @@ class Session:
fut.set_result(result)
async def app_action(self, kind: str, action: str, args: dict) -> dict:
"""Ask the app to add, list or delete a schedule or a note (``kind``) and wait for its answer
"""Ask the app to act on a schedule, a note or the screen (``kind``) and wait for its answer
(or a timeout)."""
aid = f"{self.worker.chat_action_prefix}-{self.sid}-{next(self._chat_ids)}"
fut = asyncio.get_running_loop().create_future()
@@ -549,6 +550,8 @@ class Session:
result["item"] = msg["item"]
if isinstance(msg.get("items"), list):
result["items"] = [i for i in msg["items"] if isinstance(i, dict)]
if isinstance(msg.get("images"), list): # screen pictures, base64 JPEG
result["images"] = [i for i in msg["images"] if isinstance(i, str)]
fut.set_result(result)
def _on_memory_config(self, msg: dict) -> None:
@@ -820,13 +823,14 @@ class Session:
origin = (user, via, chat_channel if via == "chat" else None)
schedule = AppBridge(self, asyncio.get_running_loop(), "schedule", *origin)
notes_backend = AppBridge(self, asyncio.get_running_loop(), "note", *origin)
screen = AppBridge(self, asyncio.get_running_loop(), "screen", *origin)
try:
async with self._llm(rid if speak else None):
w.answering += 1
try:
answer = await asyncio.to_thread(w.brain.reply, user, text, history, chat=chat,
schedule=schedule, notes=notes or [],
notes_backend=notes_backend)
notes_backend=notes_backend, screen=screen)
finally:
w.answering -= 1
if not w.answering and w.scheduler: