Metadata-Version: 2.4
Name: awx
Version: 0.3.0
Summary: Python client and awx command-line tool for awx: computers with a desktop, for agents.
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27

# awx

A small Python client and the `awx` command-line tool for awx (computers with a desktop, for agents).
It needs only `httpx`.

Python 3.10 or newer.

```
pip install https://awanbox.com/sdk/awx-0.3.0-py3-none-any.whl     # or: pip install ./sdk/python  (from the repository)
awx login --key bx_...                                              # the key: Account, API keys; the address defaults to https://api.awanbox.com
# docs: https://awanbox.com/docs/sdk/
```

A key is all you need (`AWX_API_KEY` works instead of `--key`). Only for a server you run yourself behind Cloudflare Access:
`--cf-id ... --cf-secret ...` (or `AWX_CF_CLIENT_ID` and `AWX_CF_CLIENT_SECRET`).

## Command line

```
awx sandbox create --name demo --size large         # small or large
awx sandbox rename demo my-site                     # new name; id, links and files stay
awx sandbox tags my-site team:ml                    # replaces all tags; --clear removes them
awx chat rename ch_1234abcd Planning notes
awx sandbox exec demo -- python3 -c "print(6*7)"
awx sandbox upload demo ./app.py /home/agent/app.py
awx sandbox download demo /home/agent/out.csv ./out.csv
awx sandbox preview demo --port 8000                # a public https link (up to 1 hour on the Free plan; --ttl 7d on the paid plan)
awx sandbox name demo mysite --port 8000            # a permanent name: mysite.<our domain>
awx sandbox schedule demo --days mon-fri --from 09:00 --to 18:00 --tz Asia/Kuala_Lumpur
awx sandbox resize demo large                          # files stay
awx sandbox shot demo                               # the desktop as demo.png
awx sandbox view demo --control                     # a link to take over the desktop yourself
awx chat ask "build a hello page and share it" --size large
awx workspace list
awx notices --unread
awx mcp add docs https://mcp.example.com/mcp --token ...
```

`awx --json ...` prints JSON. `awx sandbox exec` exits with the command's exit code.

## Python

```python
from awx import Client, AwxError

with Client("https://api.awanbox.com", api_key="bx_...") as awx:
    box = awx.sandboxes.create(name="demo", size="large")
    print(awx.sandboxes.shell(box["id"], "python3 -c 'print(6*7)'")["stdout"])
    awx.sandboxes.write_file(box["id"], "/home/agent/hello.txt", "hi")
    link = awx.sandboxes.create_preview(box["id"], port=8000)
    answer = awx.chats.ask("find the largest file in /usr and tell me its size", computer=box["id"],
                           on_approval=lambda a: "approve")   # or ask the person
    awx.sandboxes.delete(box["id"])
```

Errors are `AwxError` with `.code` (for example `no_capacity`, `not_found`, `quota_exceeded`) and `.message`.
The API is the same under `/v1` and `/v2`; the client uses `/v2`.

Limits: 600 requests a minute per key, and 20 new computers, starts, chats or agent messages a minute per person; past a limit
the API answers `429` with `Retry-After` and the client raises `AwxError` with code `rate_limited`.

Changes in 0.3.0: `awx login` defaults to https://api.awanbox.com and needs only your key (no Cloudflare token); a key from `AWX_API_KEY`
with no saved address uses the same default.
