# Vorks GSM — Headless Agent (CLI)

Run game servers on any Windows or Linux machine and control them from the
Vorks GSM web dashboard — no desktop app needed.

## How it works

The agent connects **outbound** to the hub over a secure WebSocket, so it works
behind NAT/firewalls with no port forwarding. You link it once with a one-time
code from the dashboard; after that you install games and start/stop servers
entirely from the web.

## 1. Get the binary

- **Windows:** `vorks-gsm-agent.exe`
- **Linux:**   `vorks-gsm-agent` (chmod +x)

(Built by `build.ps1`, or `go build` in the `agent/` folder for Linux:
`GOOS=linux GOARCH=amd64 go build -o vorks-gsm-agent .`)

## 2. Get an enroll code

In the dashboard: **My Devices → Add a device**. Copy the one-time code.

## 3. Enroll

```
# Windows
vorks-gsm-agent.exe enroll --code ABC123

# Linux
./vorks-gsm-agent enroll --code ABC123
```

Or run `enroll` with no `--code` to be prompted interactively.

Optional flags: `--hub https://gsm.vorks.net`, `--name "My Box"`,
`--license <key>`, `--data <dir>`.

## 4. Run it

**Foreground (test):**
```
vorks-gsm-agent run
```

**As a service (recommended, starts on boot):**
```
# Windows — run an Administrator prompt
vorks-gsm-agent.exe install-service

# Linux — as root
sudo ./vorks-gsm-agent install-service
```

The machine now appears in your dashboard. Pick a game, install it, and
start/stop the server remotely.

## Service management

- **Windows:** `sc.exe start VorksGSMAgent` / `sc.exe stop VorksGSMAgent`,
  remove with `vorks-gsm-agent.exe uninstall-service`.
- **Linux:** `systemctl status vorks-gsm-agent`, logs via
  `journalctl -u vorks-gsm-agent -f`, remove with
  `sudo ./vorks-gsm-agent uninstall-service`.

## Other commands

- `vorks-gsm-agent status` — show enrollment state.
- `vorks-gsm-agent help` — usage.

## Notes

- The one-time enroll code is consumed on first successful connect; the agent
  then uses a stored device key to reconnect.
- **Auto-update:** the standalone agent checks `update.vorks.net` (product
  `vorks-gsm-cli`) shortly after start and every 6 hours, downloads a newer
  build, swaps itself, and restarts. This is separate from the WPF desktop app's
  updater — the desktop app and its bundled agent update on their own channel
  (`vorks-gsm`) and are unaffected.
- Build/release the CLI agent with `build-cli.ps1` (own product + own
  `.upload-key-cli`). The WPF app is built/released by `build.ps1` as before.
- Free tier limits the number of servers/devices; Pro unlocks more.
- Forge/Fabric Minecraft installs require Java on the host.
