Commit graph hyperhive/hive-screen-mcp
Author SHA1 Message Date
iris
7176ce6322 docs(#2627): add README for hive-screen-mcp 2026-07-23 14:17:47 +02:00
iris
427328c4eb style(hive-screen-mcp): nix fmt — trailing semicolon in match arm 2026-07-20 21:18:57 +02:00
iris
cb4421228e fix(hive-screen-mcp): address argus review 🟡 items
- mouse_click: error on unrecognised button name instead of silently
  treating it as left click; "left" now explicit in match arm
- rfb_handshake: cap ServerInit name-length at 256 bytes to prevent
  a multi-GB allocation from an aberrant server response
2026-07-20 21:17:17 +02:00
iris
74fdbe7c43 fix(#2618): remove hardcoded resolution from mouse tool descriptions
The display size is not always 1280x720 — it changes when the operator
clicks 'match size' in the web UI. Replace the fixed mention with a
recommendation to use screenshot first to check the current resolution.
2026-07-20 21:07:55 +02:00
iris
228a5bacca feat(#2618): add mouse_move + mouse_click via RFB PointerEvent
Implements mouse input by speaking the RFB protocol directly to Weston's
neatvnc server (localhost:HIVE_GUI_VNC_PORT, default 5900) — the VNC
backend's native remote-input path. No /dev/uinput, no kernel bypass;
the compositor mediates all input just as it does for the browser VNC viewer.

Changes:
- rfb_handshake(): RFB 3.8 handshake with security type None (auth-method=none
  in weston.ini); shared-session ClientInit keeps the browser viewer connected
- rfb_pointer_event(): encodes a 6-byte RFB PointerEvent (type=5, button-mask,
  x/y big-endian)
- rfb_send_pointer_events(): connects, handshakes, sends an event slice,
  flushes — all in one TCP connection
- mouse_move(x, y): sends a single PointerEvent(mask=0, x, y)
- mouse_click(x, y, button): sends move → button-down → button-up sequence
  (left/middle/right via RFB button-mask bits 0/1/2)
- vnc_port(): reads HIVE_GUI_VNC_PORT from env, falls back to 5900

No new packages or nix options — HIVE_GUI_VNC_PORT is already set by the
harness when gui.enable = true; grim/wtype are the only runtime deps.

Closes #2618.
2026-07-20 21:00:09 +02:00
iris
804c11c404 fix(#2305): drop redundant [[bin]] section from hive-screen-mcp/Cargo.toml
name and path match cargo defaults; the explicit [[bin]] table is noise.
2026-07-20 20:55:27 +02:00
iris
7fa7e2bdfd refactor(#2305): drop mouse tools + ydotool, switch key_press to wtype
- remove mouse_move and mouse_click (no Wayland-native alternative on Weston
  without /dev/uinput; follow-up filed for future investigation)
- replace key_press from 'ydotool key' to 'wtype -k': parses mod1+mod2+key
  into -M mod1 ... -k key ... -m mod1 sequence via virtual-keyboard protocol
- remove dest_path parameter from screenshot: always writes to /tmp/ (fixes
  arbitrary write-path concern from security review)
- simplify screen.nix: drop screenInput option, ydotoold systemd unit, ydotool
  package; only grim + wtype remain (both compositor-mediated, no /dev/uinput)
- update module header comment to reflect three-tool surface

Addresses mara's /dev/uinput veto (PR #2617 comment #40524).
2026-07-20 20:55:27 +02:00
iris
584dfed0c9 fix(#2305): run_cmd returns Result, nix fmt, collapse nested if
- run_cmd now returns Result<String, String> — callers pattern-match
  instead of comparing against an "ok" sentinel string
- Add cmd_result() helper to format run_cmd results as tool strings
- mouse_click: collapse nested if-let into let-chain (clippy collapsible_if)
- nix fmt: reformat screen.nix package list
2026-07-20 20:55:27 +02:00
iris
0b3268feae feat(#2305): hive-screen-mcp — screenshot + input MCP for GUI agents
New crate hive-screen-mcp: a stdio MCP bridge activated automatically
when an agent has hyperhive.gui.enable = true. Provides five tools:

- screenshot   — grim → saves PNG, returns path for Read tool
- type_text    — wtype → Unicode text input (no daemon)
- key_press    — ydotool key → combos like ctrl+c, super+l
- mouse_move   — ydotool mousemove --absolute
- mouse_click  — ydotool click, optionally with prior move

New nix/agent-modules/screen.nix: wires the MCP bridge into
extraMcpServers.screen; adds grim + wtype to systemPackages. Adds
hyperhive.gui.screenInput option (default false) which enables the
ydotoold daemon + ydotool for mouse/keyboard injection via /dev/uinput.

screenshot and type_text work without screenInput. key_press,
mouse_move, and mouse_click return a ydotool error until ydotoold is
running and /dev/uinput is accessible in the container.
2026-07-20 20:55:27 +02:00