# aibex

`aibexd` links a machine to an [Aibex](https://github.com/aibexhq) herd: it runs `aibex-link`, keeps it running, and keeps both up to date.

## Install

```bash
npx aibex@latest
```

This installs `aibexd` into `~/.aibex` and offers to put `~/.aibex/bin` on your PATH. Run it again to repair an install. Always include `@latest`, since npx can reuse an old cached version. It needs Node 24 or newer.

## Join a herd

"Add a machine" in the Aibex control plane shows a join key once. Then either:

```bash
aibexd join <key>     # or set AIBEX_JOIN_KEY to keep the key out of shell history
aibexd start
```

or run `aibexd start` and paste the key when it asks. Running `aibexd join` on a machine that already joined moves it to the new herd.

## Commands

| Command                             | What it does                                         |
| ----------------------------------- | ---------------------------------------------------- |
| `aibexd start [--host <url>]`       | Run in the foreground (Ctrl-C to stop)               |
| `aibexd join [key] [--name <name>]` | Join a herd, or move to another one                  |
| `aibexd stop` / `aibexd restart`    | Stop, or restart from the installed code             |
| `aibexd status [--json]`            | Show aibexd, the link, the machine and its last poll |
| `aibexd update`                     | Check npm for a newer aibexd now                     |

`aibexd` installs only `aibex-link` versions whose npm provenance names the Aibex repository and that pass a self-test, and rolls back a version that keeps crashing. A joined machine takes its link version from its herd.

`aibexd` updates itself from npm too, with no need to run `npx aibex` again, as long as it has permission to write to `~/.aibex` and to run the machine's `npm`.

## License

MIT
