> ## Documentation Index
> Fetch the complete documentation index at: https://hub.hcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> H Platform has three products: the Agents API (managed computer-use agents, base URL https://agp.eu.hcompany.ai/api/v2 or https://agp.hcompany.ai/api/v2 for the US), the Models API (OpenAI-compatible Holo vision-language models at https://api.hcompany.ai/v1), and HoloTab (a free no-code Chrome extension that runs Holo in the user's browser, with recordable routines and schedules). The `holo` CLI (`pip install "hai-agents[cli]"`) runs Agents API agents from a terminal, drives the user's own desktop with `-a h/holo-desktop`, and serves coding agents through `holo mcp`.
> Authenticate with a bearer API key from the HAI_API_KEY environment variable. SDKs: `pip install hai-agents` (Python, `from hai_agents import Client`) and `npm install hai-agents` (TypeScript, `import { HaiAgentsClient } from "hai-agents"`). CLI: `holo`.
> Agents do work in a browser or on a desktop; describe the task as an imperative instruction. To run a task quickly, prefer the pre-built agent `h/web-surfer-flash`. Read results from the session's `latest_answer` after it reaches a terminal status.
> Sessions are the unit of work; wait for a terminal status (completed, failed, timed_out, interrupted) before reading the answer. Use webhooks or the `changes` long-poll endpoint to follow progress.

# Your desktop

> Let an agent work on your own machine, by command or by sight.

