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
19 changes: 18 additions & 1 deletion .fallowrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@
// other source file), and e2e/fake-driver/index.ts is loaded dynamically by the
// daemon via SIMLOCK_DRIVERS_MODULE (see docs/CLI.md) -- neither is visible to
// fallow's static reachability graph without being declared explicitly.
"entry": ["src/index.ts", "src/cli/main.ts", "src/daemon/main.ts", "e2e/**/*.test.ts"],
// The web console is its own entry: Vite loads ui/index.html, which loads ui/src/main.tsx. The
// browser lane's specs are Playwright entry points, as the e2e tests are vitest's.
"entry": [
"src/index.ts",
"src/cli/main.ts",
"src/daemon/main.ts",
"e2e/**/*.test.ts",
"ui/src/main.tsx",
"e2e/console/*.spec.ts"
],
"dynamicallyLoaded": ["e2e/fake-driver/index.ts"],
// The web console's libraries are bundled into dist/ui at build time and ship as files, so
// they are dev dependencies on purpose: the package gains no runtime dependency for them.
"ignoreDependencies": [
"react",
"react-dom",
"@fontsource-variable/geist",
"@fontsource-variable/geist-mono"
],
"ignoreDependencyOverrides": [
// MCP SDK 1.29 transitively requires vulnerable node-server 1.x; lockfile/audit verify this patched override.
{ "package": "@hono/node-server", "source": "pnpm-workspace.yaml" },
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ jobs:
- name: Quality checks
run: pnpm check

console:
name: Console
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
- name: Enable Corepack
run: |
corepack enable
corepack prepare pnpm@11.22.0+sha512.1ff870c4c6133dfd88fb2afc46dd13d47f09c9794b438c6fdb47ca98caf3bc16381ee0be93a091b8e3824cf01f889f46d7d9e20910fb0be1ab0fb5baa80dd621 --activate
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Install Playwright browsers
run: pnpm exec playwright install --with-deps chromium firefox webkit
- name: Browser lane
run: pnpm test:console

fallow:
name: Fallow
runs-on: ubuntu-24.04
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dist/
.fallow/
.claude/settings.local.json
.claude/worktrees/
test-results/
playwright-report/
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ End-user docs live directly under [docs/](docs/) and must stay self-contained
- [CLIENT.md](docs/CLIENT.md) — the programmatic client (`simlock/client`, `simlock/admin`)
- [CONFIGURATION.md](docs/CONFIGURATION.md) — every config key, its default, and how limits interact
- [HTTP-API.md](docs/HTTP-API.md) — the network-facing HTTP API
- [CONSOLE.md](docs/CONSOLE.md) — the web console: turning it on, opening it, signing in
- [EVENTS.md](docs/EVENTS.md) — catalog of business events, end-user cut

Maintainer/agent docs live under [docs/internal/](docs/internal/):

- [ARCHITECTURE.md](docs/internal/ARCHITECTURE.md) — high-level architecture overview
- [DESIGN.md](docs/internal/DESIGN.md) — the design guide for the web console
(and the landing page): type, colour, status colours, spacing, voice
- [DELIVERY.md](docs/internal/DELIVERY.md) — how work flows through GitHub
Issues: the three walkthroughs, handoffs, what is automated, where ADRs fit
- [templates/](docs/internal/templates/) — the feature and task spec bodies a
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ lease-loss notifications are documented in
- [docs/CLIENT.md](docs/CLIENT.md) — the programmatic client (`simlock/client`, `simlock/admin`)
- [docs/CONFIGURATION.md](docs/CONFIGURATION.md) — every config key, its default, and how limits interact
- [docs/HTTP-API.md](docs/HTTP-API.md) — the network-facing HTTP API
- [docs/CONSOLE.md](docs/CONSOLE.md) — the web console the daemon serves for operators
- [docs/EVENTS.md](docs/EVENTS.md) — catalog of business events on `simlock events`

## Made with ❤️ at Callstack
Expand Down
9 changes: 6 additions & 3 deletions docs/ABOUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ devices from a self-hosted simlock host over the network (see
without spawning a `simlock` command at all — agent-device, for
example — can instead depend on `simlock/client`/`simlock/admin`, the typed
programmatic client the CLI and MCP frontends are themselves built on (see
[CLIENT.md](CLIENT.md)).
[CLIENT.md](CLIENT.md)). With HTTP on, the daemon also serves a web console
for operators, signed in with an operator token (see
[CONSOLE.md](CONSOLE.md)).

- `simlock lease` returns a *ready* device — booted and health-checked — that
no other agent will touch for the duration of the lease.
Expand Down Expand Up @@ -73,5 +75,6 @@ registry, and every safety invariant stay on the worker.
optional MCP server reserves stdout for MCP JSON-RPC.

See [CLI.md](CLI.md) for the command surface,
[CLIENT.md](CLIENT.md) for the programmatic client, and
[HTTP-API.md](HTTP-API.md) for the network API.
[CLIENT.md](CLIENT.md) for the programmatic client,
[HTTP-API.md](HTTP-API.md) for the network API, and
[CONSOLE.md](CONSOLE.md) for the web console.
8 changes: 6 additions & 2 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,9 @@ A device currently `provisioning` or `reclaiming` carries a derived
and `list --devices` well before it crosses the threshold that would make
`doctor` flag it as stalled.

Human-oriented overview: daemon health *and mode*, the host it runs on
Human-oriented overview: daemon health *and mode*, the web console's address
when HTTP is enabled (`Console: http://127.0.0.1:4700/`, see
[CONSOLE.md](CONSOLE.md); `daemon.consoleUrl` in `--json`), the host it runs on
(`Host: macOS 15.5 arm64; xcode 16.4 (16F6), emulator 35.4.9`), managed capacity
(used/limit per platform), running and reserved capacity (globally and per
platform), the RAM budget (`RAM budget: 4.50 GiB/12.00 GiB used`), every
Expand Down Expand Up @@ -1642,7 +1644,9 @@ Manage the daemon explicitly. Other commands auto-start it on demand; `daemon`
exists for operators and debugging. `start` starts whichever mode
`config.mode` selects — a worker (the default) or a gateway — and
`status` reports it, both in the human line (`Daemon: running (gateway)`) and
as `daemon.mode` under `--json`. `stop` does not touch leases: they persist,
as `daemon.mode` under `--json`. With HTTP enabled, `start` and `status` also
print the web console's address on a `Console:` line (see
[CONSOLE.md](CONSOLE.md)). `stop` does not touch leases: they persist,
and the next daemon restores each one's TTL timer from its deadline. What a
stop does end is the connections to it — a running `simlock lease` cannot
reconnect, so it exits `1` with a `DAEMON_CONNECTION_LOST` line naming a lease
Expand Down
2 changes: 1 addition & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ edit yourself keeps the mode you give it until the next `config set`; run
| `gateway.disconnectedRetentionMs` | **Gateway side.** How long a disconnected worker is kept (greyed, never dispatched to) before the gateway forgets it. The clock is held while the gateway still knows of gateway-issued leases on that worker, and that hold ends when the last of those leases passes its deadline. | `24 hours` |
| `gateway.execTimeoutMs` | **Gateway side.** How long the gateway waits on a proxied `device.exec` before giving up. A backstop for a worker that never answers at all — deliberately longer than the worker's own `exec.timeoutMs`, which is authoritative because that side owns the process and can kill it, so an ordinary timeout surfaces as the worker's `EXEC_TIMEOUT` rather than racing this one. | `11 minutes` |
| `gateway.leaseRequestTimeoutMs` | **Gateway side.** How long the gateway waits on a forwarded `lease.request` before giving up on that worker for this request, answering `WORKER_UNREACHABLE`. Bounds the one uplink call that otherwise had no timeout of its own, so a wedged worker cannot park a request where neither a deadline nor `lease.cancel` could ever reach it again. Generous against a cold device provision-plus-boot; well below `gateway.execTimeoutMs`, since granting a lease should never take as long as a command run against the device afterward. | `5 minutes` |
| `http.enabled` | Master switch for the network-facing HTTP API (see [HTTP-API.md](HTTP-API.md)). Off by default; the daemon binds nothing until this is `true`. A gateway is the fleet's contact point, so it must be `true` there — see [Modes](#modes-gateway-and-worker). | `false` |
| `http.enabled` | Master switch for the network-facing HTTP API (see [HTTP-API.md](HTTP-API.md)) and the web console served beside it (see [CONSOLE.md](CONSOLE.md)). Off by default; the daemon binds nothing until this is `true`. A gateway is the fleet's contact point, so it must be `true` there — see [Modes](#modes-gateway-and-worker). | `false` |
| `http.host` | Address the HTTP listener binds. `127.0.0.1` keeps it loopback-only; reaching it remotely is the operator's own tunnel (Tailscale, cloudflared, reverse proxy) — Simlock does no TLS termination in v1. | `127.0.0.1` |
| `http.port` | Port the HTTP listener binds. Must be an integer `1`-`65535`. | `4700` |
| `exec.timeoutMs` | How long a single `device.exec` command (the remote half of `simlock simctl` / `simlock adb` — see [CLI.md](CLI.md#reaching-a-leased-device)) may run before Simlock kills it and fails the call with `EXEC_TIMEOUT`. Output is streamed, never buffered, so there is no size limit to go with it. | `10 minutes` |
Expand Down
100 changes: 100 additions & 0 deletions docs/CONSOLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Web console

Part of the user manual: the web console is a page in your browser that shows
what a Simlock host, or a gateway and its workers, is doing. The daemon serves
it itself. There is nothing to install and nothing is fetched from the
internet.

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 and the console's navigation: Workers, Leases,
Waiting, Attention and Events. Each page says "Coming soon" until its view is
built.

## Turn it on

The console comes with the HTTP API. It is on whenever `http.enabled` is
`true`, and there is no separate switch for it. A gateway always has HTTP on.

On a single host, turn HTTP on and restart the daemon:

```sh
simlock config set http.enabled true
simlock daemon stop && simlock daemon start
```

`http.host` and `http.port` decide where it listens, `127.0.0.1:4700` by
default (see [CONFIGURATION.md](CONFIGURATION.md)).

## Open it

`simlock daemon start` and `simlock status` print the address:

```
Daemon running
Console: http://127.0.0.1:4700/
```

Open that address in a browser. `simlock status --json` has it as
`daemon.consoleUrl`. When HTTP is off there is no `Console:` line and no
`consoleUrl`.

When `http.host` is `0.0.0.0` or `::`, the daemon listens on every interface
and the address says `localhost`. From another machine, use this host's name
or address instead. An IPv6 host is shown in brackets, as a browser expects:
`http://[::1]:4700/`.

The console uses the HTTP listener and nothing else. To reach it from another
machine, use the same tunnel you use for the HTTP API (Tailscale, cloudflared,
a reverse proxy). Simlock does not do TLS.

Every page has its own address, such as `/workers`, so you can bookmark a page
or reload it.

## Sign in

Paste an operator token and press **Sign in**. To make one, run this on the
host or the gateway:

```sh
simlock token create --role operator
```

The secret is printed once. A token works only on the daemon that minted it:
a gateway's token does not sign in to a worker, and the other way round.

If the console does not accept the token, it says why:

| Message | What it means |
| --- | --- |
| This daemon does not know that token. | The token is mistyped, revoked, or from another daemon. |
| That token is real, but the console needs an operator token. | It is an agent token or a worker join token. |
| The daemon is starting. Try again in a moment. | The daemon answers, but has not finished starting. |
| The daemon cannot be reached. | Nothing answers at this address. |
| The daemon answered with an error (HTTP *n*). | Anything else; the daemon's log says more. |

## Staying signed in

The console keeps the token in this browser tab only.

- **Reload** the page and you stay signed in.
- **Open a new tab** and it asks for a token again.
- **Close the tab** and you are signed out.
- **Sign out** forgets the token at once.
- If the token is **revoked**, the console signs you out the next time it asks
the daemon for anything, and at the latest when you reload.

Some browsers copy a tab's storage into a duplicated or reopened tab, so such a
tab may still be signed in.

## What the page loads

Everything the console needs comes from the daemon: the page, its script, its
styles and its fonts. The page tells the browser not to send anything to any
other host, so it works without internet access and your token stays with the
daemon.

The console's own files need no token, because they hold no data. Anyone who
reaches the HTTP listener can load the sign-in page and nothing more. Every
piece of data comes from the HTTP API, with your token.
21 changes: 16 additions & 5 deletions docs/HTTP-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ uses instead of the CLI/MCP frontends' unix socket. It is off by default
enabled, binds `127.0.0.1` unless configured otherwise. Reaching it from
another machine is the operator's own tunnel (Tailscale, cloudflared, a
reverse proxy) — Simlock does no TLS termination in v1, and `Authorization`
is required on every route regardless of how it's reached, loopback included.
is required on every API route regardless of how it's reached, loopback
included (see [Authentication](#authentication) for the two exceptions).

This frontend calls the exact same in-process `Dispatcher` the unix socket
calls — not a second copy of role/ownership logic, and not a
Expand Down Expand Up @@ -43,8 +44,11 @@ terminal state. No route blocks on device work in flight.

## Authentication

Every route requires `Authorization: Bearer slk_<secret>` except `GET
/v1/healthz`. Missing or unrecognized tokens are `401 UNAUTHENTICATED`.
Every route requires `Authorization: Bearer slk_<secret>` except two: `GET
/v1/healthz`, and the web console's own files, which the daemon serves at
every path outside `/v1` (see [CONSOLE.md](CONSOLE.md)). They hold no data;
the console reads everything it shows from the routes below, with the
operator's token. Missing or unrecognized tokens are `401 UNAUTHENTICATED`.

Tokens are minted and managed with `simlock token` (see [CLI.md](CLI.md)).
Since 0.3.0 `token.create|list|revoke` are daemon operations (admin role) and
Expand Down Expand Up @@ -139,9 +143,16 @@ The daemon block carries `health` (`starting`/`running`) and **`mode`**
daemon answered:

```json
{ "daemon": { "health": "running", "mode": "worker" } }
{ "daemon": { "health": "running", "mode": "worker", "consoleUrl": "http://127.0.0.1:4700/" } }
```

**`consoleUrl`** is the web console's address (see [CONSOLE.md](CONSOLE.md)):
`http://<http.host>:<http.port>/`, with `localhost` for a host of `0.0.0.0` or
`::` and an IPv6 host in brackets. It is present whenever HTTP is on, so an
HTTP answer carries it; over the unix socket it is absent while HTTP is off.
It is also left out if the address would be longer than 512 characters, which
no real host name is. An older daemon sends none.

Beside it, **`host`** says what machine the daemon runs on: the operating
system, its version, the CPU architecture, and the version of each platform
tool its drivers use:
Expand Down Expand Up @@ -203,7 +214,7 @@ on, and an additive **`workers`** array carries one
[worker view](#worker-routes) per worker:

```json
{ "daemon": { "health": "running", "mode": "gateway" },
{ "daemon": { "health": "running", "mode": "gateway", "consoleUrl": "http://127.0.0.1:4700/" },
"host": { "os": "Linux", "osVersion": "6.8.0", "arch": "x64", "tools": [] },
"workers": [ { "id": "3f81a2c4", "label": "mac-studio-2", "connection": "connected", "drained": false } ] }
```
Expand Down
12 changes: 11 additions & 1 deletion docs/internal/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ modes](#gateway-and-worker-modes-adr-0005) below for that topology.
kind, not just transport: it is the one frontend meant to be reached over a
real network, so it calls the daemon's dispatcher **in-process** — the exact
same one the socket path calls — rather than going through the unix socket at
all, and requires a bearer token on every route but `GET /v1/healthz`. It
all, and requires a bearer token on every `/v1` route but `GET /v1/healthz`. It
grants exactly the same TTL-renewed lease every other frontend does (ADR
0004) — being reachable over a real network is no longer a reason for a
different lease model, because there is only one. Its listener now starts
Expand All @@ -55,6 +55,16 @@ modes](#gateway-and-worker-modes-adr-0005) below for that topology.
before convergence completes now waits on the shared dispatcher's readiness
gate exactly like a socket request, instead of being refused. See
[HTTP-API.md](../HTTP-API.md) for the full route reference.
- **Web console** (ADR 0011): a React app in `ui/`, built by Vite into
`dist/ui` and served by the same HTTP listener at every path outside `/v1`.
`src/http/server.ts` puts it in front of `app.fetch`, so `app.ts` stays a
pure request-to-response function and the console never touches the API's
auth or request log. The console is a client of the HTTP API like any other:
it reads only `/v1`, with the operator's token, through one fetch helper
(`ui/src/api.ts`). Its views are listed once, in `ui/src/views/index.tsx`,
which is both the navigation and the router's table. See
[CONSOLE.md](../CONSOLE.md) for the user's side and
[DESIGN.md](DESIGN.md) for the style.
- **CLI**: by default it acquires a lease, prints one JSON result line on
stdout, then stays alive — renewing the lease at one third of the lease's TTL
and releasing it on exit, parent death, or `SIGINT`/`SIGTERM`. That is the
Expand Down
Loading
Loading