# Coronium: every integration in one file

coronium.io is the per-device shop for dedicated mobile modems and the marketplace where modem owners earn; coronium.ai is access for AI agents to proxies and devices on one account.

The guides for using the network from a program and for connecting a device, in one file, the same on https://coronium.ai and https://supply.coronium.ai. Each section is also served alone, at the address under its title. Read only the sections of your job:

- Use the network from a program: the quickstart and Send traffic, with calls to https://coronium.ai.
- Connect a device: Connect a device, Choose and check the agent file, one way to run it, and Device states, with calls to https://supply.coronium.ai. For more than a few devices, add Many devices. Afterwards: https://supply.coronium.ai/llms-full.txt.
- Either: Stated limits, the last section, lists what the service does not do.

Every block runs on its own, in a new shell if need be, in one folder, sets `umask 077` and keeps every secret in a file. Every refusal is JSON with `code`, `cause` and `fix`: do what `fix` names. Every call is in https://coronium.ai/openapi.json. The reference guides stay outside this file: https://coronium.ai/guides/usernames.md, https://coronium.ai/guides/prices.md, https://coronium.ai/guides/agent-payments.md and https://coronium.ai/guides/buyers.md.

## The prompt to give an agent

To use the network from a program:

> Read https://coronium.ai/guides/integrate.md and follow its steps for a program to give this project web traffic through Coronium. Ask me before you spend money or replace a credential; keep every secret in a file and out of this chat; when you finish, show me one route check and what it answered.

The shortest that is still safe:

> Follow https://coronium.ai/guides/integrate.md to set up Coronium for this project, and get my yes before you spend anything.

To connect a device:

> Read https://supply.coronium.ai/guides/integrate.md and follow its device steps to connect this machine to Coronium. Tell me first if this machine is in a data centre, where a device earns nothing. Before you sign the partner agreement, show me its text and wait for my yes; keep every secret in a file and out of this chat; when you finish, tell me the device's state and how to stop it.

The shortest that is still safe:

> Follow https://supply.coronium.ai/guides/integrate.md to connect this machine to Coronium, and get my yes before you sign anything.

When the agent is to use your account, add: "My access code is in the file coronium-account.json in this folder; read it there and never print it."

## What only your person decides

- Signing the partner agreement. It binds the person or organisation that controls the account, never you. Show them the `text` of `GET /app/api/consent`, with its `version` and `sha256`, and sign only after they say yes to that text. Send their full legal name, never your own.
- Sharing a device. Enrol a device only when its owner, and whoever pays for its connection, agreed to share it.
- Going on from a hosting or data-centre network: a device there is withheld as `class_not_sold` and earns nothing.
- Using a file that `/kit/index.json` marks `preview`, and each of its `limits`.
- Spending: confirming a quote, paying from a wallet, a live route test.
- Replacing the credential or the access code, withdrawing a device, and asking for a payout.

Everything else in these guides you do alone. When a step is safe to repeat, it says so.

## Coronium: instructions for an AI agent

This section alone: https://coronium.ai/guides/agents.md

Mobile and residential proxies for AI agents: real IP addresses on real devices, and next the phones, Macs and browsers an agent can drive.

One account, one balance, one file to read.

