8000 Add focus guard (expectWindow) to keyboard input tools · Issue #12 · Mnehmos/mnehmos.ooda.mcp · GitHub
[go: up one dir, main page]

Skip to content

Add focus guard (expectWindow) to keyboard input tools #12

Open

Description

@Mnehmos

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:

  1. Read the current foreground window.
  2. If it does not match, refuse to send input and return an error naming the window that actually had focus.
  3. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0