# Quickstart

Install the `wai` command line, watch WAI's four steps run on a sample, then run a live room
on your own machine and open it in two tabs. Everything here is open source under Apache-2.0
and runs on your machine: no account, and nothing sent anywhere else.

## 1. Install

The prebuilt command line comes with what it runs locally: the relay, the room service, the
room client a browser loads, a remote desktop host and the packager. Pick one:

```sh
# macOS or Linux, with Homebrew
brew tap transaction-science/tap https://git.transaction.science/Transaction-Science/homebrew-tap
brew install transaction-science/tap/wai

# macOS or Linux, without Homebrew: into ~/.wai, the archive checked against its SHA-256
curl -fsSL https://wai.transaction.science/install.sh | sh

# Windows, with Scoop
scoop bucket add transaction-science https://git.transaction.science/Transaction-Science/scoop-bucket
scoop install wai
```

The install script says which line puts `~/.wai/bin` on your path.

**From source**, with a Rust toolchain and nothing else (no codec library):

```sh
git clone https://git.transaction.science/Transaction-Science/open-standards
cd open-standards
cargo install --locked --path wai/wai-rs --no-default-features --features quickstart --bin wai
cargo install --locked --path joule-code/joule-code-rs/crates/joule-moq-relay
cargo install --locked --path joule-code/joule-code-rs/crates/joule-moq-room
```

A build from source also needs the room client's files for `wai dev`: `bash
wai/quickstart/build-web.sh <dir>` makes them (it needs the `wasm32-unknown-unknown` target
and the WebAssembly bindings tool it names), and `wai dev --web <dir>` serves them.

## 2. See WAI's four steps

```sh
wai hello
```

`wai hello` makes a small picture and takes it through the four steps every WAI object takes:

1. **Name.** The picture is packed in an envelope that names the capability it needs,
   `wai.image.png`.
2. **Dispatch.** The envelope is read back, and the capability this machine holds runs. One it
   does not hold would run the envelope's fallback, or be reported inert, never guessed.
3. **Rebuild.** The picture comes back byte for byte.
4. **Receipt.** The object's content hash goes into a receipt signed with a key made for the
   run, written beside the object, and checked.

It writes the object and its receipts into `wai-hello/`. `wai verify wai-hello` checks them
again, offline; change one byte of either and it says which check refused it.

## 3. Run a room on your machine

```sh
wai create my-room --template video-room
cd my-room
wai dev
```

`wai create` writes a project from one of the [examples](/docs/examples/): here a page of your
own with a live room in it. `wai dev` starts a relay and a room service on loopback, makes the
room's keys in `.wai/dev/` the first time, and serves your page, the room service and the
relay's WebSocket binding on one origin:

```text
wai dev: ready on http://127.0.0.1:8080
  your page   http://127.0.0.1:8080/
  the room    http://127.0.0.1:8080/room/?service=/room-api
  room API    http://127.0.0.1:8080/room-api/room
  relay       ws://127.0.0.1:8080/moq  (WebSocket, subprotocol moqt-22)
```

Open `http://127.0.0.1:8080/` in two tabs, or two browsers, and press **Join** in each. Each tab
makes its own key, asks the room service for a grant for it, and proves the key to the relay.
Each shows the other's camera and plays its sound, and checks every object against its signed
receipt before it decodes it. Ctrl-C stops the relay and the room service with it.

`wai dev --check` starts the same three, checks each through the origin (the page and its
WebAssembly, the room service and its clock's session on the relay, a viewer's grant, the
relay's WebSocket upgrade), prints the time it took, and stops. `wai dev --help` lists the other
rooms it runs: a watch room (`--watch`), a call (`--call`), a conversation beside the room
(`--messaging`), a remote desktop room (`--remote`).

## 4. Next

- [The examples](/docs/examples/): each one a template of `wai create`, with the test that runs
  it.
- [The SDKs and libraries](/docs/sdk/): the command line, the Rust crate, the room client for
  the browser, the native sinks for Apple platforms and Android, and the independent verifiers.
- [The room service and the relay](/docs/api/): every HTTP route, and how a client connects.
- Working with a coding assistant? `wai setup-agent` in a project writes the instructions an
  assistant reads and connects it to WAI's tools.

To have the relay and the room service run for you rather than on your own machines, see
[waiTransport](https://waitransport.transaction.science/).
