Metadata-Version: 2.5
Name: unidroid-cli
Version: 0.4.5
Summary: udcli - the Unidroid command line: auth, account, challenge, submission, bench, dataset and validator
License: MIT
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: huggingface-hub>=0.25
Requires-Dist: pyyaml>=6
Requires-Dist: rich>=13
Requires-Dist: typer>=0.12
Provides-Extra: dev
Requires-Dist: py-sr25519-bindings>=0.2; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: wallet
Requires-Dist: bittensor-wallet>=4.0; extra == 'wallet'
Description-Content-Type: text/markdown

# udcli - Unidroid CLI

Submit robotics models (VLAs, WAMs, world models) to [Unidroid](https://unidroid.ai) challenges,
manage your account, and use BenchHub.

```bash
pip install unidroid-cli            # core
pip install "unidroid-cli[wallet]"  # needed for submission submit / account coldkey register
```

Env: `UNIDROID_API_URL` (`https://api.unidroid.ai`), `UNIDROID_API_KEY`, `UNIDROID_HOME` (`~/.unidroid`),
`UNIDROID_CACHE_DIR` (`~/.unidroid/bench-cache`), `HF_TOKEN`. Without `UNIDROID_API_URL` or `--api-url`,
`udcli` talks to `https://api.unidroid.ai`. `~/.unidroid/credentials.json` is written atomically and limited to
your user.

Commands that cannot be undone (`account coldkey remove`, `auth keys delete`, `dataset discard`,
`dataset archive`) ask first; pass `--yes` / `-y` to skip the question in scripts.

## Commands

Commands are grouped by what they act on, like the Hugging Face `hf` CLI. `udcli <group>` (or `-h` at any level)
lists what a group can do.

| Group | Commands | For |
| --- | --- | --- |
| `auth` | `login`, `logout`, `whoami`, `keys list\|create\|revoke\|delete`, `hf set\|status\|remove` | Who you are, API keys, the Hugging Face read token |
| `account` | `balance`, `ledger`, `claim`, `coldkey list\|register\|remove` | Platform balance, TAO deposits, coldkeys |
| `challenge` | `list`, `show`, `leaderboard` | Browsing challenges |
| `submission` | `hash`, `push`, `check`, `submit`, `resume`, `list`, `show` | Your entries, from preparing to results |
| `bench` | `list`, `info`, `download`, `upload`, `link`, `status`, `cache list\|info\|clear` | BenchHub benchmarks |
| `dataset` | `list`, `info`, `mine`, `buy`, `download`, `upload`, `media`, `uploads`, `discard`, `set-price`, `edit`, `pending`, `approve`, `reject`, `archive`, `restore` | Datasets for sale |
| `validator` | `pending`, `fetch` | Validator accounts |

`--api-key` and `--api-url` work on every command, before or after the subcommand. They apply only to
that run, so you can use another account without `udcli auth login` and without replacing the saved key.
`UNIDROID_API_KEY` does the same when the flag is omitted. List commands accept `--json`.

## Miner quick start

```bash
udcli auth login                              # optional: save an API key from unidroid.ai/account/api-keys
udcli account balance --api-key unidroid_...  # or pass the key on any command; overrides login
udcli auth hf set                             # read-only HF token for validators
udcli account coldkey register --wallet miner
udcli account coldkey remove <ss58>           # or: --wallet miner
udcli account balance                         # shows the address to send TAO to
# After transferring TAO from that coldkey:
udcli account claim 9092713-0006              # extrinsic id from the block explorer

udcli challenge list
udcli challenge show pi05-libero-s1
udcli submission hash --path ./my-submission
udcli submission check --path ./my-submission --challenge pi05-libero-s1
udcli submission submit --path ./my-submission --hf-repo you/pi05-libero --challenge pi05-libero-s1 \
             --wallet miner --hotkey default
udcli submission list
udcli submission show 42                      # each validator's status, score, error, success rate, episodes
udcli challenge leaderboard pi05-libero-s1
```

Every submission is a folder: `agent.yaml`, `brain/`, `train/`, optional `tests/` and `docs/`, and `weights/`.
Weights go to your own Hugging Face repo; the rest goes to Unidroid as one deterministic ZIP. `agent.yaml` lists
the sha256 of every file under `weights/`, and the hotkey signs those hashes with the ZIP's hash. Keep the pinned
commit available and unchanged until Review ends, or you're disqualified. Winners are copied to Unidroid's HF org
before payout; the published copy also holds the ZIP.

Start from the brain's template, `template-<brain>` (`pi05`, `groot17` or `flux`), published in the
[Unidroid-AI](https://github.com/Unidroid-AI) GitHub organization. `init` clones from there; set
`UNIDROID_TEMPLATES_URL` (or pass `--source`) to use a different git URL prefix or a local folder.

```bash
udcli submission init --brain pi0.5-v0 --path ./my-submission   # or gr00t-n17-v0, flux3-action-v0
udcli submission hash --path ./my-submission            # (re)write the weights: block of agent.yaml
udcli submission hash --path ./my-submission --check    # verify only
udcli submission check --path ./my-submission --challenge pi05-franka-s1
udcli submission push --path ./my-submission --hf-repo you/pi05-weights   # optional: push weights/ on its own
udcli submission submit --path ./my-submission --hf-repo you/pi05-weights --challenge pi05-franka-s1 \
             --wallet miner --hotkey default
udcli submission resume <upload-id>                     # finish an interrupted upload (24 hours)
```

`submission submit` pushes `weights/` with your local Hugging Face login (`HF_TOKEN` or `hf auth login`;
it never leaves your machine), creating a private repo when missing and skipping the push when `main`
already holds the same files. It then pins the commit, compares it with `agent.yaml`, builds the ZIP and
uploads it. The publication terms and the fee are shown first: nothing is pushed to Hugging Face until you accept,
and any files on `main` that `agent.yaml` does not declare are listed before they are removed. Interrupted
uploads resume without re-sending finished parts. `--skip-upload --revision <sha>` uses weights you pushed
yourself (`--revision` is only valid with `--skip-upload`), `--write-hashes` rewrites stale
hashes without asking. Validators download with the read token saved by `udcli auth hf set`; it must belong
to the repo owner and must not be able to write. The fee is charged when the upload completes. `.DS_Store`,
`Thumbs.db`, swap and backup files, `.cache/`, `.git/` and `__pycache__/` are never hashed or uploaded; any
other dot file under `weights/` is refused.

## Validators

```bash
udcli validator pending [--challenge pi05-franka-s1] [--phase public|private]   # API key only, no tokens
udcli validator fetch 42 --out ./submission-42 --wallet validator --hotkey default   # signed by your linked hotkey; every hash checked
```

## BenchHub

```bash
udcli bench list [--category manipulation] [--visibility public]
udcli bench info libero-spatial
udcli bench download libero-spatial     # sha256-verified, cached
udcli bench upload ./my-bench --visibility private [--thumbnail cover.png]   # team role
udcli bench link franka-tabletop-v13 --visibility private   # admin, Nepher EnvHub
udcli bench status
udcli bench cache list | info | clear [id]
```

A benchmark is either uploaded to R2 or linked from the Nepher EnvHub. `bench link` is admin only: it takes an
EnvHub environment id, and the server reads that bundle's `manifest.yaml` as the BenchHub record. The bundle
stays on EnvHub and the server pins its current sha256. Downloads work the same for both: the API checks access
and returns a short-lived URL, and EnvHub bundles are streamed through the Unidroid API. You never need a Nepher
API key.

- **Public**: any logged-in user.
- **Private**: validators and the uploading team, only during the active window (UTC). Never miners.
- **Admins**: always.

A bundle needs `manifest.yaml` with `id`, `name`, `category`, `format`,
`description`. Optional: `robot` (for example `franka-panda`) and `robot_type` (any string, for example
`arm` or `humanoid`). Put any revision in the id. A benchmark id is immutable.

## Datasets

Robot datasets for training VLA models. Anyone can browse; buying and downloading need `udcli auth login`.

```bash
udcli dataset list [--search franka] [--free] [--sort popular]
udcli dataset info franka-pick-place-v1        # price, size, license, Hugging Face preview, what you may do
udcli dataset buy franka-pick-place-v1         # pays from your balance (see: udcli account balance)
udcli dataset download franka-pick-place-v1 [--out ./data] [--extract]
udcli dataset mine
```

Downloads resume after an interruption and are checked against the published sha256. Archives are unpacked
safely: nothing leaves the target folder.

Admins upload and price datasets; a super admin approves an admin's upload (a super admin's own upload goes on
sale once verified):

```bash
udcli dataset upload ./my-dataset --id franka-pick-place-v1 --license CC-BY-4.0 --price 25 \
  --robot franka-panda --hf-repo unidroid/franka-pick-place-v1-sample --sample-episodes 3 \
  --thumbnail ./cover.png --video ./preview.mp4
udcli dataset media franka-pick-place-v1 --thumbnail ./new-cover.png --video ./clip.mp4
udcli dataset uploads                          # your uploads and their review state
udcli dataset set-price franka-pick-place-v1 30
udcli dataset pending                          # super admin
udcli dataset approve franka-pick-place-v1 [--note ...]
udcli dataset reject franka-pick-place-v1 --reason "..."
udcli dataset archive franka-pick-place-v1     # off sale; buyers keep access
```

When `--hf-repo` is given, `udcli` extracts `N` randomly picked episodes (`--sample-episodes N`, plus optional
`--sample-frames` to slice each episode). The picked episode numbers are printed with a seed; pass it as
`--sample-seed` to repeat the same sample. The episodes keep their original numbers. It rewrites LeRobot `meta/` counts so the sample loads directly, generates a Dataset Card
`README.md`, and pushes the free sample to Hugging Face using your local token (`--hf-token`, `HF_TOKEN`, or
`hf auth login`; never sent to Unidroid). The sample is public, so the files are listed and you confirm before
they are pushed (`--yes` or `--confirm-rights` skips it), and a paid dataset whose sample would hold every episode
is refused. Pass `--auto-media` to extract a thumbnail and short preview clip
from the dataset folder automatically. The full folder is packaged deterministically as a store-only ZIP, uploaded
to R2 in parallel parts (`--jobs`), and resumes without re-zipping when you run the same command again.

## Development

```bash
pip install -e ".[dev]"
pytest
```

`tests/protocol_vectors.json` is copied from `unidroid-backend`. `tests/test_backend_e2e.py` runs
against the real backend when it's installed alongside, and is skipped otherwise.

Fetch several submissions in one run so the wallet is unlocked once: `udcli validator fetch 42 43 --out ./subs` or `udcli validator fetch --all-pending --challenge pi05-franka-s1 --out ./subs` (each lands in `submission-<id>/`). Submissions this hotkey already evaluated are skipped (HTTP 409).
