# Machine

> Machines: an always-on computer for agents that should never sleep.

> [!NOTE]
> Invite-only beta. [Request access](mailto:support@noclick.com?subject=Invite-only%20beta%20access) to use this page's API; without access, a call answers 404, or `not_available`.

```python
box = noclick.Machine.from_name("support-box", create_if_missing=True, size="medium", region="eu",
                                max_monthly_usd=120)
support = noclick.Agent.from_name("support", create_if_missing=True, instructions="...",
                                  harness="claude_code", model_connection="claude", machine=box)
print(box.exec("df -h /").stdout)
```

An agent on a machine runs its harness there instead of in a sandbox per
conversation: nothing is reaped when it goes quiet, and there's no per-minute
sandbox charge, only the machine's flat monthly price. Each conversation gets
its own container on the machine, so threads never see each other's files.
Model and tool calls go through NoClick's credential proxy with temporary keys:
your real keys are never on the machine. NoClick manages its image and updates,
restarts it if it fails (rebuilding it on a new host from its last backup if it
must), and attached volumes outlive it.

A Linux server you run can be one too, free (`Machine.add_own`): run the
command its `pairing` shows on the server as root, and your agents run there
in containers:

```python
home = noclick.Machine.add_own()
print(home.pairing.command)
# curl -fsSL https://api.noclick.com/machine-agent/v1/machine.sh | sudo sh -s -- --code nc_mach_...
```

## noclick.Machine (invite-only beta)

```python
class Machine
```

An always-on computer of a fixed `size` in one `region`, billed a flat
monthly price. Agents created with `machine=` run their harness on it, each
conversation in a container of its own; `exec`, `files` and `expose` reach
the machine itself. `status` is `provisioning`, `running`, `restarting`,
`updating`, `stopped` or `failed` (`status_reason` says why), or
`awaiting_approval`: rented while NoClick reviews your company, nothing made
or charged yet, it starts once that's approved.