> [card] [Shell mode](#shell-mode)
>
> The agent works by command. It runs code, edits files, and drives apps and your Chrome from the same shell.

> [card] [Visual mode](#visual-mode)
>
> The agent works by sight. It looks at the screen, clicks, and types. The default mode.

## Shell mode

The agent gets a shell on your machine. It runs commands, edits files, installs what a task needs, and starts tests and servers. When something only shows in a window, it drives the screen and your Chrome from the same shell.

**1. Install**

```bash theme={"system"}
pip install "hai-agents[cli,workstation]"
```

On Windows, also install [Git for Windows](https://git-scm.com/download/win). Its bash runs the commands.

**2. Create the agent, once**

```python Python theme={"system"}
from hai_agents import Client

client = Client()

client.agents.create_agent(
    name="laptop-coder",
    description="Runs commands and edits files on my machine.",
    environments=[{
        "id": "my-laptop",
        "kind": "desktop",
        "mode": {
            "type": "shell",
            "command_approval": "required",  # ask before each command
        },
    }],
)
```

```bash cURL theme={"system"}
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "laptop-coder",
    "description": "Runs commands and edits files on my machine.",
    "environments": [{
      "id": "my-laptop",
      "kind": "desktop",
      "mode": {"type": "shell", "command_approval": "required"}
    }]
  }'
```

**3. Run it from your project**

```bash CLI theme={"system"}
cd ~/Projects/app
HAI_SHELL_WORKSPACE=. holo -a laptop-coder "Run the tests and fix the one that fails"
```

```python Python theme={"system"}
from hai_agents import Client

client = Client()

session = client.start_session(
    agent="laptop-coder",
    messages="Run the tests and fix the one that fails",
)
result = session.wait_for_completion()  # returns when it ends, or when a command waits
```

`HAI_SHELL_WORKSPACE` is the folder the agent works in. Set it the same way when you start Python.

On macOS, the first session asks for [desktop permissions](https://hub.hcompany.ai/holo-cli/introduction.md#desktop-permissions). To stop the agent, press Esc twice, or run `holo local stop` in any terminal.

**4. Answer when it asks**

`holo` stops before each command that needs approval: `y` approves, `a` approves and always allows, `n` denies. From Python or the API, [answer from code](#answer-from-code).

### What the agent can do

* Run commands, each with a timeout. A server or a watcher keeps running in the background.
* Read, write, and edit files, with its file tools or with commands.
* Look at an image or a screenshot.
* Drive apps and your signed-in Chrome with `cua`, a command line it runs in the shell. In Chrome it opens its own tab and leaves yours alone.
* Send you a file as an [attachment](https://hub.hcompany.ai/agents-api/observe-and-steer.md#get-the-files-the-agent-sends). The file also stays on your disk.

The agent is told to stay in its folder and to install nothing system-wide. Those are instructions. Only [approvals](#approve-commands) and the [sandbox](#sandbox) enforce anything.

### Settings

```python Python theme={"system"}
client.agents.create_agent(
    name="laptop-coder",
    description="Runs commands and edits files on my machine.",
    environments=[{
        "id": "my-laptop",                                   # your name for this environment
        "kind": "desktop",
        "mode": {
            "type": "shell",
            "command_approval": "required",                  # ask before each command
            "allowed_commands": ["git status", "npm test"],  # except these, with any arguments
            "sandbox": "required",                           # run no command without the sandbox
            "allowed_domains": ["github.com"],               # also reach this host
            "writable_folders": ["~/Projects/lib"],          # also write in this folder
        },
    }],
)
```

```bash cURL theme={"system"}
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "laptop-coder",
    "description": "Runs commands and edits files on my machine.",
    "environments": [{
      "id": "my-laptop",
      "kind": "desktop",
      "mode": {
        "type": "shell",
        "command_approval": "required",
        "allowed_commands": ["git status", "npm test"],
        "sandbox": "required",
        "allowed_domains": ["github.com"],
        "writable_folders": ["~/Projects/lib"]
      }
    }]
  }'
```

By default the agent never asks (`"not_required"`), commands are sandboxed where the machine has the sandbox and run as you where it does not (`"if_available"`), and the three lists are empty.

Your machine has the last word. Set these before you start `holo` or Python:

```bash Environment theme={"system"}
export HAI_SHELL_WORKSPACE=~/Projects/app  # folder the agent works in
export HAI_SHELL_POLICY=~/allowlist.txt    # your allowlist, which overrides the agent's
export HAI_SHELL_SANDBOX=1                 # 1 requires the sandbox, 0 turns it off
```

```bash holo local desktop theme={"system"}
holo local desktop --shell \
  --workspace ~/Projects/app \
  --policy ~/allowlist.txt \
  --sandbox ~/.config/hai/sandbox.json  # or --no-sandbox, to run commands as you
```

The allowlist holds one command prefix per line, and a command outside it asks. With the sandbox turned off, commands run as you, and an agent that requires the sandbox does not start. The flags are for when you [serve the desktop yourself](#connect-from-another-client).

### Workspace

The agent works in one folder: a new one under `~/hai/` for each session, or the one `HAI_SHELL_WORKSPACE` names.

* Files you [attach to a message](https://hub.hcompany.ai/agents-api/sessions/send-messages.md#param-files) land in `files/` in the workspace.
* With approvals or the sandbox on, the file tools only act in the workspace, and never inside a `.git` folder.
* With neither on, the agent reaches whatever you can.

### Approvals

With `"command_approval": "required"`, the agent asks before each command, except:

* The agent's `allowed_commands`.
* Commands you chose to always allow on this machine. They are saved in `~/.config/hai/allowed-commands`, which starts with `cua`, the command that drives your screen.

An allowed command covers what starts with it: `git status` allows `git status --short`, and not `git stash`. In a chain with `&&`, `;`, or `|`, every command must be allowed. `$(...)`, backticks, subshells, and redirection to a file always ask.

#### Answer

A command that waits shows in [`pending_approvals`](https://hub.hcompany.ai/agents-api/sessions/status#param-pending-approvals) with its reason, and the session status is `awaiting_tool_results`. Approving runs it once. Denying tells the agent why, so it can try something else.

```text CLI theme={"system"}
Do you want to proceed? [y/a/N]:

y   approve: the command runs once
a   approve, and always allow what starts with it on this machine
n   deny, then tell the agent why
```

```python Python theme={"system"}
session = client.start_session(
    agent="laptop-coder",
    messages="Run the tests and fix the one that fails",
)
result = session.wait_for_completion()  # returns when a command waits

while result.pending_approvals:
    for held in result.pending_approvals:
        command = held.tool_req.args["command"]
        if command.startswith(("pytest", "git diff")):
            session.approve(held.tool_req.id)
        else:
            session.deny(held.tool_req.id, "Only run tests and read diffs.")
    result = session.wait_for_completion(from_index=result.next_from_index)

print(result.status, result.answer)
```

```bash cURL theme={"system"}
curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/tool_approvals \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type": "tool_approval_response", "call_id": "call_1", "action": "deny", "message": "Only run tests and read diffs."}'
```

In [Send tool approvals](https://hub.hcompany.ai/agents-api/sessions/tool-approvals.md), `call_id` is the held call's `tool_req.id`. If nobody can answer, the run ends. That is the case for `holo --json`, `holo --quiet`, a pipe, and a [coding agent](https://hub.hcompany.ai/agents-api/coding-agents.md#local-server). A command still waiting when the session ends is denied.

### Sandbox

On macOS, every command runs inside Anthropic's [sandbox-runtime](https://github.com/anthropics/sandbox-runtime). The SDK downloads it on your first shell session: 41 MB, under `~/.hai/sandbox-runtime`. If the download fails, commands run as you, with a warning at each session.

Inside it, commands can:

* Write in the workspace, and in their own temp and cache folders.
* Read everything you can, except SSH, cloud, npm, pip, and GitHub CLI credentials, the keychain, Chrome's profile, shell history, and environment variables that look like tokens.
* Reach `pypi.org`, `files.pythonhosted.org`, and `registry.npmjs.org`.
* Use git in an existing repository. `git init`, `git clone`, and config changes are blocked.

`allowed_domains` (a host, or a wildcard such as `*.example.com`) and `writable_folders` (absolute, or under `~/`) add to that, and what you added is printed when the session starts. With `github.com` allowed, commands read public repositories over HTTPS. Your SSH keys and git credentials stay unreadable, so the agent commits and you push.

The sandbox does not cover `cua`. Through your mouse and keyboard, the agent can do whatever you can.

To write your own rules, put them in `~/.config/hai/sandbox.json`, in sandbox-runtime's [settings format](https://github.com/anthropics/sandbox-runtime#configuration). The file replaces the built-in rules, and the agent's `allowed_domains` and `writable_folders` with them.

#### Linux and Windows

The sandbox is off until you install it and turn it on.

```bash Linux theme={"system"}
npm install -g --omit=optional @anthropic-ai/sandbox-runtime    # with Node 22.12+
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0   # Ubuntu 24.04 and later
sudo apparmor_parser -R /etc/apparmor.d/bwrap-userns-restrict   # Ubuntu 25.04 and later, also
export HAI_SHELL_SANDBOX=1                                      # turn it on
```

```powershell Windows (alpha) theme={"system"}
npm install -g --omit=optional @anthropic-ai/sandbox-runtime
srt windows-install            # once, as an administrator
$env:HAI_SHELL_SANDBOX = "1"   # turn it on
```

Linux also needs `bubblewrap`, `socat`, and `ripgrep`. A `sandbox.json`, or an agent that requires the sandbox, turns it on too.

* A command made only of `cua` calls runs outside the sandbox, so the agent can see and drive your screen. Mixed with anything else, `cua` stays inside and cannot reach the screen.
* On Windows, commands run as a separate `srt-sandbox` user. Each takes several seconds, and `curl` cannot open HTTPS. `git`, `pip`, and `node` can. sandbox-runtime lists its [known limitations](https://github.com/anthropics/sandbox-runtime#known-limitations).

## Visual mode

The agent looks at the screen, clicks, and types. Use it when the task stays in app windows and the agent needs no shell.

**1. Install**

```bash theme={"system"}
pip install "hai-agents[cli,desktop]"
```

**2. Create the agent, once**

```python Python theme={"system"}
from hai_agents import Client

client = Client()

client.agents.create_agent(
    name="local-desktop",
    description="Drives the desktop on my own machine.",
    environments=[{"id": "my-laptop", "kind": "desktop"}],  # visual is the default mode
)
```

```bash cURL theme={"system"}
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "local-desktop",
    "description": "Drives the desktop on my own machine.",
    "environments": [{"id": "my-laptop", "kind": "desktop"}]
  }'
```

Or skip this step and run `h/holo-desktop`, a ready-made agent.

**3. Run it**

```bash CLI theme={"system"}
holo -a local-desktop "Open Notes and write a short summary of today's standup"
```

```python Python theme={"system"}
from hai_agents import Client

result = Client().run_session(
    agent="local-desktop",
    messages="Open Notes and write a short summary of today's standup",
)
print(result.status, result.answer)
```

**4. Grant desktop permissions**

Your terminal, or the app that launches Python, needs [desktop permissions](https://hub.hcompany.ai/holo-cli/introduction.md#desktop-permissions). The first session asks for them and stops with an error until you grant them. Run it in a normal desktop session, so it can reach the display.

### Settings

```python Python theme={"system"}
client.agents.create_agent(
    name="local-desktop",
    description="Drives the desktop on my own machine.",
    environments=[{
        "id": "my-laptop",                            # your name for this environment
        "kind": "desktop",
        "mode": {"type": "visual", "settle_s": 0.3},  # seconds to wait after each action
        "screenshot_max_width": 1280,                 # shrink screenshots to this width
        "lazy": True,                                 # connect on the first desktop action
    }],
)
```

```bash cURL theme={"system"}
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "local-desktop",
    "description": "Drives the desktop on my own machine.",
    "environments": [{
      "id": "my-laptop",
      "kind": "desktop",
      "mode": {"type": "visual", "settle_s": 0.3},
      "screenshot_max_width": 1280,
      "lazy": true
    }]
  }'
```

`settle_s` takes `0` to `10` and defaults to `0.5`. `screenshot_max_width` takes `1` to `1920` pixels, defaults to `1920`, and never upscales. `lazy` defaults to `False`: the desktop connects when the session starts, with a first screenshot.

The Python SDK and `holo` set `session_id`, the desktop's command channel. Set it yourself only to [connect from another client](#connect-from-another-client).

## Limits

Both modes run on macOS, Windows, and Linux, from the Python SDK and the [`holo` CLI](https://hub.hcompany.ai/holo-cli/introduction#drive-your-desktop). When a session starts, the SDK opens a connection from your process. The agent's actions arrive over it and run on your machine. [Watch and steer](https://hub.hcompany.ai/agents-api/observe-and-steer.md) and [changes](https://hub.hcompany.ai/agents-api/sessions/changes.md) work as in the cloud.

* The agent acts as you. Prefer a dedicated machine over your main one.
* One agent drives a machine at a time. A new session from the same Python process takes over and cancels the earlier one. Another process [waits, then fails](https://hub.hcompany.ai/holo-cli/introduction.md#drive-your-desktop) with `DesktopBusyError`.
* A run stops after 150 steps or 30 minutes by default.
* When your process exits or the connection drops, its sessions are cancelled.
* What the agent sees, runs, and reads goes to H with the session. See [What H receives](https://hub.hcompany.ai/holo-cli/introduction.md#what-h-receives).
* In shell mode with approvals or the sandbox on, each command runs in a shell of its own. Only files carry over from one to the next.
* The [session file endpoints](https://hub.hcompany.ai/agents-api/sessions/list-files.md) serve cloud browsers. In shell mode the files are on your disk.
* [`holo local desktop`](https://hub.hcompany.ai/holo-cli/reference#holo-local) shrinks screenshots before upload.

## Connect from another client

The Python SDK and `holo` connect your machine for you, for an inline agent and for one you name. For a session started from TypeScript, the H Platform, or another machine, serve the desktop yourself. Do the same when `HAI_AUTO_BRIDGE=0` turns auto-connect off.

```bash CLI theme={"system"}
holo local desktop  # leave it running. It prints the session_id it serves

holo run "Open Notes and write a short summary of today's standup" \
  --agent local-desktop \
  -o 'agent.environments[kind=desktop].session_id=<printed id>'  # from the other client
```

For shell mode, serve it with `holo local desktop --shell --workspace ~/Projects/app`. [`holo local`](https://hub.hcompany.ai/holo-cli/reference#holo-local) lists its flags.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.