|
| 1 | +Canonical Computer-Use Action Schema |
| 2 | +==================================== |
| 3 | + |
| 4 | +``tool_use_schema`` exports the AC_* command *signatures* as tool definitions and |
| 5 | +``coordinate_space`` rescales a model grid — but neither *normalizes an inbound action |
| 6 | +payload*. Anthropic's computer-use tool emits ``{action:"left_click", |
| 7 | +coordinate:[x,y]}``, OpenAI's CUA emits ``{type:"click", x, y, button}`` — there was no |
| 8 | +adapter mapping these heterogeneous shapes onto a canonical action and then onto a |
| 9 | +runnable AC_* command, so integrators hand-wrote the glue. |
| 10 | + |
| 11 | +Pure-stdlib dict mapping (an optional ``scale`` callable applies coordinate-space |
| 12 | +rescaling), fully headless-testable. Imports no ``PySide6``. |
| 13 | + |
| 14 | +Headless API |
| 15 | +------------ |
| 16 | + |
| 17 | +.. code-block:: python |
| 18 | +
|
| 19 | + from je_auto_control import (from_anthropic, from_openai_cua, to_ac_command, |
| 20 | + canonical_action) |
| 21 | +
|
| 22 | + # Anthropic agent output -> canonical -> runnable AC action. |
| 23 | + canonical = from_anthropic({"action": "left_click", "coordinate": [120, 80]}) |
| 24 | + command = to_ac_command(canonical) |
| 25 | + # -> ["AC_click_mouse", {"mouse_keycode": "mouse_left", "x": 120, "y": 80}] |
| 26 | +
|
| 27 | + # OpenAI CUA, with model->physical coordinate rescaling. |
| 28 | + cmd = to_ac_command(from_openai_cua({"type": "scroll", "x": 5, "y": 6, |
| 29 | + "scroll_y": 120}), |
| 30 | + scale=lambda x, y: (x * 2, y * 2)) |
| 31 | +
|
| 32 | +``from_anthropic`` / ``from_openai_cua`` map each provider's payload to a canonical |
| 33 | +``{type, x, y, text, …}`` (clicks, double/right/middle click, move, type, key, scroll, |
| 34 | +screenshot). ``to_ac_command`` maps a canonical action to a ``[command_name, params]`` |
| 35 | +AC action (``AC_click_mouse`` / ``AC_set_mouse_position`` / ``AC_write`` / ``AC_hotkey`` |
| 36 | +/ ``AC_mouse_scroll`` / ``AC_screenshot``), applying ``scale`` to coordinates; an |
| 37 | +unmapped type raises ``AutoControlActionException``. ``canonical_action`` builds a |
| 38 | +canonical dict directly. |
| 39 | + |
| 40 | +Executor command |
| 41 | +---------------- |
| 42 | + |
| 43 | +``AC_cua_command`` normalizes a ``payload`` from ``source`` (``anthropic`` / ``openai`` |
| 44 | +/ ``canonical``) and returns ``{canonical, command}``. It is exposed as the MCP tool |
| 45 | +``ac_cua_command`` and as a Script Builder command under **Native UI**. |
0 commit comments