`kind` `own` is a server you added (`Machine.add_own`): free, the size
the server is, its `shell` and `files` as any machine's, its agents in
containers only (no `exec`, ports, `restart`, `stop` or `start`), and
`offline` while it's silent.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` |  |
| `kind` | `str | None` | `noclick`: a machine NoClick runs; `own`: a server you added. |
| `size` | `str | None` | `small`, `medium`, `large` or `xlarge` (`Machine.sizes()`); `None` on your own, which is the size its server is. |
| `host` | `str | None` | The host it runs on, `hetzner` or `digitalocean`, for its life (`None` on your own). |
| `cpu` | `int | None` | vCPUs (hardware threads). |
| `memory_gb` | `int | None` |  |
| `disk_gb` | `int | None` | Its disk. A larger size on Hetzner keeps the disk it had, so a move back down stays a resize. |
| `os` | `str | None` | The server's system, as it reports it (`Ubuntu 24.04.1 LTS`). |
| `hostname` | `str | None` |  |
| `last_seen_at` | `Any` | When it last answered NoClick: on your own machine `offline`, since when. |
| `max_conversations` | `int | None` | Your own machine: the most of its agents' conversations you let work at once (`None`: what the server takes). |
| `conversations_at_once` | `int | None` | How many of its agents' conversations work at once. |
| `agent_share` | `float | None` | Your own machine: the part of its CPUs and memory its agents use (0.75 by default); the rest stays yours. |
| `agent_share_fixed` | `bool | None` | True on a Mac once NoClick's VM is made: a VM keeps its size. |
| `docker` | `bool` | Your own machine: whether its agents' containers run Docker (any `app_testing` but `never`). |
| `app_testing` | `str | None` | Your own machine: whether its agents run apps and test databases: `by_itself`, `ask_first` (the default: each agent asks its owner first) or `never`; an agent on it gets the stricter of this and its own `app_testing`. `never` on a machine NoClick runs. |
| `workspaces` | `str | None` | Where each conversation's workspace (`/workspace`) lives: `local` (your own machine's default: on its disk alone, never saved, so a turn ends without waiting on a save; a conversation that starts elsewhere starts with an empty one) or `saved` (in NoClick's volumes, saved after every turn; always on a machine NoClick runs). |
| `agents_enabled` | `bool | None` | Whether agents run on machines on this API yet (`Machine.agents_enabled_here()`). |
| `region` | `str | None` | The region it runs in (`noclick.regions()`), fixed when it was created. |
| `status` | `str | None` |  |
| `status_reason` | `str | None` | Why it's stopped or failed, or why it restarted. |
| `monthly_usd` | `float | None` | What it costs a month on its host, in US dollars, running or stopped (0 for your own). |
| `max_monthly_usd` | `float | None` | The most you agreed it may cost a month. |
| `network` | `Any` | What its own commands may reach: `True` (anywhere the machines usage policy allows) or the hosts. |
| `volumes` | `dict[str, str] | None` | The volumes it mounts, by path: `{path: volume id}`. |
| `agent_count` | `int | None` | How many agents run on it. |
| `working_count` | `int | None` | How many of its agents are working now, from its last check-in. |
| `agent_states` | `list[dict[str, Any]]` | Each agent on it, `{agent_id, working}`: working while one of its conversations there is. |
| `spent_usd_this_month` | `float | None` | What it was charged this month (UTC) so far, in US dollars. |
| `started_at` | `Any` | When it last booted, while it runs: its uptime. |
| `pending` | `dict[str, Any] | None` | While `updating`: `{size, move}`, the size it becomes and whether it moves to a new host. |
| `image` | `str | None` | The NoClick-managed image it runs, with its harness versions. |
| `restarts` | `int | None` | How many times it restarted after failing, ever. |
| `last_restart_at` | `Any` |  |
| `user_id` | `str | None` |  |
| `created_at` | `Any` |  |
| `files` | `MachineFiles` |  |
| `health` | `MachineHealth | None` | How hard it works, from its last check-in while it runs; `None` otherwise. |
| `ports` | `list[MachinePort]` | The ports it serves. |
| `pairing` | `MachinePairing | None` | Your own machine until its server is set up; `None` after, and on a machine NoClick runs. |
| `console_url` | `str | None` | This machine in the developer console (None off the hosted API). |

### Machine.sizes

```python
noclick.Machine.sizes(
    *, region=None, include_dominated=False, client=None
) -> list[MachineSize]
```

The sizes worth buying now, smallest first: size first, each at its cheapest anywhere, or as
bought in `region` (`noclick.regions()`). A size that can't be bought now is left out, as is
one where another that can be bought has at least its vCPUs and memory for no more (judged
across every region, or in `region`; a larger disk alone doesn't count).
`include_dominated=True` lists every size, each with `available` and `dominated_by`.

Parameters:

- `region` (`str | None`, default `None`)
- `include_dominated` (`bool`, default `False`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[MachineSize]` Each size's `name` (what `size=` takes), its processors and memory, about how many
conversations can work on it at once, and its cheapest offer now: the `region`, the
`host` it would go on and its `disk_gb` and `monthly_usd` there. `regions` lists every
region it can be bought in now, cheapest first, and `hosts` each host that runs it here.
Stock is read at most a minute before; `create` checks again.

Usage:

```python
size = noclick.Machine.sizes()[0]
print(size.name, size.region, size.host, size.monthly_usd)   # small eu hetzner 8.39
box = noclick.Machine.create("support-box", size=size.name, region=size.region, host=size.host,
                             max_monthly_usd=size.monthly_usd)
```

### Machine.create

```python
noclick.Machine.create(
    name, *, size='small', region=None, volumes=None, network=None, max_monthly_usd,
    host=None, allow_existing=False, user=..., client=None
) -> Machine
```

Start an always-on machine called `name` (unique to its user; a taken
name raises `noclick.Conflict` with `existing_id`, or with `allow_existing=True`
returns the machine already there, as it is: nothing about it changes). `size` is one of
`Machine.sizes()`; `region` (`noclick.regions()`) is where it runs, for
good, else your account's default region, else `us-east`. `volumes`
attaches `Volume`s (or their ids or names) at absolute paths: each
conversation sees a volume as it was when its turn started and saves its
writes when the turn ends. `network` is what the machine's own commands may
reach: `True` (the default: anywhere the machines usage policy allows, so no
mail ports, mining pools or private addresses) or a list of hosts (HTTPS to them,
`"*.github.com"` for subdomains, and name lookups). It's charged to your
account from the day it first runs, a thirtieth of its monthly price a day
while it exists, running or stopped, and refused (`noclick.PriceExceeded`,
nothing started) if its size costs more than `max_monthly_usd` on the host it goes on. It goes
on the cheapest host that runs the size in the region and has stock for it (Hetzner in
`eu`, DigitalOcean everywhere; `Machine.sizes()` lists each host's price and disk),
never one costing more than `max_monthly_usd`: when only a dearer host has stock, that
raises `noclick.PriceExceeded` naming the host and its price. `host` names one instead
(only it is tried). A machine stays on its host for its life. An account's
first machine needs its company vetted by NoClick: its owner asks in the
developer console (Resources, Machines), saying what its machines will run,
and until NoClick approves it this raises `noclick.ActionRequired`, whose
`next_step` links that page.

Parameters:

- `name` (`str`, required)
- `size` (`str`, default `'small'`)
- `region` (`str | None`, default `None`)
- `volumes` (`Mapping[str, Any] | None`, default `None`)
- `network` (`bool | list[str] | None`, default `None`)
- `max_monthly_usd` (`float`, required)
- `host` (`Literal['hetzner', 'digitalocean'] | None`, default `None`)
- `allow_existing` (`bool`, default `False`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Machine` The machine, `provisioning` until it's ready (`running`).

Usage:

A machine in Europe for a team of agents, with their shared files:

```python
box = noclick.Machine.create(
    "support-box", size="medium", region="eu", max_monthly_usd=120,
    volumes={"/shared": noclick.Volume.from_name("support-kb", create_if_missing=True)},
)
print(box.status, box.monthly_usd)
```

### Machine.add_own

```python
noclick.Machine.add_own(
    *, name=None, max_conversations=None, agent_share=None, docker=None,
    app_testing=None, workspaces=None, client=None
) -> Machine
```

Add a Linux server you run (x86-64 or ARM64, with sudo) as a machine your
account's agents run on, in containers: free, its agents' model calls at
cost. Its containers can't reach its network, and on the server itself
NoClick only opens the account owner's `shell` and `files`, as its
`noclick` user. Run `pairing.command` on it as root within 30
minutes. Without `name` it takes the server's hostname;
`max_conversations` caps how many
of its agents' conversations work at once; `agent_share` is the part of
the server they use (0.1 to 1; 0.75 by default, 1 for a server just for
NoClick; on a Mac, NoClick's VM is made that size); `app_testing` is whether
its agents run apps and test databases (`"ask_first"` unless it says: each
agent asks its owner in the chat first; `"by_itself"`; `"never"`), each
conversation's container then running its own Docker inside its gVisor sandbox
(no host socket, nothing privileged on the server; a container whose agent's
network is limited runs without it); `docker` alone chooses `"by_itself"`
(true) or `"never"` (false); `workspaces` is where each conversation's
workspace lives (`"local"` unless it says: on the server's disk alone, kept
across its containers and never saved, so a turn ends without waiting on a
save, and a conversation that starts elsewhere or whose agent leaves starts
with an empty one; `"saved"`: in NoClick's volumes, saved after every turn).
Either way, a checkout kept on the server borrows from its repo cache, package
managers share their caches, and its volumes are mounted read-only. Called again before a
server pairs, it returns that same machine, with its code while the code is
good and a new one once it expired: add one per server, after the last one
paired. The account's own, never a user's (`as_user` doesn't apply).

Parameters:

- `name` (`str | None`, default `None`)
- `max_conversations` (`int | None`, default `None`)
- `agent_share` (`float | None`, default `None`)
- `docker` (`bool | None`, default `None`)
- `app_testing` (`str | None`, default `None`)
- `workspaces` (`str | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Machine` The machine, `provisioning` until the server answers, then `running`
(`offline` while it's silent: its agents' turns fail then), with its
`pairing`.

Usage:

```python
home = noclick.Machine.add_own()
print(home.pairing.command)
# On the server: curl -fsSL https://api.noclick.com/machine-agent/v1/machine.sh | sudo sh -s -- \
#     --code nc_mach_...
```

### Machine.agents_enabled_here

```python
noclick.Machine.agents_enabled_here(*, client=None) -> bool
```

Whether agents run on machines on this API yet. Until they do, an agent
isn't put on a machine and your own server isn't added
(`noclick.NotAvailable`), and each machine reads `agents_enabled` False.

Parameters:

- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `bool` True once agents run on machines here.

Usage:

```python
if noclick.Machine.agents_enabled_here():
    home = noclick.Machine.add_own()
```

### Machine.from_name

```python
noclick.Machine.from_name(
    name, *, create_if_missing=False, size=None, region=None, volumes=None,
    network=None, max_monthly_usd=None, host=None, user=..., client=None
) -> Machine
```

A lazy reference to the machine called `name` in the current (or given)
user. Given fields, it gets the machine and sets the `size`, `volumes`, `network` and
`max_monthly_usd` you pass, on every run (a new size restarts it, judged against the
`max_monthly_usd` set with it). Fields you leave out are never changed. Its `region` and
`host` are fixed: an existing machine in another raises `noclick.Conflict` naming it.
`create_if_missing=True` starts it with the fields `create` takes when there's none
(`max_monthly_usd` is required then); without it, a missing machine raises
`noclick.NotFound`.

Parameters:

- `name` (`str`, required)
- `create_if_missing` (`bool`, default `False`)
- `size` (`str | None`, default `None`)
- `region` (`str | None`, default `None`)
- `volumes` (`Mapping[str, Any] | None`, default `None`)
- `network` (`bool | list[str] | None`, default `None`)
- `max_monthly_usd` (`float | None`, default `None`)
- `host` (`Literal['hetzner', 'digitalocean'] | None`, default `None`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Machine` A machine that loads (or is started, or has your fields set) the first time it's used.
Nothing is sent yet.

Usage:

```python
box = noclick.Machine.from_name("support-box", create_if_missing=True, size="medium", max_monthly_usd=120)
print(box.status)
```

### Machine.from_id

```python
noclick.Machine.from_id(machine_id, *, client=None, user=...) -> Machine
```

A lazy reference to a machine by id.

Parameters:

- `machine_id` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).

Returns: `Machine` A machine that loads the first time you read a field. Nothing is sent yet.

Usage:

```python
box = noclick.Machine.from_id("3b9e2c71-4f0d-4a68-9c15-7e2a8d1f6b40")
print(box.exec("uptime").stdout)
```

### Machine.get

```python
noclick.Machine.get(machine_id, *, user=..., client=None) -> Machine
```

Load a machine by id now; an unknown id raises `noclick.NotFound`.

Parameters:

- `machine_id` (`str`, required)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Machine` The machine, loaded.

Usage:

```python
box = noclick.Machine.get("3b9e2c71-4f0d-4a68-9c15-7e2a8d1f6b40")
print(box.name, box.status, box.agent_count)
```

### Machine.list

```python
noclick.Machine.list(
    *, kind=None, limit=None, user_filter=None, user=..., client=None
) -> list[Machine]
```

The current user's machines (the account's own outside `as_user`, or those `user_filter` covers);
`kind` (`noclick` or `own`) narrows them.

Parameters:

- `kind` (`str | None`, default `None`)
- `limit` (`int | None`, default `None`): Return at most this many.
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[Machine]` Every matching machine, newest first, fetched page by page.

Usage:

```python
for box in noclick.Machine.list(user_filter=noclick.ALL_USERS):
    print(box.name, box.region, box.status, box.monthly_usd)
print([box.name for box in noclick.Machine.list(kind="own") if box.status == "offline"])
```

### Machine.list_page

```python
noclick.Machine.list_page(
    *, kind=None, cursor=None, limit=None, user_filter=None, user=..., client=None
) -> Page
```

One page of machines; pass `next_cursor` back as `cursor`.

Parameters:

- `kind` (`str | None`, default `None`)
- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.
- `limit` (`int | None`, default `None`): Return at most this many.
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Page` A page whose `data` holds the machines and whose `next_cursor` is `None` on the last page.

Usage:

```python
page = noclick.Machine.list_page(limit=50)
print([box.name for box in page.data], page.next_cursor)
```

### Machine.exec

```python
machine.exec(command, *, background=False, timeout_s=None) -> ExecResult | Operation
```

Run a shell command on the machine itself (not in a conversation's
container) and wait for it: `timeout_s` is 60 by default, at most 90.
`background=True` runs it as an operation, up to an hour.

Parameters:

- `command` (`str`, required)
- `background` (`bool`, default `False`)
- `timeout_s` (`int | None`, default `None`)

Returns: `ExecResult | Operation` What the command printed and how it exited, or with `background=True` an `Operation`
whose `wait()` gives that result.

Usage:

```python
box = noclick.Machine.from_name("support-box")
print(box.exec("df -h /").stdout)
backup = box.exec("tar czf /shared/backup.tgz /home/noclick", background=True, timeout_s=1800)
print(backup.wait().exit_code)
```

### Machine.expose

```python
machine.expose(port, *, public=False) -> MachinePort
```

Serve `port` at an HTTPS URL on NoClick's domain: a dashboard or a webhook
receiver your agents run. A private port asks for an API key with the
`machines` scope, which the app never sees; `public=True` answers anyone.

Parameters:

- `port` (`int`, required)
- `public` (`bool`, default `False`)

Returns: `MachinePort` The port's `url`.

Usage:

```python
box = noclick.Machine.from_name("support-box")
dashboard = box.expose(8080)
print(dashboard.url)
```

### Machine.close_port

```python
machine.close_port(port) -> None
```

Stop serving `port`; its URL stops answering.

Parameters:

- `port` (`int`, required)

Usage:

```python
noclick.Machine.from_name("support-box").close_port(8080)
```

### Machine.agents

```python
machine.agents() -> list[Any]
```

The agents that run on it.

Returns: `list[Any]` Each `Agent`, loaded.

Usage:

```python
box = noclick.Machine.from_name("support-box")
print([agent.name for agent in box.agents()])
```

### Machine.update

```python
machine.update(
    *, name=..., size=..., volumes=..., network=..., max_monthly_usd=...,
    max_conversations=..., agent_share=..., docker=..., app_testing=...,
    workspaces=...
) -> Machine
```

Rename it, change its size, volumes, network or price ceiling. New volumes and
network apply without a restart (each conversation's from its next turn). A larger
size restarts it once running turns finish (`updating`); the new price applies
from the next day. A smaller size moves a running machine to a new host, since no
host shrinks a disk in place: its user's home is copied over and each conversation
loads its files from where they're saved, a longer restart (what's on its disk
must fit the smaller one; a move that fails leaves it on its old host).
Your own machine takes `max_conversations` (`None`: what its server takes)
`agent_share` (`None`: 0.75), `app_testing`, `docker` and `workspaces` (as in `add_own`)
instead of a size or a price; its server takes them within seconds, each conversation's
container at its next start.

Parameters:

- `name` (`Any`, default: unchanged)
- `size` (`Any`, default: unchanged)
- `volumes` (`Any`, default: unchanged)
- `network` (`Any`, default: unchanged)
- `max_monthly_usd` (`Any`, default: unchanged)
- `max_conversations` (`Any`, default: unchanged)
- `agent_share` (`Any`, default: unchanged)
- `docker` (`Any`, default: unchanged)
- `app_testing` (`Any`, default: unchanged)
- `workspaces` (`Any`, default: unchanged)

Returns: `Machine` This machine, updated.

Usage:

```python
box = noclick.Machine.from_name("support-box")
box.update(size="large", max_monthly_usd=240)
```

### Machine.new_pairing_code

```python
machine.new_pairing_code() -> Machine
```

Your own machine, until its server is set up: a new one-time code (and
command) in place of the last one, which stops working.

Returns: `Machine` This machine, with the new `pairing`.

Usage:

```python
home = noclick.Machine.get("7c1d9a20-2b6f-4e0a-9d51-3f8e6a4b2c10")
print(home.new_pairing_code().pairing.command)
```

### Machine.restart

```python
machine.restart() -> Operation
```

Restart it now, without waiting for running turns (they fail as interrupted).
Its disk and volumes are kept; a `machine.restarted` event follows.

Returns: `Operation` An `Operation` whose `wait()` gives the machine, `running` again.

Usage:

```python
box = noclick.Machine.from_name("support-box")
print(box.restart().wait().status)   # running
```

### Machine.stop

```python
machine.stop() -> Machine
```

Stop it: its agents take no turns (a message raises `noclick.NotAvailable`)
until `start()`. It's still charged, since it stays yours.

Returns: `Machine` This machine, `stopped`.

Usage:

```python
noclick.Machine.from_name("support-box").stop()
```

### Machine.start

```python
machine.start() -> Machine
```

Start a stopped machine. One stopped because the balance couldn't pay it
is charged what it owes first (`noclick.PaymentRequired` while it can't).

Returns: `Machine` This machine, `provisioning` until it's `running`.

Usage:

```python
noclick.Machine.from_name("support-box").start()
```

### Machine.shell

```python
machine.shell() -> MachineShell
```

Open a shell (`bash -l`) on this machine, as its user, in its home: for the account's owner, with
its secret key or signed in, while it's running. Your own machine's too (on a Mac, in NoClick's VM
there). `noclick machines ssh <name>` opens one in your own terminal.

Returns: `MachineShell` The websocket's `url` and its single-use `token` (good for two minutes): hand them to a browser
terminal (xterm.js) from your server.

Usage:

```python
box = noclick.Machine.from_name("support-box")
opened = box.shell()
send_to_browser(opened.url, opened.token)
```

### Machine.delete

```python
machine.delete() -> None
```

Delete it, with its disk; attached volumes stay. The agents on it go
back to their own cloud sandboxes first, each from its next turn. The
charge stops that day. Your own machine is removed from NoClick, which
uninstalls itself from the server when it next answers.

Usage:

```python
box = noclick.Machine.from_name("support-box")
moving = box.agents()   # what goes back to sandboxes
box.delete()
```

## noclick.MachineSize (invite-only beta)

```python
class MachineSize
```

One of `Machine.sizes()`: its processors and memory, and how it's bought now. `region`, `host`,
`disk_gb` and `monthly_usd` are its cheapest offer anywhere (or, asked about a region, there); `regions`
lists every region it can be bought in now, cheapest first, and `hosts` each host that runs it. Stock is read at
most a minute before; `create` checks again, so pass `region`, `host` and `monthly_usd` (as
`max_monthly_usd`) to buy exactly this.

| Attribute | Type | Description |
| --- | --- | --- |
| `name` | `str` | What `size=` takes: `small`, `medium`, `large` or `xlarge` (Hetzner's alone, so in `eu` only). |
| `cpu` | `int` | vCPUs (hardware threads), as hosts sell them. |
| `memory_gb` | `int` |  |
| `disk_gb` | `int` | The machine's own disk on `host` (while it isn't available, on the first host that sells it). |
| `monthly_usd` | `float` | Its price per month in US dollars on `host` in `region` (while it isn't available, the price it has once the first host that sells it has one again). |
| `working_conversations` | `int` | About how many coding-agent conversations can work on it at the same moment. |
| `available` | `bool` | Whether it can be bought now (only `False` with `include_dominated=True`). |
| `region` | `str | None` | Where it's cheapest now (the account's default region first at one price), or the region asked about; `None` when it can't be bought anywhere. |
| `host` | `str | None` | The host a new one would go on there now; `None` while it can't be bought. |
| `dominated_by` | `str | None` | A size that can be bought now with at least its vCPUs and memory for no more (only listed with `include_dominated=True`); `None` when there's none. |
| `regions` | `list[MachineSizeRegion]` | Each region it can be bought in now, cheapest first: the host, disk and price there. |
| `hosts` | `list[MachineHost]` | Each host that runs it, cheapest first: its regions, disk and price there. |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.MachineSizeRegion (invite-only beta)

```python
class MachineSizeRegion
```

A region a size can be bought in now (`MachineSize.regions`, cheapest first): the host a new one would go
on there, and its disk and flat monthly price there.

| Attribute | Type | Description |
| --- | --- | --- |
| `region` | `str` | The region (`noclick.regions()`): what `create` takes as `region=`. |
| `host` | `str` | The host a new one would go on there now, `hetzner` or `digitalocean`: what `create` takes as `host=`. |
| `disk_gb` | `int` | Its disk on that host. |
| `monthly_usd` | `float` | Its price per month in US dollars on that host: what `create` takes as `max_monthly_usd=`. |
| `dominated_by` | `str | None` | A size that can be bought there now with at least its vCPUs and memory for no more, which makes this one no buy there (only listed with `include_dominated=True`); `None` when there's none. |

## noclick.MachineHost (invite-only beta)

```python
class MachineHost
```

A size on one host (`MachineSize.hosts`): where it runs, its disk there and its flat monthly price there.

| Attribute | Type | Description |
| --- | --- | --- |
| `host` | `str` | What `host=` takes: `hetzner` or `digitalocean`. |
| `regions` | `list[str]` | The regions it runs in on this host (`noclick.regions()`). |
| `disk_gb` | `int` |  |
| `monthly_usd` | `float` | Its price per month in US dollars on this host, whatever it runs and whether it's busy. |

## noclick.MachinePort (invite-only beta)

```python
class MachinePort
```

A port a machine serves. `url` reaches it over HTTPS; a private port asks
for an API key with the `machines` scope (`Authorization: Bearer`), a public
one answers anyone.

| Attribute | Type | Description |
| --- | --- | --- |
| `port` | `int` |  |
| `url` | `str` |  |
| `public` | `bool` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.MachinePairing (invite-only beta)

```python
class MachinePairing
```

Your own machine until its server is set up: the one-time `code` and the
`command` that carries it, which NoClick only shows as it makes them (a
machine read again has both `None`), when the code stops working, and the
server being set up with it once its installer started.

| Attribute | Type | Description |
| --- | --- | --- |
| `code` | `str | None` |  |
| `command` | `str | None` | What to run on the server as root (a Linux server's, or a Linux distro's in WSL on Windows). |
| `expires_at` | `Any` | 30 minutes after the code was made; `new_pairing_code()` makes another. |
| `installing_on` | `str | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `refused` | `MachineRefusal | None` | The last server turned away with the code, and why (None since the code was made, or once one pairs). |
| `commands` | `dict[str, str] | None` | The command for each system: `"linux"` (`command`) and `"mac"`, run in Terminal as you, never root; and each with `--yes` to install unattended (SSH, cloud-init, a script): `"linux_unattended"`, `"mac_unattended"`. |

## noclick.MachineRefusal (invite-only beta)

```python
class MachineRefusal
```

A server turned away with your own machine's code, newest first: by NoClick (its system, or the code
expired) or by the installer itself. Cleared by a new code or a server that pairs.

| Attribute | Type | Description |
| --- | --- | --- |
| `system` | `str | None` |  |
| `arch` | `str | None` |  |
| `hostname` | `str | None` |  |
| `message` | `str` | What the server's terminal printed, whole. |
| `next_step` | `str | None` | What to do, where NoClick knows it. |
| `at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.MachineFiles (invite-only beta)

```python
class MachineFiles
```

`machine.files`: read and write files on the machine's own disk.

### MachineFiles.write

```python
machine.files.write(path, data) -> None
```

Write `data` (bytes, or text as UTF-8) to `path` (relative paths are under `/home/noclick`).

Parameters:

- `path` (`str`, required)
- `data` (`bytes | str`, required)

Usage:

```python
box = noclick.Machine.from_name("support-box")
box.files.write("/etc/noclick/notes.md", "Restart the worker after deploys.")
```

### MachineFiles.read

```python
machine.files.read(path) -> bytes
```

Read the file at `path`; a missing file raises `noclick.NotFound`.

Parameters:

- `path` (`str`, required)

Returns: `bytes` The file's bytes, exactly as stored.

Usage:

```python
box = noclick.Machine.from_name("support-box")
print(box.files.read("/var/log/worker.log").decode()[-2000:])
```

### MachineFiles.list

```python
machine.files.list(path='/home/noclick') -> list[MachineFileEntry]
```

The files and folders in the folder at `path` (relative paths are under `/home/noclick`, the
machine user's home), by name.

Parameters:

- `path` (`str`, default `'/home/noclick'`)

Returns: `list[MachineFileEntry]` Each entry's `path`, `type` (`file` or `directory`), `size` and `updated_at`.

Usage:

```python
box = noclick.Machine.from_name("support-box")
for entry in box.files.list("logs"):
    print(entry.type, entry.path, entry.size)
```

## noclick.MachineFileEntry (invite-only beta)

```python
class MachineFileEntry
```

A file or folder on a machine's disk (`machine.files.list`).

| Attribute | Type | Description |
| --- | --- | --- |
| `path` | `str` |  |
| `type` | `str` | `file` or `directory`. |
| `size` | `int | None` | A file's bytes (`None` for a folder). |
| `updated_at` | `Any` |  |

## noclick.MachineHealth (invite-only beta)

```python
class MachineHealth
```

How hard a running machine works, from its last check-in (`machine.last_seen_at`).

| Attribute | Type | Description |
| --- | --- | --- |
| `cpus` | `int | None` | Its vCPUs (your own: the server's). |
| `load_1m` | `float` | Its one-minute load average, and that as a part of its vCPUs kept busy (at most 100). |
| `cpu_percent` | `int | None` |  |
| `memory_used_gb` | `float` | Memory in use and in all (your own: the whole server's; its agents use `agent_share` of it). |
| `memory_total_gb` | `float` |  |
| `disk_used_gb` | `float` |  |
| `disk_total_gb` | `float` |  |

## noclick.MachineShell (invite-only beta)

```python
class MachineShell
```

A shell on a machine NoClick runs (`machine.shell()`): `url` is a websocket, opened once with `token`
within two minutes. Its first message is `{"type": "auth", "token": ..., "cols": ..., "rows": ...}`; then binary
messages carry what you type and what it prints, a text `{"type": "resize", "cols", "rows"}` sizes it, and it
sends `{"type": "ready"}` once and `{"type": "state", "state": "exited", "reason"}` as it closes (code 4410):
bash exited, `idle_limit_s` passed with nothing typed, or the socket closed. It closes 4401 once its key is
revoked or expires and 4404 once the machine is deleted. A client that says it renews (`"renew": true` in its
first message) lasts 15 minutes at a time: asked `{"type": "renew"}`, it answers `{"type": "renew", "token": ...}` with a new `machine.shell()` token and bash goes on, else it closes with code 4000.

| Attribute | Type | Description |
| --- | --- | --- |
| `machine_id` | `str` |  |
| `url` | `str` |  |
| `token` | `str` |  |
| `token_expires_at` | `Any` |  |
| `idle_limit_s` | `int` |  |
