feat(v2): screenView sees someone's Discord screen share in its popped-out window

The share target checks that the person asked about shares their screen in
Jarvis's voice channel, finds Discord's popped-out window (title not ending in
Discord, the voice channel's name first) and, when there is none, asks for it in
the channel and looks again every second for 30 s. Screen actions now wait as
long as PC actions in the worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-19 13:43:31 +09:00
parent 3af881935c
commit 844958d311
13 changed files with 287 additions and 28 deletions

View File

@@ -10,9 +10,10 @@ from ..base import Tool, ToolContext
from ..types import ToolExecutionResult
from ...debug import debug_log
_TARGETS = ("screen", "monitor", "window", "list")
_TARGETS = ("screen", "monitor", "window", "share", "list")
_DETAILS = ("fast", "normal", "detailed")
MAX_WINDOW_CHARS = 200
MAX_PERSON_CHARS = 200
def _fail(text: str) -> ToolExecutionResult:
@@ -37,10 +38,11 @@ class ScreenViewTool(Tool):
def description(self) -> str:
return (
"See this PC's screen as a picture: target='screen' (all monitors), 'monitor' with its "
"number, or 'window' with part of the program's name or window title; target='list' "
"names the monitors and open windows. Use it whenever the person asks what is on their "
"screen, a monitor or a program's window; detail='detailed' to read small text. Answer "
"only from the picture."
"number, 'window' with part of the program's name or window title, or 'share' for "
"another person's screen, which they share on Discord (person: their name); "
"target='list' names the monitors and open windows. Use it whenever the person asks "
"what is on their screen, a monitor, a program's window or someone else's screen; "
"detail='detailed' to read small text. Answer only from the picture."
)
@property
@@ -51,6 +53,7 @@ class ScreenViewTool(Tool):
"target": {"type": "string", "enum": list(_TARGETS)},
"monitor": {"type": "integer", "description": "monitor: its number (1, 2, ...)"},
"window": {"type": "string", "description": "window: part of its program name or title"},
"person": {"type": "string", "description": "share: the name of the person sharing"},
"detail": {"type": "string", "enum": list(_DETAILS)},
},
"required": [],
@@ -80,6 +83,12 @@ class ScreenViewTool(Tool):
if not w or len(w) > MAX_WINDOW_CHARS:
return _fail("window needs part of the program name or title; call target='list' to see them")
fields["window"] = w
if target == "share":
p = " ".join(str(args.get("person") or "").split())
if len(p) > MAX_PERSON_CHARS:
return _fail("person needs the name of the person sharing their screen")
if p:
fields["person"] = p
fields["detail"] = _word(args.get("detail"), _DETAILS, "normal")
result = backend.act("capture", **fields) or {}
images = [i for i in result.get("images") or [] if isinstance(i, str) and i]