Merge control portal work from RPGTheory/aeternalis-portal

RPGTheory/aeternalis-portal had diverged from this repo (the git/CI/CD
copy) with an in-progress control portal feature that was never synced
back here, so none of it had gone through CI or been deployed:

- New site/game/control routing split: index.html becomes a world
  directory landing page (site.ts), game.html is the renamed former
  index.html (main.ts), control.html is a new admin panel
  (control.ts, portal-shared.ts, portal.css).
- Server: new internal/store/portal.go (character/world registry,
  command queue, admin grants) and internal/transport/control.go
  (portal API routes), plus a new internal/gitops package that lets
  the portal provision new worlds via a GitOps repo commit.
- game.World gains BornAt/DiedAt/DeathReason and an operator Control()
  path (close/open admissions, awaken boss, end world, per-character
  rename/heal/unstuck/retire); death no longer reuses the same
  character id on rejoin, matching the "new life" permadeath model in
  Plan.md rather than the old bypass-prevention test's expectations.
- deploy/: new control-egress network policy and portal/control
  values (admin role, GitOps repo/branch/values file/CIDRs).
- New e2e coverage: tests/portal.spec.ts, tools/capture-world.mjs.

Verified this repo's own independent commits (800ms movement-staleness
window, 20s boss-attack poll, SRS/TLS deploy values, ubuntu-22.04
runner pin, DOCKER_HOST fix) were already present in the portal copy
before merging, so nothing here regresses them. `tsc --noEmit`, the
vite client build, and the protocol contract check all pass; no go.mod
changes. Could not run `go build`/`go test` locally (no Go toolchain
on PATH, Docker daemon not running) — every new/changed Go symbol was
manually cross-referenced and resolves, but this should still be built
and tested in CI before merging to master.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-06 11:08:44 -04:00
co-authored by Claude Sonnet 5
parent b515c65aba
commit 5df2f1b681
32 changed files with 1871 additions and 100 deletions
+12 -3
View File
@@ -21,9 +21,11 @@ let pendingAction: { op: string; target: string } | undefined;
let requestedClose = false;
const keys = new Set<string>();
let view: WorldView;
const selectedWorld = new URLSearchParams(location.search).get('world');
const worldPrefix = selectedWorld && /^[a-z][a-z0-9-]{0,30}$/.test(selectedWorld) ? `/worlds/${selectedWorld}` : '';
async function api<T>(path: string, body?: unknown): Promise<T> {
const response = await fetch(path, { method: body === undefined ? 'GET' : 'POST', credentials: 'same-origin', headers: body === undefined ? {} : { 'Content-Type': 'application/json' }, body: body === undefined ? undefined : JSON.stringify(body) });
const response = await fetch(path.startsWith('/api/') ? worldPrefix + path : path, { method: body === undefined ? 'GET' : 'POST', credentials: 'same-origin', headers: body === undefined ? {} : { 'Content-Type': 'application/json' }, body: body === undefined ? undefined : JSON.stringify(body) });
const result = await response.json();
if (!response.ok) throw new Error(result.error ?? `Request failed (${response.status})`);
return result as T;
@@ -54,7 +56,7 @@ function action(op: string) {
function connect() {
requestedClose = false; sequence = 0;
const ending = $<HTMLDialogElement>('ending'); ending.close();
ws = new WebSocket(`${location.protocol === 'https:' ? 'wss:' : 'ws:'}//${location.host}/ws`);
ws = new WebSocket(`${location.protocol === 'https:' ? 'wss:' : 'ws:'}//${location.host}${worldPrefix}/ws`);
ws.onopen = () => { $('connection-status').textContent = 'Connected'; $('connection-dot').parentElement!.classList.remove('offline'); };
ws.onmessage = event => {
const value = JSON.parse(event.data) as Snapshot;
@@ -84,6 +86,7 @@ function showEnding(title: string, detail: string, survivor: boolean) {
}
if (survivor && destinations.children.length === 0) { const p = document.createElement('p'); p.textContent = 'Your passage is saved. No destination world is open yet.'; destinations.append(p); }
visible('reconnect', false);
visible('new-character', snapshot?.self.entity.state === 'dead' && ['gathering','cataclysm'].includes(snapshot.world.phase));
$<HTMLDialogElement>('ending').show();
}
function inventory(c: Character) {
@@ -141,6 +144,7 @@ function updateHUD(s: Snapshot) {
if (s.message && s.message !== lastNotice) { notice(s.message); lastNotice = s.message; }
}
async function boot() {
$<HTMLAnchorElement>('login').href = `/auth/login?return=${encodeURIComponent(location.pathname + location.search)}`;
createIcons({ icons: { Crosshair, Settings2, X, Flame, LogOut, Hourglass, Swords, Pickaxe, HeartPulse, Gem, Backpack, ChevronUp, ChevronDown, ChevronLeft, ChevronRight, ArrowRight, RefreshCw } });
view = new WorldView($<HTMLCanvasElement>('world'));
view.start(dt => {
@@ -165,7 +169,7 @@ async function boot() {
view.addChunks(chunks); view.updateEntities(chunks.flatMap(c => c.resources));
$('connection-status').textContent = 'World online';
visible('dev-boss', config.development);
let me: { character: Character | null } | undefined;
let me: { character: Character | null; active?: { worldId: string; state: string; name: string } } | undefined;
try { me = await api('/api/me'); } catch { if (config.development) { await api('/auth/dev', {}); me = await api('/api/me'); } }
if (!me && !config.development) { visible('join-form', false); visible('login', true); }
else if (me?.character) {
@@ -174,6 +178,10 @@ async function boot() {
else if (me.character.entity.state === 'eligible') showEnding('A passage forward.', 'Your survivor passage is saved.', true);
else connect();
} else {
if (me?.active) {
visible('join-form', false);
const link = document.createElement('a'); link.href = `/game?world=${encodeURIComponent(me.active.worldId)}`; link.className = 'command'; link.textContent = `Continue ${me.active.name} in ${me.active.worldId}`; $('passages').append(link);
}
const passages = await api<{ characterId: string; sourceWorld: string; name: string }[]>('/api/passages').catch(() => []);
for (const passage of passages.filter(p => p.sourceWorld !== config.worldId)) {
const button = document.createElement('button'); button.textContent = `Continue as ${passage.name}`;
@@ -193,6 +201,7 @@ async function boot() {
$('target-boss').onclick = () => { selection(snapshot?.entities.find(e => e.id === 'boss')); walkTo = { x: 0, z: 0 }; pendingAction = { op: 'attack', target: 'boss' }; };
$('dev-boss').onclick = () => void api('/api/dev/boss', {}).catch(e => notice(e.message));
$('reconnect').onclick = () => location.reload();
$('new-character').onclick = () => { requestedClose = true; ws?.close(); location.reload(); };
$('logout').onclick = async () => { requestedClose = true; await api('/auth/logout', {}); ws?.close(); location.reload(); };
$<HTMLSelectElement>('quality').onchange = event => view.quality((event.target as HTMLSelectElement).value === 'high');
$<HTMLInputElement>('zoom').oninput = event => { view.distance = Number((event.target as HTMLInputElement).value); view.resize(); };