Initial commit — SvelteKit fleet manager for T5 Plutonium servers

Ports push_scripts.sh (1497 lines of bash) to a SvelteKit + SQLite web app
that manages a fleet of T5 Plutonium servers running on Komodo. Same push
and beta workflow as the shell script, with a live SSE pipeline view, a
!rt-token-gated auth modal that hard-pauses deployments on stale tokens,
per-file audit diffs, and a Komodo-container deployment target.

- Push/beta engines port the exact filter, held-by-beta, conflict, and
  stale-backup rules from the shell script
- SQLite (better-sqlite3) replaces script_metadata.json; a one-shot
  importer moves legacy state over on first boot
- 16 vitest tests cover push add/update/skip, beta open→rollback,
  open→promote, conflict guards, sweep frozen/manual branches, and IW4M
  login/status parsing
- docker/ + komodo/stack.toml deploy as a managed container on the same
  host as the game servers, /root/zombies bind-mounted at the same path
  the shell script used
This commit is contained in:
2026-09-12 00:23:51 -04:00
commit d99711563e
67 changed files with 9415 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
import { writable, derived } from 'svelte/store';
import { browser } from '$app/environment';
export type AuthState =
| { kind: 'ready'; token: string; expiresAt: number }
| { kind: 'stale'; reason: 'expired' | 'rejected' | 'unreachable' }
| { kind: 'missing' };
interface AuthPayload {
type: 'auth-state';
state: AuthState;
msRemaining?: number;
}
export const authState = writable<AuthState>({ kind: 'missing' });
export const msRemaining = writable<number>(0);
export const isReady = derived(authState, ($s) => $s.kind === 'ready');
export const shouldBlock = derived(authState, ($s) => $s.kind !== 'ready');
let source: EventSource | null = null;
export function startAuthStream(): void {
if (!browser || source) return;
source = new EventSource('/api/events/auth');
source.addEventListener('auth-state', (evt) => {
try {
const payload = JSON.parse((evt as MessageEvent).data) as AuthPayload;
authState.set(payload.state);
if (payload.msRemaining !== undefined) msRemaining.set(payload.msRemaining);
} catch {
/* ignore malformed */
}
});
source.addEventListener('error', () => {
// Browser will auto-reconnect. If the stream stays down long enough,
// the token will expire on the server anyway and the next reconnect
// will surface the transition.
});
}
export async function submitToken(token: string): Promise<{ ok: true } | { ok: false; error: string }> {
const res = await fetch('/api/auth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token })
});
const body = (await res.json()) as { ok: boolean; error?: string };
if (!res.ok || !body.ok) return { ok: false, error: body.error ?? `HTTP ${res.status}` };
return { ok: true };
}
+60
View File
@@ -0,0 +1,60 @@
import { writable } from 'svelte/store';
import { browser } from '$app/environment';
export type ServerState = 'pending' | 'done' | 'failed' | 'held' | 'manual';
export interface PipelineDeployment {
id: string;
action: string;
servers: Map<string, { state: ServerState; players: number | null; error: string | null }>;
openedAt: number;
}
export const deployments = writable<Map<string, PipelineDeployment>>(new Map());
export const frozen = writable<boolean>(false);
export const frozenReason = writable<string | null>(null);
let source: EventSource | null = null;
function updateDeployment(id: string, mutate: (d: PipelineDeployment) => void): void {
deployments.update((m) => {
const existing = m.get(id) ?? { id, action: '', servers: new Map(), openedAt: Date.now() };
mutate(existing);
m.set(id, existing);
return new Map(m);
});
}
export function startPipelineStream(): void {
if (!browser || source) return;
source = new EventSource('/api/events/pipeline');
source.addEventListener('deployment-opened', (evt) => {
const data = JSON.parse((evt as MessageEvent).data) as { deploymentId: string; action: string; servers: string[] };
updateDeployment(data.deploymentId, (d) => {
d.action = data.action;
for (const s of data.servers) {
if (!d.servers.has(s)) d.servers.set(s, { state: 'pending', players: null, error: null });
}
});
});
source.addEventListener('server-state', (evt) => {
const data = JSON.parse((evt as MessageEvent).data) as {
deploymentId: string;
server: string;
state: ServerState;
players: number | null;
error: string | null;
};
updateDeployment(data.deploymentId, (d) => {
d.servers.set(data.server, { state: data.state, players: data.players, error: data.error });
});
});
source.addEventListener('sweep-tick', (evt) => {
const data = JSON.parse((evt as MessageEvent).data) as { frozen: boolean; reason?: string };
frozen.set(data.frozen);
frozenReason.set(data.reason ?? null);
});
}
+25
View File
@@ -0,0 +1,25 @@
import { writable } from 'svelte/store';
import { browser } from '$app/environment';
export interface ServerStatus {
server: string;
players: number | null;
name?: string;
}
export const statusByServer = writable<Map<string, ServerStatus>>(new Map());
let source: EventSource | null = null;
export function startServerStream(): void {
if (!browser || source) return;
source = new EventSource('/api/events/servers');
source.addEventListener('server-status', (evt) => {
const data = JSON.parse((evt as MessageEvent).data) as { entries: ServerStatus[] };
statusByServer.update(() => {
const m = new Map<string, ServerStatus>();
for (const e of data.entries) m.set(e.server, e);
return m;
});
});
}