Action Reference
Complete action-level reference for the computer_use tool and the ComputerUseHost contract in Namzu.
The computer_use tool exposes one discriminated action union. This page is the action-by-action reference you can use when building prompts, tests, or MCP-facing docs.
1. Coordinate Model
All pointer coordinates are:
- logical pixels
- measured from the top-left of the primary display
- interpreted by the current host adapter
In practice, the safest sequence for GUI work is:
- take a screenshot
- inspect the returned image dimensions
- choose coordinates inside those bounds
- move or click
2. Action Matrix
| Action type | Input shape | Result shape | Required capability | Destructive |
|---|---|---|---|---|
screenshot | { type: 'screenshot' } | base64 PNG via ToolResult.output | screenshot | No |
cursor_position | { type: 'cursor_position' } | current { x, y } | cursorPosition | No |
mouse_move | { type: 'mouse_move', to: { x, y } } | ok | mouse | No |
mouse_click | { type: 'mouse_click', at: { x, y }, button } | ok | mouse | Yes |
mouse_drag | { type: 'mouse_drag', from: { x, y }, to: { x, y }, button } | ok | mouse | Yes |
scroll | { type: 'scroll', at: { x, y }, direction, amount } | ok | mouse | Yes |
type_text | { type: 'type_text', text } | ok | keyboard | Yes |
key | { type: 'key', keys } | ok | keyboard | Yes |
3. Screenshot
Input:
Tool result behavior:
ToolResult.outputcontains base64 PNG dataToolResult.dataincludes:mimeTypewidthheightencoding: 'base64'
Use screenshot first whenever the model or operator needs visual grounding.
4. Cursor Position
Input:
Returns:
This action only works when the adapter exposes cursorPosition: true.
5. Mouse Actions
5.1 mouse_move
Use it when the next action needs pointer positioning without immediate input.
5.2 mouse_click
Buttons:
leftrightmiddle
This action is marked destructive because it changes UI state.
5.3 mouse_drag
Use drag for:
- slider movement
- selection
- window repositioning
- drag-and-drop UI
5.4 scroll
Directions:
updownleftright
amount must be a positive integer.
6. Keyboard Actions
6.1 type_text
Use it when literal text entry is intended.
6.2 key
Examples:
ReturnEscapectrl+ccmd+shift+talt+tab
Use key for shortcuts or special keys rather than raw text entry.
7. Host Contract vs Tool Result
At the host layer, ComputerUseHost.execute(action) returns:
screenshotcursor_positionok
At the tool layer, createComputerUseTool() converts that into standard ToolResult output. That is why screenshots appear as base64 output instead of raw buffers when invoked through the SDK tool surface.
8. Capability Gating
The tool wrapper checks the host's capability map before executing an action. If the capability is missing, the tool fails clearly instead of hanging.
Typical examples:
cursor_positionon Wayland often fails becausecursorPositionis falsemouse_moveon macOS may require optional tooling for richer mouse support- keyboard input can fail if the host session is not interactive
9. Recommended Action Patterns
9.1 Visual-first navigation
screenshot- inspect image
mouse_movemouse_click
9.2 Form entry
mouse_clickto focustype_textkeywithReturnorTabas needed
9.3 Scrolling through content
screenshotscrollscreenshotagain to confirm state change