Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions docs/CONSOLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ The console is for people who operate Simlock. It needs an operator token.
Coding agents keep using the CLI, the MCP server, the client and the HTTP API.

This version has sign-in, the console's navigation (Workers, Leases, Waiting,
Attention and Events), the Workers pages, the Waiting page and the Attention
page. The other pages say "Coming soon" until their views are built.
Attention and Events), the Workers and Leases pages, the Waiting page and
the Attention page. The other pages say "Coming soon" until their views are
built.

## Turn it on

Expand Down Expand Up @@ -115,6 +116,7 @@ Select a worker to open its page. It adds:
was granted, and a device being provisioned or reclaimed on a connected
worker how long that has taken so far. Other states show `—`: the daemon
reports no time for them.
- **Leases**: the leases on this worker, as the Leases page shows them.
- **Host**: the operating system, the CPU architecture, and the version of
each platform tool, such as Xcode or the Android emulator.
- **Catalog**: the models and runtimes the worker can lease. It is read again
Expand All @@ -125,6 +127,49 @@ Select a worker to open its page. It adds:
A page the daemon cannot answer on a single host says "Not available on a
single host" in place of its content.

## Leases

**Leases** lists every lease the daemon holds, as `simlock list --leases`
does. On a gateway that is every lease on every worker, including the ones a
worker granted itself. On a single host it is the host's own leases.

Each lease shows:

| Fact | What it says |
| --- | --- |
| Holder | Who holds the lease (see below) |
| Worker | The worker the device is on, by its label, or its id when it has none |
| Device | The device's model and id |
| Mode | `slim` or `full` |
| Image tag | The image tag the device was created from, or `—` |
| Granted | How long ago the lease was granted |
| Expires in | How long until the lease expires unless it is renewed. It counts down every second. |
| Last renewed | How long ago the lease was last renewed, or granted if it never was |

Select a lease to open its page. It shows the same facts, the device's UDID,
and the id of the request that was granted the lease, while the daemon still
keeps it. A lease that has been released or has
expired says "Lease not found".

### Who holds a lease

A lease taken over the HTTP API belongs to the token that took it. The console
shows that token's label, with the token id beside it: `ci-runner-3
tok_9f2c`. Give each agent's token a label when you create it, so you can tell
them apart:

```sh
simlock token create --role agent --label ci-runner-3
```

A token created without `--label` shows as its id alone. A lease taken
through the CLI or the MCP server on the host itself is held by the agent id
it was taken with, and shows that id. The console matches a lease to a token
by id only, so an agent id that happens to equal a token's id shows that
token's label: the label names who the lease says holds it, not proof. On a
gateway the labels are the gateway's own tokens. A lease taken on a worker
directly shows its holder's id as that worker reports it.

## Waiting

**Waiting** lists every request waiting for a device, oldest first, as
Expand Down
22 changes: 18 additions & 4 deletions docs/HTTP-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Three roles:
| Role | Can |
|---|---|
| `agent` | catalog, status, installed components, its own lease requests and leases, `exec` on its own lease |
| `operator` | everything `agent` can, plus every other requester's leases/devices, the worker routes, event replay/stream, and releasing any lease |
| `operator` | everything `agent` can, plus every other requester's leases/devices, the token records, the worker routes, event replay/stream, and releasing any lease |
| `worker` | open an uplink at [`/v1/uplink`](#get-v1uplink-websocket-upgrade), and nothing else |

A valid token with the wrong role for a route is `403 FORBIDDEN`, not `401` —
Expand Down Expand Up @@ -1123,7 +1123,9 @@ take the host out of rotation or forget it.

### Operator routes

Role: `operator` for all five.
Role: `operator` for all six. `GET /v1/leases` also answers an `agent`
token, with only its own leases. `GET /v1/lease-requests` and `GET /v1/tokens`
answer it `403 FORBIDDEN`.

`DELETE /v1/leases/{id}` with an `operator` token already releases any single
lease, on a gateway as anywhere else. The fleet-wide form of that — the CLI's
Expand All @@ -1150,14 +1152,26 @@ an all-or-nothing that leaves the operator guessing.
memory.
- `GET /v1/events/stream` — Server-Sent Events follow of the event bus
(`simlock events --follow`).
- `GET /v1/tokens` — every token this daemon knows (`simlock token list`):

On a **gateway** all five are fleet-wide, which is what makes a single
```json
{ "tokens": [
{ "id": "tok_9f2c", "role": "agent", "label": "ci-runner-3", "createdAt": 1735689600000 }
] }
```

A token's `id` is the `requesterId` on the leases it takes over HTTP, so a client can
show a lease's holder by the token's `label`. The answer never carries a
secret or a hash. `label` is absent from a token created without one.

On a **gateway** the first five are fleet-wide, which is what makes a single
console possible: `/v1/leases` and `/v1/devices` return every connected
worker's, each record carrying the `workerId` it lives on,
`/v1/lease-requests` returns the gateway's queue and every connected
worker's, and the two event routes carry the workers' republished events
(also `workerId`-tagged) interleaved with the gateway's own `worker.*` and
`request.dispatched` facts.
`request.dispatched` facts. `/v1/tokens` lists the daemon's own tokens: on a
gateway, the gateway's, since tokens never cross machines.

#### `GET /v1/lease-requests`

Expand Down
Loading
Loading