The admin panel
sg panel runs a small web UI and a JSON API on your machine. It calls the same code as the CLI, so anything you do there is planned, confirmed and recorded the same way.
Start it
Run it from your project directory. It opens ./.sg/state.db relative to where you launch it.
cd ~/estates/lab
sg panel # http://127.0.0.1:7070, in the foreground
sg panel --listen 127.0.0.1:8080
sg panel --listen tailnet:7070 # this host's own verified tailnet address
Ctrl-C shuts it down gracefully. Active runs are finished and recorded before the ledger closes.
Where it may listen
Only loopback (IPv4 or IPv6) and the host's own verified tailnet address are accepted. tailnet:<port> must resolve to exactly one observed tailnet address, so it needs the tailscale CLI and refuses if it finds none or several. Wildcard (0.0.0.0), public, LAN, link-local, multicast and hostname binds are all refused before a socket opens.
How it behaves
- Reads never open SSH. Pages show the last observed snapshot with an observed-at or stale marker. Only Refresh (
POST /api/v1/probe) and plan or apply actions contact hosts. - No background polling. The UI refreshes when you act, and opens one live event stream per active run, with a Stop button straight away.
- One run at a time. A second apply gets
409 sg:run-active.
Plan-bound approval
Every apply needs the hash of the plan you approved:
{"confirm": {"plan_hash": "<hash from the plan route>"}}
The server prepares a fresh plan. If its hash doesn't match what you approved, the request refuses with 409 sg:plan-stale and changes nothing. Destroy routes also need "confirm_word" set exactly to the cluster or application name.
The API
Success responses are {"data": …}. Errors look like this, and always name the matching CLI command:
{"error": {"code": "sg:plan-stale", "message": "…", "hint": "…",
"cli_equivalent": "sg application deploy", "run_id": "…"}}
Request bodies are strict JSON: unknown fields return 400 sg:invalid-request before anything runs.
| Method | Path | Does | CLI equivalent |
|---|---|---|---|
| GET | /api/v1/overview | Estate overview (last snapshot) | |
| POST | /api/v1/probe | Refresh: observe hosts now | |
| GET | /api/v1/clusters | List clusters | |
| POST | /api/v1/clusters | Write a new cluster.yaml (never overwrites) | (panel only) |
| GET | /api/v1/clusters/{name}/eligible-members | Machines that can join | |
| POST | /api/v1/clusters/{name}/plan | Plan formation or teardown, returns plan_hash | |
| POST | /api/v1/clusters/{name}/create | Form the cluster (plan-bound) | sg cluster create |
| POST | /api/v1/clusters/{name}/destroy | Tear down (plan-bound + confirm_word); with_machines is refused here | sg cluster destroy |
| GET | /api/v1/applications | List applications | |
| POST | /api/v1/applications | Register {"spec_path": "<file in project dir>"} | sg application init |
| GET | /api/v1/applications/{name} | Groups, instances, volume safety, observation | sg application status |
| POST | /api/v1/applications/{name}/plan | Read-only plan + plan_hash | sg application plan |
| POST | /api/v1/applications/{name}/deploy | Deploy (plan-bound) | sg application deploy |
| POST | /api/v1/applications/{name}/destroy | Destroy (plan-bound + confirm_word) | sg application destroy |
| GET | /api/v1/applications/{name}/generations | Generation history, newest first | |
| POST | /api/v1/applications/{name}/rollback | {} previews, {"confirm": …} executes | sg application rollback |
| POST | /api/v1/applications/{name}/restart | Preview or execute {"selector": …} | sg application restart |
| POST | /api/v1/applications/{name}/scale | {"group", "count", "placements"} preview or execute | sg application scale |
| POST | /api/v1/applications/{name}/upgrade | {"group", "image"} preview or execute | sg application upgrade --image |
| GET | /api/v1/runs | Run history | |
| GET | /api/v1/runs/{id}/events | Live run events (Server-Sent Events) | |
| POST | /api/v1/runs/{id}/stop | Cancel an active run | Ctrl-C |
A few panel-specific limits: it registers specs only by a file name directly in the project directory; its upgrade takes an image only; and cluster destroy with machines is CLI-only.
Try it
curl -s http://127.0.0.1:7070/api/v1/overview | jq .
curl -s -X POST http://127.0.0.1:7070/api/v1/applications/hello/plan \
-H 'content-type: application/json' -d '{}' | jq . # the response carries the plan_hash to approve