name: click

description:
Click against a target pid. **Prefer `element_index` over pixel coordinates** — element_index works on backgrounded / hidden windows, surfaces a stable handle, and tells you what you're clicking via the cached AT-SPI element's role + label. Reach for `x, y` only when the target is a canvas / custom-drawn surface that doesn't appear in the AT-SPI tree.

Provide either (window_id + x/y) or (pid + element_index). Routes via XSendEvent (no focus steal). element_index cache is scoped per (pid, window_id) and is replaced by the next get_window_state of the same window — re-snapshot every turn before clicking.

After a zoom call, pass from_zoom=true to auto-translate zoom-image coords back to full-window space.

button: "left" (default), "right", or "middle". Defaults to left so the field is fully back-compat. X11: routes through XSendEvent ButtonPress/Release with the matching button code. Native Wayland: only left-button is supported via the virtual-pointer protocol — right/middle return an error rather than silently degrading to left. `modifier` holds ctrl/shift/alt/super for the click on X11. Native Wayland refuses modified pointer clicks until its input protocol can carry keyboard modifier state.

input_schema:
{
  "additionalProperties": false,
  "properties": {
    "button": {
      "description": "Mouse button. Default: \"left\" (legacy back-compat). X11: routed via ButtonPress/Release with the matching evdev code. Native Wayland: only left-button is supported via the virtual-pointer protocol; right/middle return an error.",
      "enum": [
        "left",
        "right",
        "middle"
      ],
      "type": "string"
    },
    "count": {
      "type": "integer"
    },
    "cursor_id": {
      "description": "Optional multi-cursor instance id. Default: 'default'.",
      "type": "string"
    },
    "delivery_mode": {
      "default": "background",
      "description": "Input delivery mode. 'background' (default) never activates or raises the target window. On X11 it injects via XTEST / the XInput2 master pointer (no focus steal). On Wayland it goes through libei + xdg-desktop-portal, which injects to the compositor's input focus — Wayland's security model has no per-window background targeting, so a specific non-focused window cannot be aimed at; when no libei backend is available the tool returns a structured background_unavailable error. 'foreground' is the explicit escalation: activate the target (X11 _NET_ACTIVE_WINDOW; Wayland compositor activate), inject, then restore the prior active window — a brief focus swap unless the target was already active. Matches the macOS / Windows delivery_mode surface.",
      "enum": [
        "background",
        "foreground"
      ],
      "type": "string"
    },
    "element_index": {
      "description": "Element index from get_window_state. Requires the matching `snapshot_id` alongside it. Prefer `element_token`, which carries both values.",
      "type": "integer"
    },
    "element_token": {
      "description": "Opaque per-snapshot element handle from `structuredContent.elements[].element_token`. If element_index, snapshot_id, or window_id are also supplied they must agree. Returns an explicit stale error once a newer snapshot supersedes it.",
      "type": "string"
    },
    "from_zoom": {
      "description": "Set true after a zoom call to auto-translate zoom-image pixel coordinates back to full-window space.",
      "type": "boolean"
    },
    "modifier": {
      "description": "Modifier keys held during the action: cmd, shift, option/alt, ctrl.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "pid": {
      "type": "integer"
    },
    "scope": {
      "default": "window",
      "enum": [
        "window",
        "desktop"
      ],
      "type": "string"
    },
    "session": {
      "description": "For multi-call work, prefer a short public session label and repeat it on every call that accepts it. Omit it to use the authenticated transport's implicit lifecycle session.",
      "type": "string"
    },
    "snapshot_id": {
      "description": "Snapshot handle from get_window_state. Required when targeting by element_index; stale snapshots fail closed.",
      "pattern": "^s[0-9a-f]{8}$",
      "type": "string"
    },
    "target": {
      "anyOf": [
        {
          "description": "Exact capture/input target selected independently for each action.\n\n`display_id=\"primary\"` is the portable desktop target in this release.\nPlatforms that cannot address another display reject it explicitly rather\nthan silently changing coordinate spaces.",
          "oneOf": [
            {
              "additionalProperties": true,
              "properties": {
                "kind": {
                  "const": "window",
                  "type": "string"
                },
                "pid": {
                  "format": "uint32",
                  "minimum": 0,
                  "type": "integer"
                },
                "window_id": {
                  "format": "uint64",
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "required": [
                "kind",
                "pid",
                "window_id"
              ],
              "type": "object"
            },
            {
              "additionalProperties": true,
              "properties": {
                "display_id": {
                  "type": "string"
                },
                "kind": {
                  "const": "desktop",
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "display_id"
              ],
              "type": "object"
            }
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "window_id": {
      "type": "integer"
    },
    "x": {
      "type": "number"
    },
    "y": {
      "type": "number"
    }
  },
  "required": [],
  "type": "object"
}
