# How agents see and use a machine

An AI agent sees a machine through screenshots and window controls, and acts on it through OSMates' MCP tools.

The [MCP reference](https://osmates.com/docs/mcp) defines every tool. To connect an agent, see [Connect an agent](https://osmates.com/docs/agents).

## Screenshots and input

An agent takes a screenshot, then acts on coordinates in it, with the screenshot's `frameId` as `frame_id`. After the display changes size or the machine starts again, the `frameId` is stale, and the agent takes a new screenshot.

`input_actions` takes the computer-use actions of Anthropic, OpenAI, and Gemini. Each result is one of these:

| Result | Meaning |
|---|---|
| `verified` | The screen changed |
| `unverified` | The input arrived, but the screen didn't change within a second |
| `failed` | The action failed, and the ones after it didn't run |

Pressed keys and buttons go up when the agent's session ends, even if its program is killed.

## Window controls

On Windows, macOS, and a Linux desktop, the agent reads window controls with `screen_elements`, then acts on a returned reference with `element_action`.

| Argument | Returns |
|---|---|
| `mode: "interactive"` | The controls that take actions |
| `mode: "skeleton"` | The first levels, with a count of their children |
| `since` with a `readId` | Only what changed since that read |

A full read of a large window stops at 32 KiB and has no `readId`. Wayland gives controls no position boxes. On macOS, [allow OSMates Agent](https://osmates.com/docs/macos#let-agents-read-the-controls) once first.

## Text and keys

Text types on the guest's keyboard layout. `type_text` pastes what the layout can't type, and types for at most 30 seconds a call. On Linux it types only on the US layout and pastes otherwise. On macOS, Command and Control shortcuts follow the layout, so Command-V pastes on Dvorak and French layouts too.

`vm_sign_in` signs in with the password in your Keychain, which never appears in a tool result. To give an agent an API token it can use but not read, [grant a credential](https://osmates.com/docs/credentials).

## Long calls and errors

A long call waits `wait_seconds`, 20 by default and 30 at most, then returns a job. The agent follows the job with `job_output`.

`vm_start` and `vm_run` wait while [no machine can start](https://osmates.com/docs/power#start-a-machine), and the job's progress names the running ones. With `queue: false`, the call refuses instead.

A failure explains itself in `error.message`. Its `actions` list calls that recover, with the arguments to supply under `needs`. A `destructive` action discards something, such as saved memory, so an agent runs it only when you asked for that change.

## Machines, networks, and devices

- `vm_create` takes an arm64 Linux disk image as an HTTPS URL with a `checksum`, or as a local file. `user_data` takes cloud-init user-data.
- For a Linux desktop, an agent uses `debian-13-desktop` or `omarchy`, which sign in by themselves and [never lock](https://osmates.com/docs/linux-desktop#turn-the-lock-screen-back-on). Machines an agent creates use the US keyboard.
- `vm_import` brings in another app's machine. It needs the Full profile, and you approve the path each time. With `check`, it creates nothing.
- `vm_egress` can only narrow network access, and only you can widen it or add a rule. A clone keeps the original's access, or narrower with `egress_mode`.
- Only you can [give OSMates a USB device](https://osmates.com/docs/usb#give-a-device-to-osmates). `vm_usb_devices` lists those devices, and `vm_usb_attach` and `vm_usb_detach` need the Full profile and the `usb` permission.

## Run an accessibility tool inside a machine

An agent can run a command-line accessibility tool inside a machine. The tool works on the machine's apps, never on your Mac.

1. Take a snapshot with `vm_snapshot`, or work in a clone, so `vm_revert` removes the tool again.
2. Download the tool with `vm_exec` and `desktop`, then check it against the checksum its release publishes.
3. On macOS, [allow OSMates Agent](https://osmates.com/docs/macos#let-agents-read-the-controls) before the tool starts.
4. Run the tool with `vm_exec` and `desktop`, which reaches the windows `screen_elements` reads. Add `background` for a tool that keeps running, such as a server.
5. Stop it with `job_cancel`.

On Windows, a UI Automation tool needs no permission, but can't use a program that runs as administrator. On a Linux desktop, an AT-SPI tool gets the desktop's display and session bus. On macOS, a tool that opens an app of its own needs the same permission for that app.

## Text from the guest

Text from a machine can hold instructions aimed at your agent, in files, clipboard data, logs, screen text, control names, and host names. Agents must treat it as data.

Guest text is wrapped in `<guest-data>` and `</guest-data>`, and in structured results it's under `guestData`. Control and invisible characters are spelled out, such as `\u{1b}`, so guest text can't close the wrapper. The marks grant nothing: profiles and your permissions decide what the agent can do.

A result holds at most 32 KiB of guest text, and a program returns 16 KiB for each output stream. For the rest, the agent calls `job_output` or `vm_read_file`, or copies the whole file with `vm_pull`.
