You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add focus guard (expectWindow) to keyboard input tools #12
keyboard_type, keyboard_press, and keyboard_shortcut send input to whatever window currently has focus, with no way to assert what that window is.
Why this matters
During a playtest I had to hand-roll the safety check: focus_window returned false, so before typing I called get_active_window manually to confirm Notepad was actually foreground. Without that manual step the keystrokes would have gone into the user's editor — which had another agent actively working in it.
That check should be structural, not something each caller remembers. Frontier computer-use harnesses treat "focus changed unexpectedly -> stop typing" as a deterministic reflex, not a prompt-level instruction.
Fix
Add an optional expectWindow parameter (substring match on title, or a pid) to the keyboard tools. When supplied:
Read the current foreground window.
If it does not match, refuse to send input and return an error naming the window that actually had focus.
If it matches, proceed.
Default behavior (no expectWindow) is unchanged, so this is backwards compatible. Optionally expose the same guard for mouse_click.
This is the first reflex in the server: a deterministic precondition check that does not require a model turn.
Activity