Files
de-praxis/docs/server-control.md
T
juli d4e237a593 Add advanced LLM generation controls and redesign the admin login
- Backend protocols: OpenAI-compatible, llama.cpp extensions and native
  Ollama (/api/chat, /api/tags model discovery)
- Thinking modes per protocol; thinking output is stripped and unfinished
  reasoning falls back to scripted narration
- Context length, story history entry/character budgets, top-p, top-k,
  repeat penalty and seed; output tokens up to 8192
- Admin panel stays hidden until the key is verified; cassette login art and
  System / Dark CRT / Light Archive themes
- Generation tests, updated control-room guide and screenshots
2026-10-25 02:15:04 +02:00

8.2 KiB
Raw Permalink Blame History

Server control room

The server includes a themed web control panel. It ships in the server distribution and needs no separate frontend build, hosting service, or JavaScript runtime.

Dark control panel, light login, and generation controls, captured during isolated browser QA against a disposable mock inference backend.

Open the panel

Start the server with JDK 17:

./gradlew -PserverOnly :server:installDist
./server/build/install/server/bin/server

Open http://127.0.0.1:1337/admin. On first start, the server creates a private admin.key inside DATA_DIR (default ./data). Its startup message shows the file's location, without printing the key. Copy the key from that file into the panel's login field.

For deployments that supply their own secret, set ADMIN_TOKEN to at least 24 printable characters. This replaces file-based authentication for that process. The admin key is separate from player tokens and backend API keys.

Navigation and settings remain hidden until the server verifies the admin key. The panel uses the bundled cassette artwork and offers System, Dark CRT, and Light Archive themes; the theme choice persists across visits.

The browser remembers operator clearance for the current tab session. Lock console clears it and clears the form. The panel does not download or display the saved backend API key. Use HTTPS or an SSH tunnel when administering across an untrusted network.

Admin routes default to local connections only. For testing from another device on a trusted LAN, run:

./server/bin/server --lan --lan-admin
# Equivalent: LAN_MODE=true LAN_ADMIN_ACCESS=true ./server/bin/server

Use the printed http://<relay-IP>:1337/admin URL, or substitute your configured port. The IP must be this relay's numeric destination address; DNS hostnames are deliberately not accepted. Retrieve the admin key from DATA_DIR/admin.key on the server (default data/admin.key), or use your configured ADMIN_TOKEN. All settings and backend operations still require this key. LAN mode uses plaintext HTTP, so use it only on a trusted local network. --lan-admin requires --lan; it cannot be combined with PUBLIC_ORIGIN, trusted proxy settings or HTTPS ADMIN_REMOTE_ACCESS. Do not set ADMIN_REMOTE_ACCESS=true for LAN testing.

For internet hosting, use the private SSH access and HTTPS proxy layout; the public proxy deliberately does not expose this panel. Backend tests/model discovery are rate-limited, so wait after repeated diagnostics return 429.

Configure inference

  1. Choose a connection profile (llama.cpp, LM Studio, native Ollama, or custom) and its backend API protocol.
  2. Enter the complete generation endpoint, reachable from the server, such as http://127.0.0.1:8081/v1/chat/completions or native Ollama http://127.0.0.1:11434/api/chat.
  3. Use Find models to query the corresponding /models route (native Ollama uses /api/tags), or enter a model ID manually. Some compatible backends do not implement model discovery; manual entry still works.
  4. Enter an API key if required. A blank field preserves the existing key. Clear saved key removes it when the configuration is saved.
  5. Use Test backend to generate a small sample from the current form, without saving it. This intentionally contacts the selected backend, even when LLM narration is currently disabled.
  6. Enable LLM narration and save the configuration.

Generation controls include:

Setting Behavior
Context length Native Ollama sends options.num_ctx (1,024–262,144 tokens). Other protocols manage capacity on the inference server; llama.cpp uses startup --ctx-size.
Thinking Default leaves the backend unchanged. Native Ollama accepts on/off or model-supported levels. llama.cpp uses chat-template controls for on/off and reasoning_effort for levels. Compatible APIs receive reasoning_effort for an explicit selection. Unsupported model options can make a probe fail.
Output tokens 32–8,192 tokens. Reasoning models may share this budget with thinking; increase it and the timeout when needed. The existing 30-second maximum request deadline still applies.
Story history Send the latest 0–200 entries within a 500–64,000-character budget. Zero entries sends current campaign state without previous log entries. These limits do not change model context capacity.
Sampling Temperature, top-p and optional nonnegative seed. Native Ollama and llama.cpp also expose top-k and repeat penalty.

Separate backend thinking fields are ignored, and completed inline <think> blocks are removed before narration reaches players. Empty or unfinished reasoning output falls back to the scripted narration. A seed does not guarantee identical output across backends or hardware.

These controls follow the Ollama chat API, Ollama request options, and llama.cpp server API. Model and template support varies; test a draft before saving it.

Generation settings and style direction apply to the next narration call. In-flight calls finish with the settings they captured when they started. The fixed narration contract keeps rolls, objectives, and game outcomes authoritative; style direction adds atmosphere within that contract.

Settings are written atomically to DATA_DIR/server-settings.json, including any backend key, with owner-only file permissions on supported filesystems. This file is private, not encrypted. Preserve the data directory across server upgrades. LLM_URL, LLM_MODEL, and LLM_API_KEY seed settings only when no saved settings file exists; saved configuration takes precedence on later starts.

Relay status and crew intake

The overview shows active crews, recorded transmissions, server uptime, and successful/fallback narration counts. Counters reset on server restart; rooms and configuration persist. Probe requests do not count as game narration.

The crew manifest includes room code, phase, crew count, round, and remaining pressure. It excludes player credentials and pending action text. Accept new transmissions controls new room creation; turning it off lets existing rooms continue, including joining a lobby that already exists.

Changes apply without restarting. Revision checks reject saves from a stale browser tab; use Discard changes to reload the current saved configuration before editing again.

Admin API

All /admin/api/* endpoints require Authorization: Bearer <admin key>. Writes require Content-Type: application/json. The browser uses only same-origin requests; no CORS access is enabled.

Method Endpoint Purpose
GET /admin/api/settings Redacted saved settings and revision
POST /admin/api/settings Validate and save settings
GET /admin/api/status Uptime, narrator counters, room summaries
POST /admin/api/probe Test draft settings with one generation
POST /admin/api/models Discover model IDs using draft settings

The panel serves its CSS, JavaScript, and branding locally under /admin/. A restrictive content security policy disallows external scripts, external assets, and framing. Backend requests happen on the Kotlin server, so backend credentials stay out of browser requests to inference services.

Verification

./gradlew -PserverOnly :server:test :server:distZip
node --check server/src/main/resources/admin/app.js
python3 scripts/smoke.py http://127.0.0.1:1337

Automated tests cover admin authentication, credential redaction and retention/removal, settings persistence, stale-write rejection, URL and generation-limit validation, runtime narration updates, model discovery, and pausing only new rooms. Existing campaign and narration tests remain in place. Generation tests cover protocol-specific payloads, history limits, thinking-output filtering, and legacy configuration defaults. Browser QA uses an isolated data directory and a disposable mock backend; it does not certify a particular inference model.