An agent uses the same kind of account as a person. You send web traffic over HTTP or SOCKS5 through residential and mobile devices and pay per GB from one US dollar balance. [/llms.txt](https://coronium.ai/llms.txt) gives the state of every product, and [/openapi.json](https://coronium.ai/openapi.json) every call.

Every path below is on the base URL you were given, or the address you read this file from. The commands use curl, jq and python3. Each block runs on its own, in a new shell if need be: it sets `umask 077`, so only you can read its files, and `BASE` to https://coronium.ai unless you exported it.

### Rules

- Send JSON with `Content-Type: application/json`.
- Every refusal is a JSON object with `code`, `cause` and `fix`. Read `fix` and send what it names.
- Money and byte counts are decimal strings. 1 USD is `1000000` micro-USD.
- An account has three secrets: `credential`, `accessCode` and the session cookie, and a device adds its `deviceSecret` and any enrolment `token`. The commands here keep each in a file only you can read and pass it to curl from a file or on standard input, never on a command line. Never print one or put one in a prompt, a log or a chat message.
- Ask your person before you spend money, replace the credential or the access code, or ask for a payout.
- A country with no devices online is on request. Make usernames for it anyway: the service records the request, and the answer's `stock.status` reads `on_request`.
- If a call answers `403` with the code `private_preview`, the operator has the site behind its preview lock: tell your person.

### Steps

0. Read what is sold now: `GET /app/api/buy` needs no account and answers `registration`, `peerSales`, `charging` and each way to pay. While `peerSales` is `paused`, step 5 answers `peer_sales_paused`: tell your person, who can buy a private modem instead ([/guides/private-proxies.md](https://coronium.ai/guides/private-proxies.md)).

```
umask 077
BASE=${BASE:-https://coronium.ai}
curl -sS "$BASE/app/api/buy"
```

1. Create an account with `POST /app/api/signup`: no details, only a proof of work this block solves. It saves the answer and session cookie and prints the account id or refusal code. Safe to repeat: it signs up only while `coronium-account.json` holds no access code.

```
umask 077
BASE=${BASE:-https://coronium.ai}
jq -e 'has("accessCode")' coronium-account.json >/dev/null 2>&1 || {
curl -sS "$BASE/app/api/signup/challenge" -o coronium-challenge.json &&
python3 -c 'import hashlib,json,sys,itertools;a=json.load(sys.stdin);c=a.get("challenge") or sys.exit(1)
print(json.dumps({"challenge":c,"nonce":str(next(n for n in itertools.count() if int.from_bytes(hashlib.sha256(f"{c}:{n}".encode()).digest(),"big")>>256-a["difficulty"]==0))}))' <coronium-challenge.json >coronium-signup.json &&
curl -sS -c coronium.cookies -H 'Content-Type: application/json' -d @- "$BASE/app/api/signup" -o coronium-account.json <coronium-signup.json ||
cp coronium-challenge.json coronium-account.json; }
jq -r '.accountId // .code' coronium-account.json
```

`coronium-account.json` now holds `accountId`, `credential` and `accessCode`, shown once. Other codes: [/auth.md](https://coronium.ai/auth.md). To use your person's account instead, as when it prints `registration_closed`, they first write `{"accessCode": "<access code>", "credential": "<credential>"}` into that file: the block then makes no account, and step 2 adds `accountId`. Replacing a lost credential with `POST /app/api/credential` stops every string with the old one, and each credential a browser made for itself.

2. Sign in with the access code; a new account is signed in already. Repeat this when a call answers `sign_in_required`, or on another machine. It stops with an error if the file holds no access code; the second command answers `{"signedIn":true}`, and the third adds `accountId`.

```
umask 077
BASE=${BASE:-https://coronium.ai}
jq -c '{code: ((.accessCode | strings | select(. != "")) // error("no accessCode in coronium-account.json"))}' coronium-account.json > coronium-login.json &&
curl -sS -c coronium.cookies -H 'Content-Type: application/json' -d @- "$BASE/app/api/login" < coronium-login.json &&
curl -sS -b coronium.cookies "$BASE/app/api/dashboard" | jq --slurpfile account coronium-account.json '$account[0] + {accountId: ((.account.id | strings | select(. != "")) // error("no account in the session read: sign in again"))}' > coronium-account.next && mv coronium-account.next coronium-account.json
```

3. Read the price list with `GET /app/api/prices`. It needs no account. Each tier lists its countries and the devices online in each.

```
umask 077
BASE=${BASE:-https://coronium.ai}
curl -sS "$BASE/app/api/prices"
```

4. Read the stock of one country, here Germany, with `GET /app/api/proxy/stock?country=de`. It lists the IP classes, carriers, states and cities a username can ask for.

```
umask 077
BASE=${BASE:-https://coronium.ai}
curl -sS -b coronium.cookies "$BASE/app/api/proxy/stock?country=de"
```

5. Make proxy usernames with `POST /app/api/proxy/spawn`. Each string holds `{credential}`, which the service never prints; the second command fills it in from the account file into `coronium-proxies.txt`.

```
umask 077
BASE=${BASE:-https://coronium.ai}
curl -sS -b coronium.cookies -H 'Content-Type: application/json' -d '{"count": 1, "pool": "peer", "country": "de", "protocol": "http", "format": "url", "rotation": "none"}' "$BASE/app/api/proxy/spawn" -o coronium-proxies.json
jq -r --slurpfile account coronium-account.json '(($account[0].credential | strings | select(. != "")) // error("no credential in coronium-account.json")) as $credential | .strings[] | sub("[{]credential[}]"; $credential)' coronium-proxies.json > coronium-proxies.txt
```

`"rotation": "sticky"`, a `sessionPrefix` and `"save": true` save a list.

6. Read the balance with `GET /app/api/billing`. `state` is `active`, `unfunded`, `suspended`, `byte_cap` or `traffic_stopped`. While `charging` is true, an account with no funds carries no traffic. Step 7 adds funds with your person, step 8 from your own wallet.

```
umask 077
BASE=${BASE:-https://coronium.ai}
curl -sS -b coronium.cookies "$BASE/app/api/billing"
```

7. Add funds with your person. The first block asks for a quote, which names an amount and owes nothing, keeps it in `coronium-quote.json` and prints it, or the refusal. A quote lasts 30 minutes, and the same `requestId` answers the same quote. `provider` is one that `providers` of `GET /app/api/billing` answers as `configured`: `coingate` for crypto, `stripe` for a card. Any other is refused with `provider_not_configured`, and every quote with `topups_closed` while `charging` is false; nothing is charged either way.

```
umask 077
BASE=${BASE:-https://coronium.ai}
curl -sS -b coronium.cookies -H 'Content-Type: application/json' -d '{"provider": "coingate", "usdMicros": "5000000", "requestId": "topup-1"}' "$BASE/app/api/billing/quotes" -o coronium-quote.json
jq '{quoteId, usdMicros, expiresAt, code, cause, fix}' coronium-quote.json
```

Show your person `usdMicros` and wait for their yes. Only then run the second block, which confirms the quote in `coronium-quote.json`, and give them `checkoutUrl` to pay at. It sends nothing if the file holds no quote, and confirming the same quote again answers the same checkout.

```
umask 077
BASE=${BASE:-https://coronium.ai}
jq -c '{quoteId: ((.quoteId | strings) // error("no quoteId in coronium-quote.json: ask for a quote first")), confirm: true}' coronium-quote.json > coronium-confirm.json &&
curl -sS -b coronium.cookies -H 'Content-Type: application/json' -d @- "$BASE/app/api/billing/topups" < coronium-confirm.json | jq '{checkoutUrl, state, code, cause, fix}'
```

8. Pay from your own wallet. `POST /v1/topup` takes the account id without its dashes and an amount, needs no cookie, and answers `402` with x402 and MPP offers. The block sends nothing if `coronium-account.json` holds no account id. How to pay one is in [/guides/agent-payments.md](https://coronium.ai/guides/agent-payments.md). While `agent.configured` in step 0 is false it answers `503`, offers nothing and charges nothing.

```
umask 077
BASE=${BASE:-https://coronium.ai}
jq -c '{accountId: (((.accountId | strings | select(. != "")) // error("no accountId in coronium-account.json: run step 2")) | gsub("-"; "")), usdMicros: "5000000"}' coronium-account.json > coronium-topup.json &&
curl -sS -i -H 'Content-Type: application/json' -d @- "$BASE/v1/topup" < coronium-topup.json
```

9. Read where to connect with `GET /app/api/proxy`. `endpoint.state` is `open` or `closed`. While it is closed no buyer traffic is carried, and the strings from step 5 also hold `{host}` and `{port}`.

```
umask 077
BASE=${BASE:-https://coronium.ai}
curl -sS -b coronium.cookies "$BASE/app/api/proxy"
```

10. Check a route. This call takes the credential as a Bearer header and no cookie. The first command writes the header to `coronium-bearer.txt`, and sends nothing if `coronium-account.json` holds no credential. While step 9 reads `closed` it answers `409 endpoint_closed`: report that answer. Add `"live": true` to the body to send one billed request to the operator's test origin.

```
umask 077
BASE=${BASE:-https://coronium.ai}
jq -r '"Authorization: Bearer " + ((.credential | strings | select(. != "")) // error("no credential in coronium-account.json"))' coronium-account.json > coronium-bearer.txt &&
curl -sS -H @- -H 'Content-Type: application/json' -d "$(jq -c '{username: .usernames[0]}' coronium-proxies.json)" "$BASE/app/api/proxy/test" < coronium-bearer.txt
```

### Not built yet

- Not built yet: MCP tools under the namespace `ai.coronium`, reached with a credential limited to what the agent may do; `@coronium-ai/sdk`, a typed client over the same HTTP API; and `@coronium-ai/cli`, for sign-up, sign-in and proxy strings from a terminal. Whether anything is published under one of these names, npm and the MCP registry answer.

A product that /llms.txt does not list as available takes a request. Signed in, send `POST /app/api/demand/device` with `{"kind": "<product id>"}` and an optional one-line `note`; the ids are the `kind` enum of that call in /openapi.json. The request is recorded, and nothing is ordered or charged. Your person can also send one from the Devices page, after sign-in.

Other guides: [buyers](https://coronium.ai/guides/buyers.md), [buying a private modem line](https://coronium.ai/guides/private-proxies.md), [device owners](https://coronium.ai/guides/device-owners.md), [usernames](https://coronium.ai/guides/usernames.md), [prices](https://coronium.ai/guides/prices.md), [limits](https://coronium.ai/guides/limits.md).

## Send traffic

This section alone: https://coronium.ai/guides/send-traffic.md

A program sends its requests through a device over the HTTP proxy or SOCKS5, with the strings the [quickstart](https://coronium.ai/guides/agents.md) wrote to `coronium-proxies.txt`. The edge, the one meter, counts every byte both ways. `POST /v1/fetch` and `POST /v1/routes/explain` answer only on the edge's own host and `local_only` anywhere else, because the buyer port takes no TLS; from anywhere else, check a route with `POST /app/api/proxy/test`, step 10 of the quickstart.

### Needs

`endpoint.state` `open` in `GET /app/api/proxy`: while it is `closed` no buyer traffic is carried, and the strings still hold `{host}` and `{port}`. Funds, once charging is on.

### Steps

1. As an HTTP proxy. A proxy string holds the credential, so it goes to curl in a config file, never as an argument.

```sh
umask 077
sed -n '1s/.*/proxy = "&"/p' coronium-proxies.txt > coronium-curl.conf
curl -sS -K coronium-curl.conf -o /dev/null -w '%{http_connect} %{http_code}\n' https://example.com/
```

Expect: `200 200`, the tunnel and then the target's status. The edge refuses with an error status such as `407` or `502`, a JSON body of `code`, `cause` and `fix`, and a `Coronium-Retry` header: `stop`, `wait-for-change` or `once-if-idempotent`. The route check names a route's code. Safe to repeat: as safe as the request itself.

2. Over SOCKS5. Make strings with `"protocol": "socks5"` in step 5 of the quickstart; `socks5h` lets the device look the name up.

```sh
umask 077
sed -n '1s/^socks5:/socks5h:/;1s/.*/proxy = "&"/p' coronium-proxies.txt > coronium-curl.conf
curl -sS -K coronium-curl.conf -o /dev/null -w '%{http_connect} %{http_code}\n' https://example.com/
```

Expect: `000 200`: SOCKS5 has no CONNECT status, so curl prints `000`, then the target's status. A SOCKS5 refusal is only a reply code, and curl ends with an error: read its `code`, `cause` and `fix` from the route check, or from the same request sent over the HTTP proxy. Safe to repeat: as safe as the request itself.

3. On the edge's own host only: `POST /v1/fetch` with `Authorization: Bearer <credential>` and `{"url": "..."}`, and an optional `selector`, a username, makes the request itself and answers `status`, `headers`, `body_base64`, `exit` and `bytes_billed`. `POST /v1/routes/explain` with `{"selector": "<username>"}` says where that username would go, and opens no stream.

### Refusals

| `code` | Do |
|---|---|
| `bad_credential`, `credential_replaced` | use the account's current credential |
| `bad_options` | fix the username: [usernames](https://coronium.ai/guides/usernames.md) |
| `on_request` | no device fits now, and the demand is recorded: follow `Coronium-Retry` |
| `target_blocked` | the target is refused, such as mail ports, an IPv6 literal or an address on the device's own network |
| `target_failed` | the target did not answer through the device; no route to the target can mean the device carries IPv4 only |
| `unfunded`, `account_suspended`, `byte_cap_reached` | read `GET /app/api/billing` and tell your person |
| `traffic_stopped` | buyer traffic is stopped on this network: stop the job |
| `local_only` | a `/v1` call from another host: use the proxy, and the route check |

The `reason` of an `on_request` body:

- `not_offered`: Not sold yet; recorded as demand.
- `no_device`: No matching device online; demand recorded.
- `devices_busy`: Matching devices busy.
- `account_limit`: This account's own limits.
- `edge_capacity`: This edge is full.
- `edge_not_ready`: This edge is starting, or lost its directory or storage.

An account holds 256 streams open at once on an edge unless the owner set its own limit. Such a limit counts up to 8192 streams. A device that has not opened a stream within 3 seconds is left for the next one, except with a named device, `failover-none` or a session.

## Connect a device: account, agreement and enrolment

This section alone: https://supply.coronium.ai/guides/device-enrol.md

Calls go to https://supply.coronium.ai: each block sets `SUPPLY` to it unless you exported `SUPPLY`, and enters one folder, `~/coronium` unless you exported `CORONIUM_DIR`. The blocks use curl, jq, sha256sum and python3 and keep every answer in a file only you can read: check a file by its keys, never by printing it. Enrol a device only when its owner, and whoever pays for its connection, agreed.

On a hosting or data-centre network a device is withheld as `class_not_sold` and earns nothing: tell your person before they sign.

### Steps

1. Sign up once, then sign in.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
mkdir -p "${CORONIUM_DIR:=$HOME/coronium}" && cd "$CORONIUM_DIR" || exit
[ ! -e coronium-account.json ] || jq -e 'has("accessCode")' coronium-account.json >/dev/null || { echo "coronium-account.json holds no accessCode: correct or move it" >&2; exit 1; }
if [ ! -e coronium-account.json ]; then
  curl -sS "$SUPPLY/app/api/signup/challenge" -o coronium-challenge.json
  jq -e 'has("challenge") or error("\(.code): \(.cause) Fix: \(.fix) \(.retryAt // "")")' coronium-challenge.json >/dev/null || exit 1
  python3 -c 'import hashlib,json,sys,itertools;a=json.load(sys.stdin);c=a["challenge"];print(json.dumps({"challenge":c,"nonce":str(next(n for n in itertools.count() if int.from_bytes(hashlib.sha256(f"{c}:{n}".encode()).digest(),"big")>>256-a["difficulty"]==0))}))' < coronium-challenge.json | curl -sS -c coronium.cookies -H 'Content-Type: application/json' -d @- "$SUPPLY/app/api/signup" -o coronium-signup.json
  jq -e 'has("accessCode") or error("\(.code): \(.cause) Fix: \(.fix) \(.retryAt // "")")' coronium-signup.json >/dev/null || exit 1
  mv coronium-signup.json coronium-account.json
fi
jq -c '{code: .accessCode}' coronium-account.json | curl -sS -c coronium.cookies -H 'Content-Type: application/json' -d @- "$SUPPLY/app/api/login"
```

Expect: `{"signedIn":true}`. A new account's file holds `accessCode`, `accountId` and `credential`, shown this once. A refusal prints its code, cause and fix, and no account is made: on `registration_closed`, your person makes `coronium-account.json` in this folder with `chmod 600`, holding `{"accessCode": "<access code>"}`, then rerun; on `signups_paused` or `rate_limited`, wait until the time named. A file there without an access code stops the block: correct it or move it. Safe to repeat: yes; it signs up only when the file is absent.

2. Read the partner agreement, and show it.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
curl -sS -b coronium.cookies "$SUPPLY/app/api/consent" -o coronium-consent.json
jq -j '.text // empty' coronium-consent.json > coronium-agreement.md
jq '{version, sha256, approved, status, code}' coronium-consent.json
```

Expect: `approved` true, and `status` `unsigned`, `signed` or `countersigned`; `sha256sum coronium-agreement.md` prints `sha256`. Show your person `coronium-agreement.md` whole, with `version` and `sha256`, and wait for their yes. While `approved` is false nobody can sign. Safe to repeat: yes.

3. Sign, after the yes. Write `coronium-signer.json` as `{"name": "<full legal name>", "organisation": "<only when they sign for one>"}`: the person or organisation that controls the account, never you, trimmed, without `|` or a line break. The block keeps the signed body in `coronium-signature.json`.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
[ -s coronium-signature.json ] || {
  now=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
  sig=$(jq -j --arg now "$now" --slurpfile s coronium-signer.json '"coronium-partner-agreement|\(.version)|\(.accountId)|\($s[0].name)|\($s[0].organisation // "")|\(.sha256)|\($now)"' coronium-consent.json | sha256sum | cut -d' ' -f1)
  jq -c --arg now "$now" --arg sig "$sig" --slurpfile s coronium-signer.json '{consent: {version, sha256}, agreed: true, signer: $s[0], signedAt: $now, signature: $sig}' coronium-consent.json > coronium-signature.tmp && mv coronium-signature.tmp coronium-signature.json || exit
}
curl -sS -b coronium.cookies -H 'Content-Type: application/json' -d @- "$SUPPLY/app/api/consent" < coronium-signature.json | jq '{signatureId, version, code}'
```

Expect: a `signatureId`. [`/kit/SIGNING.md`](https://supply.coronium.ai/kit/SIGNING.md) has the fingerprint with a worked example, and what is stored with a signature and each enrolment. If refused: `bad_signed_at` (more than 10 minutes from the server's clock: fix the clock, delete `coronium-signature.json`, repeat), `already_signed` (signed already with other values; that stands, go on), `consent_outdated` (step 2, then delete `coronium-signature.json`). Safe to repeat: yes, with the same file. A signature is never withdrawn.

4. Enrol one device.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
[ -s coronium-enrol.json ] || { jq -c --arg id "$(od -An -tx1 -N8 /dev/urandom | tr -d ' \n')" '{consent: {version, sha256}, agreed: true, requestId: $id}' coronium-consent.json > coronium-enrol.tmp && mv coronium-enrol.tmp coronium-enrol.json || exit; }
[ -s coronium-device.json ] || {
  curl -sS -b coronium.cookies -H 'Content-Type: application/json' -d @- "$SUPPLY/app/api/devices" < coronium-enrol.json -o coronium-device.tmp
  jq -e 'has("deviceSecret")' coronium-device.tmp >/dev/null && mv coronium-device.tmp coronium-device.json || { jq '{code, cause, fix, deviceId}' coronium-device.tmp; exit 1; }
}
jq '{deviceId, relay, state}' coronium-device.json
```

Expect: `deviceId`, `relay` and `state` `new`; the file also holds `deviceSecret`, shown this once. A refusal prints its code, cause and fix and keeps no device file; act on `fix` and repeat: `agreement_unsigned` (step 3), `device_cap_reached` (the account holds `terms.deviceLimit` of `GET /app/api/earnings`), `enrolment_repeated` (this `requestId` enrolled `deviceId` already and its secret is gone: withdraw it, delete `coronium-enrol.json`, enrol again). Safe to repeat: yes; one `requestId` enrols once. For a second device, in this same folder, first move `coronium-enrol.json` and `coronium-device.json` aside.

5. Write the settings file.

```sh
umask 077
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
jq -er 'if (.relay and .deviceId and .deviceSecret) then "CORONIUM_RELAY=\(.relay)\nCORONIUM_DEVICE=\(.deviceId)\nCORONIUM_DEVICE_SECRET=\(.deviceSecret)" else error("no relay, device or secret in coronium-device.json") end' coronium-device.json > agent.env.tmp && mv agent.env.tmp agent.env
```

Expect: no output; `cut -d= -f1 agent.env` prints the three names. A null `relay` means ask the operator. Safe to repeat: yes.

### Then

[Choose and check the agent file](https://supply.coronium.ai/guides/device-files.md), run it one way, and [read the device's state](https://supply.coronium.ai/guides/device-states.md). Tell the person sharing the device [what it refuses](https://supply.coronium.ai/guides/device-states.md#what-a-device-refuses).

## Choose and check the agent file

This section alone: https://supply.coronium.ai/guides/device-files.md

Calls go to https://supply.coronium.ai. `/kit/index.json` lists what this server publishes now, with `"schema": 2`: stop on another number or none. Each file has `name`, `sha256`, `bytes`, `way`, `os`, `arch`, `kind`, `state`, `checked` and `limits`.

### Steps

1. Pick a file by `os`, `arch` and `kind`. `uname -m` prints `x86_64` for `amd64`, `aarch64` or `arm64` for `arm64`, `armv7l` for `armv7` and `armv6l` for `armv6`. A MIPS router prints `mips` either way: take `mipsle` when its firmware names a little-endian architecture such as `mipsel_24kc`. `kind` is `kit` for the Linux kit, `docker` for the image, `binary` for the program alone, and `install` and `uninstall` for the scripts that make the program a service on macOS and Windows and remove it, whose `arch` is `any`.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
curl -fsS "$SUPPLY/kit/index.json" -o coronium-kit.json
jq -r '.files[] | select(.os == "linux" and .arch == "amd64") | "\(.name) \(.kind) \(.state) \(.limits | join(","))"' coronium-kit.json
```

Expect: one line per file of that system. Only a `preview` file needs the owner's yes, to its state and each of its `limits`, whatever `checked` reads. Safe to repeat: yes.

2. Download the file and check it against the list.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
FILE=coronium-agent-linux-amd64
curl -fsSLO "$SUPPLY/kit/$FILE"
jq -r --arg f "$FILE" '.files[] | select(.name == $f) | "\(.sha256)  \(.name)"' coronium-kit.json | sha256sum -c
```

Expect: `coronium-agent-linux-amd64: OK`; stop on anything else. Nothing is signed yet: the list is as trustworthy as its HTTPS connection. Safe to repeat: yes.

### Then

Linux with systemd and a person at its terminal: [the Linux kit](https://supply.coronium.ai/guides/device-linux-kit.md). A Docker host: [the image](https://supply.coronium.ai/guides/device-docker.md). A service on [macOS](https://supply.coronium.ai/guides/device-macos.md) or [Windows](https://supply.coronium.ai/guides/device-windows.md): its installer. Anything else, a container among them, or no person at the terminal: [the program alone](https://supply.coronium.ai/guides/device-program.md).

### Every file

The table is the next build's.

| Way | `os` | `arch` | `kind` | `state` | `limits` |
|---|---|---|---|---|---|
| Linux agent kit | `linux` | `amd64` | `kit` | `available` | `system_ca_roots_required` |
| Docker image | `linux` | `amd64` | `docker` | `available` | `not_run_by_coronium` |
| Linux agent kit | `linux` | `amd64` | `binary` | `available` | `system_ca_roots_required` |
| Linux agent kit | `linux` | `arm64` | `kit` | `available` | `not_run_by_coronium`, `system_ca_roots_required` |
| Docker image | `linux` | `arm64` | `docker` | `available` | `not_run_by_coronium` |
| Linux agent kit | `linux` | `arm64` | `binary` | `available` | `not_run_by_coronium`, `system_ca_roots_required` |
| Linux agent kit | `linux` | `armv7` | `binary` | `preview` | `not_run_by_coronium`, `system_ca_roots_required` |
| Linux agent kit | `linux` | `armv6` | `binary` | `preview` | `not_run_by_coronium`, `system_ca_roots_required` |
| Linux agent kit | `linux` | `riscv64` | `binary` | `preview` | `not_run_by_coronium`, `system_ca_roots_required` |
| Routers | `linux` | `mips` | `binary` | `preview` | `not_run_by_coronium`, `no_installer`, `system_ca_roots_required`, `large_for_small_flash` |
| Routers | `linux` | `mipsle` | `binary` | `preview` | `not_run_by_coronium`, `no_installer`, `system_ca_roots_required`, `large_for_small_flash` |
| Windows | `windows` | `amd64` | `binary` | `available` | `not_run_by_coronium`, `unsigned` |
| Windows | `windows` | `arm64` | `binary` | `available` | `not_run_by_coronium`, `unsigned` |
| Windows | `windows` | `any` | `install` | `available` | `not_run_by_coronium`, `unsigned`, `starts_at_login` |
| Windows | `windows` | `any` | `uninstall` | `available` | `not_run_by_coronium`, `unsigned` |
| macOS | `darwin` | `arm64` | `binary` | `preview` | `not_run_by_coronium`, `unsigned` |
| macOS | `darwin` | `any` | `install` | `preview` | `not_run_by_coronium`, `starts_at_login` |
| macOS | `darwin` | `any` | `uninstall` | `preview` | `not_run_by_coronium` |
| Android app SDK | `android` | `arm64_x86_64` | `aar` | `preview` | `sharing_apps_only`, `notice_proposed`, `container_run_only` |

What Coronium observed of each file: [the program alone](https://supply.coronium.ai/guides/device-program.md), Each system.

`version` is the published agent's. `GET /app/api/devices` returns, as `agent`, the name each device's agent gave its relay, such as `agent/0.1.0`, or null when its relay reported none. A name states a version, not a build: two builds of one version read the same.

States:

- `available`: Coronium took this exact file through its whole check on this system: digest checked, started by the published steps, connected to the relay, one billed request with bytes billed equal to bytes carried, then stopped and removed by the published steps. `checked` is the day of that record when it holds this file's SHA-256, and null otherwise. A file that also carries `not_run_by_coronium` is available by the owner's decision, without that check.
- `preview`: Built for this system, its header read back from its bytes, and not yet through that whole check here. Use it only when the device's owner accepts that and each of its limits.
- `not_available`: There is no file for this way. The way names its reason.

Limits:

- `not_run_by_coronium`: No run of this file on this system is recorded against its row.
- `unsigned`: Not code-signed: the system may warn about it or block it.
- `no_installer`: No installer and no service: you start it from a shell.
- `starts_at_login`: Its service belongs to one user and starts when that user logs in, not when the machine starts: after a restart it is back once that user has logged in.
- `system_ca_roots_required`: Needs the system's certificate roots (the ca-certificates package), which minimal, container and router images often lack. The Docker image carries its own.
- `large_for_small_flash`: Large for a router with 8 to 16 MB of flash.
- `sharing_apps_only`: Only for an app whose stated main purpose is sharing its user's connection, in a store that allows that or given out directly. A store allows proxying for others at most as an app's own purpose, and one forbids it outright: never inside a game, a utility or any other app.
- `notice_proposed`: The notice the library shows its user is proposed and not yet approved: the supply site enrols no device under it, and in an app that is not debuggable the library opens no consent screen.
- `container_run_only`: Run end to end on a development Android instance only, never on a phone: an ARM64 phone, real charging, the system's battery limits and mobile networks are not yet checked.

Reasons a way has no file:

- `platform_policy`: The platform's review rules allow background services only for listed purposes, and a proxy is not one. None is planned.
- `not_built`: Not built, or this build left its files out.

A sharing kit inside another developer's product is not built.

## Run it with the Linux kit

This section alone: https://supply.coronium.ai/guides/device-linux-kit.md

The kit installs the agent as a systemd service, after checking every file and showing the partner agreement. Calls go to https://supply.coronium.ai. The kit carries these same steps in its `README.md`.

### Needs

- Linux on x86-64 or ARM64, root through `sudo`, and `curl` and `sha256sum`.
- The system's certificate roots, which minimal and container images leave out: `sudo apt-get install -y ca-certificates` on Debian and Ubuntu, `sudo apk add ca-certificates` on Alpine, `sudo dnf install -y ca-certificates` on Fedora and RHEL.
- Outbound TCP to the relay. No inbound port.
- From the device's enrolment at https://supply.coronium.ai/farmer or through the API: the relay `host:port`, the device id, the device secret, and the agreement digest shown for the device, which is the `sha256` of the text the account signed.
- The kit digest: the line for `coronium-agent-linux-<arch>/SHA256SUMS` in https://supply.coronium.ai/kit/SHA256SUMS, which the farmer portal also shows.
- A person at the device's terminal: the installer shows the partner agreement and asks them to type it. An agent hands this step to its person, or runs the program alone instead.

### Steps

1. Download and check the kit as your normal user, before anything runs as root. Every block works in one folder, `~/coronium` unless `CORONIUM_DIR` names another. `ARCH` is `amd64` when `uname -m` prints `x86_64`, and `arm64` for `aarch64`.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
mkdir -p "${CORONIUM_DIR:-$HOME/coronium}"
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
ARCH=amd64
curl -fsSLO "$SUPPLY/kit/SHA256SUMS"
curl -fsSLO "$SUPPLY/kit/coronium-agent-linux-$ARCH.tar.gz"
grep " coronium-agent-linux-$ARCH.tar.gz\$" SHA256SUMS | sha256sum -c
tar -xzf "coronium-agent-linux-$ARCH.tar.gz"
grep " coronium-agent-linux-$ARCH/SHA256SUMS\$" SHA256SUMS | sha256sum -c
(cd "coronium-agent-linux-$ARCH" && sha256sum -c SHA256SUMS)
```

Expect: every line ends `OK`. If one does not, stop and write to the contact in `PARTNER-AGREEMENT.md`. Nothing is signed yet: the digests are only as trustworthy as the site they came from. Safe to repeat: yes.

2. Install, from the kit's folder. Without systemd, add `--no-systemd`: the installer then prints one command that runs the agent in the foreground as the user `nobody`, and nothing starts it after a reboot.

```sh
umask 077
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
cd coronium-agent-linux-*/ && sudo ./install.sh
```

Expect: `Installed.` and the consent record, which holds no secret. The settings go to `/etc/coronium-agent/agent.env`, readable by root only. If refused: `no_certificate_roots` (install the roots above), `kit_digest_mismatch` (download the kit again), `agreement_not_accepted` (the kit's agreement is not the text the account signed: sign the text in force, then enrol), `consent_not_given`, `bad_relay`, `bad_device_id` or `bad_secret` (run it again with the right value), `no_systemd` (add `--no-systemd`), `wrong_architecture`, `checksum_mismatch` or `consent_draft` (get a new kit). Safe to repeat: yes, and it keeps the settings.

3. Check.

```sh
umask 077
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
systemctl is-active coronium-agent
journalctl -u coronium-agent -n 20 --no-pager
```

Expect: `active` and `connected to the relay`. A problem is one log line with its cause and its fix, and the agent dials again by itself. If its settings are refused five times in five minutes the service stops: fix the cause, then `sudo systemctl restart coronium-agent`.

### Stop and remove

Stop, remove, withdraw: https://supply.coronium.ai/guides/device-lifecycle.md.

### If it is not connected

```sh
umask 077
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
sudo systemctl enable --now coronium-agent
sudo systemctl restart coronium-agent
journalctl -u coronium-agent -n 5 --no-pager
```

The first line starts a service that was stopped or disabled; the second starts one that gave up after refused settings; the third shows why it is not connected, if it is not.

### Update

`/kit/index.json` names the published `version`, and publishing a newer agent does not stop one that is running. To update, download and check the new kit as in step 1 and run its installer as in step 2. It checks every file of the kit again and asks for the two digests and your agreement before it replaces the program, keeps `/etc/coronium-agent/agent.env`, and starts the service again. Then check as in step 3. When a check fails, nothing is replaced.

## Run it in a container

This section alone: https://supply.coronium.ai/guides/device-docker.md

The image runs the agent as user 65534, not as root, on a read-only filesystem, with no shell and no installer. It carries certificate roots of its own. Calls go to https://supply.coronium.ai.

### Needs

- Docker on Linux, outbound TCP to the relay, and no inbound port.
- `agent.env` from [enrolment](https://supply.coronium.ai/guides/device-enrol.md), in the folder every block works in: `~/coronium` unless `CORONIUM_DIR` names another. A person who has none yet makes it there with `touch agent.env && chmod 600 agent.env`, then writes three lines into it in an editor, such as `nano agent.env`: `CORONIUM_RELAY=us1.almanac.channel:17001`, `CORONIUM_DEVICE=<device id>` and `CORONIUM_DEVICE_SECRET=<device secret>`, without quotes and never on a command line.
- One container per public address: when an earlier residential device already exits from that address, the later one is withheld as `same_exit`.

No installer shows the agreement here, so the signature and the acceptance stored at enrolment are its record.

### Steps

1. Download, check and load the image. `ARCH` is `amd64` for `x86_64` and `arm64` for `aarch64`.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
mkdir -p "${CORONIUM_DIR:-$HOME/coronium}"
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
ARCH=amd64
curl -fsSLO "$SUPPLY/kit/SHA256SUMS"
curl -fsSLO "$SUPPLY/kit/coronium-agent-docker-$ARCH.tar"
grep " coronium-agent-docker-$ARCH.tar\$" SHA256SUMS | sha256sum -c
docker load -i "coronium-agent-docker-$ARCH.tar"
curl -fsS "$SUPPLY/kit/index.json" | jq -r .version > coronium-version.txt
```

Expect: `OK`, then `Loaded image: coronium-agent:<version>`, with the version `coronium-version.txt` now holds. Stop if the check fails. Safe to repeat: yes.

2. Run it, beside `agent.env`.

```sh
umask 077
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
VERSION=$(cat coronium-version.txt)
chmod 600 agent.env
docker run -d --name coronium-agent --restart unless-stopped --read-only \
  --cap-drop ALL --security-opt no-new-privileges --env-file agent.env "coronium-agent:$VERSION"
for second in $(seq 20); do docker logs coronium-agent 2>&1 | grep -q 'connected to the relay' && break; sleep 1; done
docker logs -n 20 coronium-agent
```

Expect: `connected to the relay`, once the agent has connected: the block waits for that line for a short while before it prints the log. A problem is one line with its cause and its fix. The agent does not retry a refused setting: Docker starts it again with a growing pause until the file is fixed. Docker reads `agent.env` only when it creates the container, so after a change run `docker rm -f coronium-agent` and this step again. Safe to repeat: after `docker rm -f coronium-agent` only; Docker refuses a second container of the same name.

### If it is not connected

```sh
umask 077
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
docker start coronium-agent
docker logs -n 5 coronium-agent
```

The first line starts a container that stopped; the second shows why it is not connected, if it is not. With `--restart unless-stopped` Docker starts it again after a restart of the machine, unless you stopped it yourself.

### Update

`/kit/index.json` names the published `version`, and publishing a newer image does not stop a container that is running. To update, run step 1 again, which checks the new image before it is loaded, then `docker rm -f coronium-agent` and step 2. `agent.env` stays as it is. `docker rmi coronium-agent:<old version>` removes the image it replaced.

### Stop and remove

Stop, remove, withdraw: [update, stop, remove and withdraw](https://supply.coronium.ai/guides/device-lifecycle.md).

## Run it on macOS

This section alone: https://supply.coronium.ai/guides/device-macos.md

The installer sets the program up as a launchd user agent: a service of your own user, which starts when you log in and is started again whenever it ends. Calls go to https://supply.coronium.ai. `/kit/index.json` lists the state and the limits of the program and of the installer, and [the files section](https://supply.coronium.ai/guides/device-files.md) says what each means.

### Needs

- A Mac with Apple silicon, Terminal and your own user, never `sudo`.
- `agent.env` from [enrolment](https://supply.coronium.ai/guides/device-enrol.md), in the folder of the downloads. Without it the installer asks for the three values, the secret without showing it.
- Outbound TCP to the relay, no inbound port, and one device per public address.

No installer shows the agreement here, so the signature and the acceptance stored at enrolment are its record.

### Steps

1. Download, check and install, in a folder of its own. The installer runs only when every check line ends `OK`.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
for f in SHA256SUMS coronium-agent-darwin-arm64 coronium-agent-darwin-install.sh coronium-agent-darwin-uninstall.sh; do curl -fsSLO "$SUPPLY/kit/$f"; done
grep -E '  coronium-agent-darwin-(arm64|install\.sh|uninstall\.sh)$' SHA256SUMS | shasum -a 256 -c && sh coronium-agent-darwin-install.sh
```

Expect: three lines ending `OK`, then `Installed.` The installer checks the files again, moves `agent.env` into `~/Library/Application Support/CoroniumDevice`, readable by you only, and writes `~/Library/LaunchAgents/ai.coronium.device.plist`, which holds no setting. If refused: `checksum_missing` or `checksum_mismatch` (download again), `wrong_architecture` (no program is published for an Intel Mac), `runs_as_root` (run it without `sudo`), `quarantined` (a browser downloaded the program: fetch it with curl as above), `bad_settings_file`, `bad_relay`, `bad_device_id` or `bad_secret` (correct `agent.env`), `service_not_started` (log in to the Mac's desktop as this user). Nothing is signed yet: the digests are as trustworthy as the site they came from. Safe to repeat: yes, and it keeps the settings; an `agent.env` beside the installer is then not used, and the installer says to delete it.

2. Check.

```sh
umask 077
launchctl print gui/$(id -u)/ai.coronium.device | grep state
tail -n 20 "$HOME/Library/Application Support/CoroniumDevice/agent.log"
```

Expect: `state = running` and `connected to the relay`. A problem is one log line with its cause and its fix, and the agent dials again by itself. launchd starts an agent that ended again after a pause, so a refused setting repeats in the log until `agent.env` is right.

The service belongs to your user: it runs while you are logged in. After a restart it is back once you log in, and not before. Nothing trims `agent.log`.

### If it is not connected

```sh
umask 077
launchctl bootstrap gui/$(id -u) "$HOME/Library/LaunchAgents/ai.coronium.device.plist"
launchctl kickstart -k gui/$(id -u)/ai.coronium.device
tail -n 5 "$HOME/Library/Application Support/CoroniumDevice/agent.log"
```

The first line loads the service and fails harmlessly when it is loaded; the second starts it again; the third shows why it is not connected, if it is not.

### Update

`/kit/index.json` names the published `version`, and publishing a newer agent does not stop one that is running. To update, run the block of step 1 again in an empty folder, without `agent.env`. The installer checks the new files before it touches anything, keeps the settings that are installed, ends the running service, puts the new program in place and starts it. When a check fails, the installed program stays as it is and keeps running.

### Stop and remove

`launchctl bootout gui/$(id -u)/ai.coronium.device` stops sharing until you log in again. To remove the service, the program, its log and `agent.env` with the secret:

```sh
umask 077
sh "$HOME/Library/Application Support/CoroniumDevice/uninstall.sh"
```

It warns, with the process id, about an agent you started yourself, which it does not stop. Removing it does not withdraw the device; [update, stop, remove and withdraw](https://supply.coronium.ai/guides/device-lifecycle.md) says how.

## Run it on Windows

This section alone: https://supply.coronium.ai/guides/device-windows.md

The installer sets the program up as a scheduled task of your own user, which starts when you log on and is started again after it fails. It is written to need no administrator rights and no other tool; it was not run by Coronium on Windows, so neither is measured. Calls go to https://supply.coronium.ai. `/kit/index.json` lists the state and the limits of the program and of the installer, and [the files section](https://supply.coronium.ai/guides/device-files.md) says what each means.

### Needs

- Windows on x86-64 or ARM64, Windows PowerShell, and your own user.
- `agent.env` from [enrolment](https://supply.coronium.ai/guides/device-enrol.md), in the folder of the downloads. Without it the installer asks for the three values, the secret without showing it.
- Outbound TCP to the relay, no inbound port, and one device per public address.

No installer shows the agreement here, so the signature and the acceptance stored at enrolment are its record.

### Steps

1. Download, check and install, in PowerShell, in a folder of its own. `$ARCH` is `amd64` for x86-64 and `arm64` for ARM64. The block stops at the first line that fails.

```powershell
& {
$ErrorActionPreference = 'Stop'
$SUPPLY = 'https://supply.coronium.ai'
$ARCH = 'amd64'
Invoke-WebRequest -UseBasicParsing "$SUPPLY/kit/SHA256SUMS" -OutFile SHA256SUMS
foreach ($f in "coronium-agent-windows-$ARCH.exe", 'coronium-agent-windows-install.ps1', 'coronium-agent-windows-uninstall.ps1') {
  Invoke-WebRequest -UseBasicParsing "$SUPPLY/kit/$f" -OutFile $f
  $listed = Select-String -Path SHA256SUMS -Pattern ('  ' + [regex]::Escape($f) + '$')
  if (-not $listed -or $listed.Line.Split(' ')[0] -ne (Get-FileHash $f -Algorithm SHA256).Hash.ToLower()) { throw "$f does not match SHA256SUMS" }
}
powershell -NoProfile -ExecutionPolicy Bypass -File .\coronium-agent-windows-install.ps1
}
```

Expect: no error from the checks, then `Installed.` The installer checks the files again, moves `agent.env` into `%LOCALAPPDATA%\CoroniumDevice`, a folder only your user can read, and registers the task `CoroniumDevice`, which holds no setting. The scripts are not signed, so each is started with `-ExecutionPolicy Bypass` after its digest is checked. If refused: `checksum_missing` or `checksum_mismatch` (download again), `wrong_architecture`, `policy_blocks_scripts` (the machine's administrator allows signed scripts only), `bad_settings_file`, `bad_relay`, `bad_device_id` or `bad_secret` (correct `agent.env`), `service_not_started` or `program_not_replaced` (the cause is in the message; after the second, the program installed before runs on). A file a browser downloaded carries a download mark the installer does not handle: download with this block. Nothing is signed yet: the digests are as trustworthy as the site they came from. Safe to repeat: yes, and it keeps the settings.

2. Check.

```powershell
(Get-ScheduledTask -TaskName CoroniumDevice).State
Get-Content -Tail 20 "$env:LOCALAPPDATA\CoroniumDevice\agent.log"
```

Expect: `Running` and `connected to the relay`. A problem is one log line with its cause and its fix, and the agent dials again by itself.

The task belongs to your user: it runs while you are logged on. After a restart it is back once you log on, and not before. Windows starts a failed task again only as often as the task's restart count allows; past it, the task stays down until you log on again. Nothing trims `agent.log`.

### If it is not connected

```powershell
Enable-ScheduledTask -TaskName CoroniumDevice
Start-ScheduledTask -TaskName CoroniumDevice
Get-Content -Tail 5 "$env:LOCALAPPDATA\CoroniumDevice\agent.log"
```

The first two lines start the task again; the third shows why it is not connected, if it is not.

### Update

`/kit/index.json` names the published `version`, and publishing a newer agent does not stop one that is running. To update, run the block of step 1 again in an empty folder, without `agent.env`. The installer checks the new files before it touches anything, keeps the settings that are installed, copies the new program beside the installed one, ends the running task, moves the new program into place and starts it. When a check or the move fails, the installed program stays as it is and runs on.

### Stop and remove

`Stop-ScheduledTask -TaskName CoroniumDevice; Disable-ScheduledTask -TaskName CoroniumDevice` stops sharing and keeps it stopped. To remove the task, the program, its log and `agent.env` with the secret:

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File "$env:LOCALAPPDATA\CoroniumDevice\uninstall.ps1"
```

It warns, with the process id, about an agent you started yourself, which it does not stop. Removing it does not withdraw the device; [update, stop, remove and withdraw](https://supply.coronium.ai/guides/device-lifecycle.md) says how.

## Run the program alone

This section alone: https://supply.coronium.ai/guides/device-program.md

The program alone is built for Linux, Windows, macOS and routers; the state and limits of each file and what Coronium observed of it are listed below, under Each system. Started this way it has no service: a shell starts it detached, with the three settings of `agent.env` in its environment, never as arguments, and never as root, and nothing starts it again unless a supervisor of your own does. A published installer makes it a service on [macOS](https://supply.coronium.ai/guides/device-macos.md) and on [Windows](https://supply.coronium.ai/guides/device-windows.md), and on Linux with systemd [the kit](https://supply.coronium.ai/guides/device-linux-kit.md) does. Calls go to https://supply.coronium.ai.

### Needs

- The file for the system, checked as in [the files section](https://supply.coronium.ai/guides/device-files.md), and `agent.env` from [enrolment](https://supply.coronium.ai/guides/device-enrol.md), both in the folder every block works in: `~/coronium` unless `CORONIUM_DIR` names another.
- Outbound TCP to the relay, no inbound port, and one device per public address.
- On Linux and routers, the system's certificate roots: without them the program logs that the system has none, with the package to install. Windows and macOS check the relay's certificate with their own store.

### Steps

1. Start it. On Linux, macOS and routers, put the file's name in `FILE`:

```sh
umask 077
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
FILE=coronium-agent-linux-amd64
chmod 0755 "$FILE"
RUN="$PWD/$FILE"
AS=""
if [ "$(id -u)" = 0 ]; then
  id coronium-agent >/dev/null 2>&1 || useradd --system --no-create-home --shell /usr/sbin/nologin coronium-agent 2>/dev/null || adduser -S -D -H -s /sbin/nologin coronium-agent || { echo "no_service_user: the user coronium-agent could not be made. Fix: make it with the system's own tool, then run this again"; exit 1; }
  mkdir -p /opt/coronium && cp "$FILE" /opt/coronium/coronium-agent && chmod 0755 /opt/coronium /opt/coronium/coronium-agent
  RUN=/opt/coronium/coronium-agent
  AS=coronium-agent
fi
(set -a; . ./agent.env; set +a
  if [ -n "$AS" ]; then exec nohup su -s /bin/sh "$AS" -c "exec $RUN"; else exec nohup "$RUN"; fi >>coronium-agent.log 2>&1 </dev/null &
  echo $! >coronium-agent.pid)
sleep 5; tail -n 1 coronium-agent.log
```

It runs detached, with its log in `coronium-agent.log`, and `kill "$(cat coronium-agent.pid)"`, in the working folder, stops it. From a root shell, such as a server's console or a container without systemd, it does not run as root: the block makes a system user of its own, `coronium-agent`, or stops where the system has no tool that makes one, as on many routers, puts the program in `/opt/coronium` and runs it as that user, so no other user's process reads the settings in its environment; `agent.env` and the log stay with root.

On Windows, in PowerShell, in the folder of the file and `agent.env`:

```powershell
Get-Content agent.env | ForEach-Object { $name, $value = $_ -split '=', 2; Set-Item "env:$name" $value }
.\coronium-agent-windows-amd64.exe
```

Expect: `connected to the relay`. Each problem is one line, `not connected: <cause>. Fix: <fix>. Dialing again in <time>`, and the program dials again by itself after a lost connection. A setting it refuses ends it with exit status 2 and `<code>: <cause>. Fix: <fix>`: `bad_relay`, `bad_device_id` or `bad_secret` means `agent.env` is wrong. Safe to repeat: once it is stopped; a second copy with the same settings replaces the first at the relay.

2. Know each system's limits, which `/kit/index.json` lists for each file.

- Windows and macOS: the file has no code signature, so the system may warn about it or block a copy a browser downloaded; a copy fetched with curl carries no download mark.
- Routers: copy the file to the router, and check that it has certificate roots, room in flash and memory, and a clock set by NTP, because a router that boots with its clock in the past fails the certificate check until the time is set. A router's memory, flash, resolver and clock are not measured by Coronium yet.

### Each system

The next build's state and limits of the program's files; `/kit/index.json` speaks for what this server publishes now:

- `linux` on `amd64`: `available`; limits `system_ca_roots_required`.
- `linux` on `arm64`: `available`; limits `not_run_by_coronium`, `system_ca_roots_required`.
- `linux` on `armv7`, `armv6`, `riscv64`: `preview`; limits `not_run_by_coronium`, `system_ca_roots_required`.
- `linux` on `mips`, `mipsle`: `preview`; limits `not_run_by_coronium`, `no_installer`, `system_ca_roots_required`, `large_for_small_flash`.
- `windows` on `amd64`, `arm64`: `available`; limits `not_run_by_coronium`, `unsigned`.
- `darwin` on `arm64`: `preview`; limits `not_run_by_coronium`, `unsigned`.

What Coronium observed of each published file, the kit and the image included. A dated note speaks only for the digest it names:

- Linux `amd64` kit and program: two runs of two earlier builds, one that installed, started and removed the kit and one that carried a billed request. No run of a published file.
- Docker `amd64`, digest `bd501040b7432344`: on 26 November 2026, connected, measured and withheld as a data-centre network. No billed request.
- Windows `amd64` and `arm64`, digests `e2a3557e46c9e546` and `5ca66a8dec3becd9`: on 26 November 2026, started on hosted virtual machines of their architecture and reached the relay's refusal of an unknown device. Never enrolled.
- macOS `arm64`, digest `2b24631d8079012d`: on 29 November 2026, set up by hand on a Mac on a home line as the launchd user agent the installer writes, with that program. It connected, and its device, measured and admitted on an earlier day under an earlier build, read admitted and routable. No billed request, and the installer itself was not run. An earlier build, digest `c739273a9de679a3`, ran once on 26 November 2026: connected, measured and withheld as an unclassified network.
- Linux `arm64`, `armv7`, `armv6`, `riscv64` and both router files: run only under emulation, which is not a run on that system.

### If it is not connected

Nothing starts the program alone again: after a restart of the machine, or when it ended, run step 1 again, or give it a supervisor that does. `tail -n 5 coronium-agent.log`, in the working folder, shows why it is not connected.

### Update

`/kit/index.json` names the published `version`, and publishing a newer agent does not stop one that is running. To update, download and check the new file as in [the files section](https://supply.coronium.ai/guides/device-files.md), stop the running program, put the new file in its place and start it as before. `agent.env` stays as it is.

### Stop and remove

Stop, remove, withdraw: [update, stop, remove and withdraw](https://supply.coronium.ai/guides/device-lifecycle.md).

## Inside an app: the Android library

This section alone: https://supply.coronium.ai/guides/device-android-sdk.md

The library lets the user of your Android app share the phone's connection with Coronium. Only that user turns it on, on a screen the library shows with the sharing notice unchanged. Your app cannot turn sharing on, hide it or bring it back after a no, may always turn it off, and may not reach into the library's inner classes. It is a preview with a proposed notice: until the owner approves it, the supply site enrols no device from an app, and an app that is not debuggable opens no consent screen. Calls go to https://supply.coronium.ai.

### Needs

- An app whose stated main purpose is sharing its user's connection: [store declarations](https://supply.coronium.ai/guides/device-android-store.md) says where it may ship and what to declare.
- Your account's app token, minted as [enrolment by token](https://supply.coronium.ai/guides/device-tokens.md) says and kept on your server, never in the app, and that server's HTTPS address for step 4.
- `/kit/index.json` listing an `aar` file: until it does, nothing is published.
- `minSdk` 26, `compileSdk` 34 or later, Kotlin 2.1 or later.
- A 64-bit app (ARM or x86-64): in a 32-bit process the library pauses and enrols nothing.
- No other gomobile library (`libgojni.so`) in the app.

### Steps

1. Add the repository, for the group `ai.coronium` only, and the dependency. Its permissions and components merge into your manifest, none exported.

```kotlin
// settings.gradle.kts, in dependencyResolutionManagement { repositories { ... } }
val supply = "https://supply.coronium.ai"
maven { url = uri("$supply/kit/maven/"); content { includeGroup("ai.coronium") } }

// app/build.gradle.kts
dependencies { implementation("ai.coronium:device:0.1.0") }
```

Name the SHA-256 of its `.aar`, `.module` and `.pom` from `/kit/SHA256SUMS` in `gradle/verification-metadata.xml`.

2. Initialize it once, in `Application.onCreate`. It starts nothing, and does nothing outside the app's main process. `dailyByteCap` may lower the notice's daily limit, never raise it.

```kotlin
Coronium.initialize(this, CoroniumConfig(enrolUrl = getString(R.string.enrol_url)))
```

3. Offer the library's screen and its settings from buttons of your own.

```kotlin
share.setOnClickListener { Coronium.showConsent(this) }
settings.setOnClickListener { Coronium.openSettings(this) }
```

Expect `Shown`, `AlreadyOn`, or `NoticeNotApproved` (a proposed notice in a build that is not debuggable). `Turn sharing on` makes the install's random id and secret, asks for the notification permission and calls step 4; back, home or `Not now` is a no. `Coronium.state` follows sharing; `Coronium.turnOff()` turns it off.

4. On your server, send the library's `POST` of `{deviceId, secretSha256, app}` to the exchange with your token and the consent kept from the mint, and give the app Coronium's status and body unchanged:

```python
import json, os, urllib.error, urllib.request

SUPPLY = "https://supply.coronium.ai"

def enrol(body: bytes) -> tuple[int, bytes]:
    asked = json.loads(body)
    sent = {"secretSha256": asked["secretSha256"], "app": asked["app"], "consent": json.loads(os.environ["CORONIUM_CONSENT"])}
    request = urllib.request.Request(SUPPLY + "/app/api/devices/" + asked["deviceId"], method="PUT",
        data=json.dumps(sent).encode(), headers={"Authorization": "Bearer " + os.environ["CORONIUM_APP_TOKEN"], "Content-Type": "application/json"})
    try:
        with urllib.request.urlopen(request, timeout=30) as answer:
            return answer.status, answer.read()
    except urllib.error.HTTPError as refused:
        return refused.code, refused.read()
```

Expect `201`, and `200` on a repeat. The secret never leaves the phone. Keep the id beside your own user: rewards are yours to pay, and a reinstall is a new id.

### States

- `Off`: no yes for this notice, or turned off; only the settings switch turns it on again. Also when the supply site holds no record of the yes (a plain token's exchange): the notice is offered again.
- `Waiting(reasons)`: on, and the phone is not charging or its network is metered, mobile data, roaming, a VPN, not validated or gone. The notification says so.
- `Connecting`, then `Sharing`, with the notification and its `Turn off`, which comes back if swiped away.
- `Paused(reason, code, cause, fix)`: the daily limit, notifications refused, a refusal of enrolment or the relay, or a phone that cannot run the core or keep its files; the next resumed screen tries again.
- `Withdrawn(by)`: removed by the user, by you, by a revoked token or by Coronium. A new yes makes a new id.

### Limits

- At most 2 GB a day, counted on the phone as a stop and sent nowhere, and `Limits.MAX_STREAMS` connections at once. The edge alone meters.
- After a crash, an update or a restart it comes back only at the app's next resumed activity. A force stop counts as `Turn off`.

### Each file

The library's state and limits are in `/kit/index.json`, and `/kit/APP-NOTICE.md` is its notice, byte for byte. It was run end to end on a development Android instance, never on a phone.

### Reinstall and removing a device

When your user enrols again with a new id, or leaves, withdraw the old id from your server as [device states](https://supply.coronium.ai/guides/device-states.md) says. The user's own `Withdraw` removes the phone without you.

## Many devices: enrolment by token

This section alone: https://supply.coronium.ai/guides/device-tokens.md

A token lets each device enrol itself, holding no session or access code, and no device secret crosses the network. Calls follow [enrolment](https://supply.coronium.ai/guides/device-enrol.md).

### Needs

- These routes answer `503` `enrol_tokens_off` until the operator opens them ([limits](https://supply.coronium.ai/guides/limits.md)).
- An account signed in that signed the text in force ([enrolment](https://supply.coronium.ai/guides/device-enrol.md), steps 1 to 3), and the yes of the devices' owner.

### Steps

1. Mint a token with the access code as proof; `expiresInHours` and `label` are optional, and `uses` above what the account may still enrol is refused with `most`.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
jq -c '{consent: {version, sha256}, agreed: true, uses: 1, label: "rack_a"}' coronium-consent.json > coronium-mint.json
jq -c --slurpfile m coronium-mint.json '$m[0] + {proof: {code: .accessCode}}' coronium-account.json | curl -sS -b coronium.cookies -H 'Content-Type: application/json' -d @- "$SUPPLY/app/api/enrol-tokens" -o minted.json
if jq -e '.tokenId | strings' minted.json > /dev/null; then
  jq -r '"Authorization: Bearer \(.token)"' minted.json > token.header
  jq -c .consent minted.json > consent.json
else
  jq -r '"\(.code): \(.cause) Fix: \(.fix)"' minted.json; false
fi
```

Expect: `token.header` and `consent.json` for each device; the token is shown once. A refusal prints its code, cause and fix and writes neither: `enrol_tokens_off` (enrol as in [enrolment](https://supply.coronium.ai/guides/device-enrol.md)), `token_limit_reached` (revoke one), `device_cap_reached`, `agreement_unsigned`. Safe to repeat: no.

2. On each device, make the id and secret and write `agent.env` before any call, so a lost answer is sent again with the same pair.

```sh
umask 077
[ -e agent.env ] || {
  head -c 32 /dev/urandom >secret.bin
  id=$(od -An -tx1 -N16 /dev/urandom | tr -d ' \n' | sed -E 's/^(.{8})(.{4})(.{4})(.{4})(.{12})$/\1-\2-\3-\4-\5/')
  printf 'CORONIUM_DEVICE=%s\nCORONIUM_DEVICE_SECRET=%s\n' "$id" "$(od -An -tx1 -v secret.bin | tr -d ' \n')" >agent.env
}
```

3. Exchange the token. The body is `secretSha256`, the SHA-256 of the raw secret bytes, never of their hex text, and `consent`.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
id=$(sed -n 's/^CORONIUM_DEVICE=//p' agent.env)
printf '{"secretSha256":"%s","consent":%s}' "$(sha256sum secret.bin | cut -d' ' -f1)" "$(cat consent.json)" >exchange.json
code=$(curl -sS -o answer.json -w '%{http_code}' -X PUT -H @token.header -H 'Content-Type: application/json' \
  --data-binary @exchange.json "$SUPPLY/app/api/devices/$id")
case "$code" in 200|201) printf 'CORONIUM_RELAY=%s\n' "$(jq -r '.relay // empty' answer.json)" >>agent.env && rm -f token.header secret.bin exchange.json ;; esac
echo "$code"
```

Expect: `201` (`applied`), or `200` (`already_applied`, no use spent) for the same id and secret. If refused: `bad_enrol_token`, `enrol_token_expired`, `enrol_token_used` or `enrol_token_revoked` (mint another), `consent_outdated` (sign the text in force, then mint again), `device_id_taken` (delete `agent.env` and `secret.bin`, start at step 2). A 429 means wait: until `retryAt` when given, else a second. A null `relay` means ask the operator. Safe to repeat: yes.

Then run the agent with `agent.env`; [`/kit/SIGNING.md`](https://supply.coronium.ai/kit/SIGNING.md) has a worked digest.

### Many devices in one call

`PUT /app/api/devices` takes `consent` and `devices`, pairs of `deviceId` and `secretSha256`, and skips entries the account already holds; [the API](https://supply.coronium.ai/openapi.json) has the rest.

**Never bake `agent.env` into an image**: copies of one id and secret are one device, each replacing the last at the relay. Bake `token.header` and `consent.json`; make the pair at first boot.

### Read, revoke and withdraw

`GET /app/api/enrol-tokens` lists each token's `state`, `used` and `app`, never the token. `POST /app/api/enrol-tokens/{tokenId}/revoke` with `{}` revokes one; `{"withdrawDevices": true, "confirm": true}` also withdraws its devices. Replacing the access code revokes all.

## Device states, earnings and payouts

This section alone: https://supply.coronium.ai/guides/device-states.md

Calls go to https://supply.coronium.ai, signed in as in [enrolment](https://supply.coronium.ai/guides/device-enrol.md).

### Steps

1. Read the devices once a minute until the new one is measured.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
curl -sS -b coronium.cookies "$SUPPLY/app/api/devices" | jq -c 'if .code then {code, cause, fix} else .devices[] | {deviceId, status, state, reason} end'
```

Expect: `online` once the agent connects. Then act on `state` and `reason`:

| Reads | Means | Do |
|---|---|---|
| `status` `offline` | the agent is not connected | unless you stopped it, its log says why: [troubleshooting](https://supply.coronium.ai/guides/device-troubleshoot.md) |
| `new`, `not_measured` | connected, not measured yet | read again a minute later |
| `withheld`, `unclassified_asn` | the network is not classified yet | nothing: leave it running, tell your person, do not enrol again |
| `withheld`, `class_not_sold` | a network Coronium does not sell, such as a data centre | stop it: it earns nothing. Do not enrol again from this network |
| `withheld`, `same_exit` | an earlier residential device, of any account, exits from this address | move it to a connection of its own, or stop it |
| `withheld`, `exit_unverified` or `exit_changed` | three measurements in a row failed, or the country changed | keep it running: it is measured again |
| `withheld`, `supplier_blocked` | the operator blocked the account | tell your person |
| `admitted` | carries buyer traffic as fallback supply | done |
| `established` | carries traffic first, after the operator promoted it on a clean history | done |
| `paused`, `private` | the account's own choice | nothing, unless your person asks |
| `withdrawn` | permanent | a new enrolment, if your person wants one |

`requests`, `bytesUp` and `bytesDown` include Coronium's own exit measurements, which earn nothing. Safe to repeat: yes.

`health` says whether a device still carries traffic: [device health](https://supply.coronium.ai/guides/device-health.md).

2. Read the statement.

```sh
umask 077
SUPPLY=${SUPPLY:-https://supply.coronium.ai}
cd "${CORONIUM_DIR:-$HOME/coronium}" || exit
curl -sS -b coronium.cookies "$SUPPLY/app/api/earnings" | jq '{earned, held, available, requested, paid, payoutMinimumUsdMicros, terms}'
```

Expect: the totals and `terms`; [the statement and a payout](https://supply.coronium.ai/guides/device-payouts.md) explains each field. Safe to repeat: yes.

Payouts are paid by hand on the 6th of each month, for requests received before it; later ones the next month.

3. Ask for a payout, only with your person's word: [the block](https://supply.coronium.ai/guides/device-payouts.md).

### What a device refuses

Beside the ranges the protocol forbids, a device never dials what its system shows of its own network: its own addresses as its interfaces show them, its default gateway (the home router), any address on the links of its interfaces, and any of these behind a NAT64 prefix that the protocol or its resolver names. Such a target is answered `target_blocked`. What the system does not show is not refused yet: the public address of a router in front of the device, which the device does not know, and a target behind a NAT64 prefix that only the router announces. When the device cannot tell whether an IPv6 target is safe (it cannot read its interfaces, its resolver failed on `ipv4only.arpa` or synthesizes in a form it cannot read, or an IPv6 address of the device has no on-link prefix it can read), it carries IPv4 only, answers a target with no IPv4 address `unreachable`, and its log says why. Nothing to do.

### Stop and withdraw

Stopping the agent stops sharing; withdrawal is for good. [Update, stop, remove and withdraw](https://supply.coronium.ai/guides/device-lifecycle.md) has the one answer for each. `reason` says who withdrew:

- `user`: the device's own secret: in an app, its user's no
- `account`: the account, signed in
- `token`: a revoke of the token that enrolled it
- `fleet`: Coronium, for the whole account
- `owner`: Coronium, for this device, or an older withdrawal

## Stated limits

This section alone: https://coronium.ai/guides/limits.md

- The operator opens and closes registration, the proxy endpoint, the chat and per-GB peer sales: `GET /app/api/buy` answers `registration`, `chat` and `peerSales`, and `GET /app/api/proxy` answers `endpoint.state`. Closed, enrolment by token ([Many devices](https://coronium.ai/guides/device-tokens.md)) answers 503 `enrol_tokens_off`, an app token `app_devices_off`, and every route under `/app/api/sessions` 503 `device_sessions_off`.
- The service sells mobile and residential peer devices. Carrier modems (`mbl`), ISP addresses and datacenter addresses asked for in a username are recorded as demand and answered `on_request`. A dedicated carrier modem is the Private mobile proxies product. Reserved addresses are not offered.
- A product the buyer site's `/llms.txt` does not list as available is not built; a signed-in account may ask for one, free.
- The proxies page marks a balance low when it buys less than 1 GB at the chosen price.
- A count under 5 devices reads `few`, and a city, carrier or network with fewer than 5 devices online is not listed.
- A quote lasts 30 minutes.
- A request for a product that is not built carries a note of at most 500 bytes.
- A private line takes one rotation in 120 seconds, whichever way it was asked.
- A private line's rotation interval is at least 2 minutes.
- A private line's rotation interval is at most 1440 minutes.
- An account replaces one private line in 24 hours.
- While orders are taken, private lines that cannot be delivered at once are usually supplied within about 3 days.
- At most 20 private devices wait to be supplied per account.
- A route refused repeatedly is answered from memory, with `Retry-After`, up to 60 seconds.
- Notifications are kept 90 days after their last event.
- A read lists 20 notifications at most.
- A private line's end is reported 3 days before.
- A device that was connected and then stays without a connection for 30 minutes is reported to its account, in one notification a day that counts the devices.
- Outcomes are read 31 days at most.
- Edges reread credentials every 1 second.
- A replaced credential answers `credential_replaced` for up to 30 days.
- One address may send the enrolment exchange 60 tokens that can enrol nothing per sign-in window; a live token never counts.
- Sign-up challenges last 10 minutes.
- A mailed link works once, for 15 minutes.
- A withdrawn device never connects again; for 30 days relays refuse it with no retry, then as unknown.
- An account enrols at most 1000 devices of its own a day, withdrawn ones counted, fewer if its device limit is lower.
- The Android app library shares at most 2 GB a day, and an app may only lower it.
- The operator makes at most 20 accounts an hour.
- Hosting networks add 4 challenge bits.
- A chat confirmation waits 10 minutes for its click.
- Chat confirmations and the record of chat actions are kept 90 days.
- Without an account, one address asks the chat at most 60 requests in a quarter of an hour.
- Guests together ask the chat at most 600 requests in a quarter of an hour.
- An account holds at most 5 lasting credentials: proxy passwords for its tools and agents.
- A model reads at most 100 requests of one account's chat a day.
- One account's chat uses at most 300000 model tokens a day.
- One chat message makes at most 4 requests of a model.
- A chat message a model reads reserves 148384 tokens of the day and is settled to what it used.
- IP class and carrier are decided by the network (ASN) a device exits from. The exit is measured on IPv4 only. A modified agent can recognise the measurement.
- A sticky session holds one device while it stays in the pool, then moves to another device.
- A city name that two states share selects both unless `state` is given.
- A proxy request to mail ports 25, 465, 587 and 2525, or to an IPv6 literal, is refused with `target_blocked`.
- One buyer's limit on simultaneous streams is counted per edge server.
- Traffic in flight when a balance runs out, an account is suspended or a byte cap is reached is charged in full until the stop takes effect (not measured yet). Traffic charged into debt earns the device owner nothing.
- A usage batch delivered more than 15 minutes late, across a device's change of country, is priced at the new country.
- A reversed payment does not take back earnings already credited to a device owner.
- An account saves at most 64 session sets of up to 1,000 sessions each. Saved sessions have no traffic counters.
- An account holds at most three open quotes with one provider. A refund or dispute is recorded for the operator to reverse by hand.
- The `limits` of every device session quote bound one account's sessions.
- A network in no reviewed list is classed by its operator name: hosting is a data centre, not sold; any other is residential, never mobile.
- An agent file marked `preview` in `/kit/index.json` was built for its system but not yet through Coronium's whole check there. Nothing in `/kit/` is signed yet.
- An account holds at most `terms.deviceLimit` devices (`GET /app/api/earnings`) when that is a number. Payouts are made by hand, one request at a time, from the payout minimum up. A payout request is proven with the access code.
- Top-ups are tested against provider stand-ins; `GET /app/api/buy` answers which way to pay is `configured`.
- No capacity figure is claimed for this build: throughput gates run on separate hardware, published with hardware, node count and duration.
