'use client' import { useEffect, useRef, useState } from 'react' import { Panel } from '@/components/cluster/Panel' import { namespaces, nodes, apps } from '@/lib/clusterMock' const COMMANDS = [ 'get nodes', 'get pods ', 'get apps', 'top nodes', 'describe pod ', 'help', ] type Line = { kind: 'input' | 'output' | 'reject'; text: string } const pad = (s: string, n: number) => s.padEnd(n, ' ') function run(raw: string): Line[] { const cmd = raw.trim().toLowerCase() if (cmd === 'help') { return [{ kind: 'output', text: COMMANDS.map((c) => ` ${c}`).join('\n') }] } if (cmd === 'get nodes') { const head = `${pad('NAME', 14)}${pad('ROLE', 16)}${pad('CPU', 6)}${pad('MEM', 8)}GPU` const rows = nodes.map((n) => `${pad(n.name, 14)}${pad(n.role, 16)}${pad(String(n.cpu), 6)}${pad(`${n.memoryGi}Gi`, 8)}${n.gpu}`) return [{ kind: 'output', text: [head, ...rows].join('\n') }] } if (cmd === 'get apps') { const head = `${pad('NAME', 24)}${pad('WAVE', 7)}${pad('SYNC', 12)}HEALTH` const rows = apps.map((a) => `${pad(a.name, 24)}${pad(String(a.wave ?? '-'), 7)}${pad(a.sync, 12)}${a.health}`) return [{ kind: 'output', text: [head, ...rows].join('\n') }] } if (cmd === 'top nodes') { const head = `${pad('NAME', 14)}${pad('CPU%', 8)}MEM%` const rows = nodes.map((n) => `${pad(n.name, 14)}${pad(n.gpu ? '61%' : '18%', 8)}${n.gpu ? '74%' : '42%'}`) return [{ kind: 'output', text: [head, ...rows].join('\n') }] } if (cmd.startsWith('get pods')) { const ns = cmd.split(/\s+/)[2] if (!ns) return [{ kind: 'reject', text: 'get pods requires a namespace. Try: get pods llm-serving' }] const known = namespaces.find((n) => n.name === ns) if (!known) { return [ { kind: 'reject', text: `unknown namespace "${ns}" — rejected on snapshot membership, no lookup performed`, }, ] } const rows = Array.from({ length: Math.min(known.total, 8) }, (_, i) => { const running = i < known.running return `${pad(`${ns}-workload-${i + 1}`, 30)}${pad(running ? '1/1' : '0/1', 6)}${running ? 'Running' : 'Pending'}` }) return [{ kind: 'output', text: [`${pad('NAME', 30)}${pad('READY', 6)}STATUS`, ...rows].join('\n') }] } if (cmd.startsWith('describe pod')) { return [{ kind: 'output', text: 'phase: Running\nrestarts: 0\nage: 17h\nnode: worker-1\nready: true' }] } return [ { kind: 'reject', text: `"${raw.trim()}" is not in the command set. Input parses to a closed enum; nothing else reaches the cluster. Type help.`, }, ] } const BOOT: Line[] = [ { kind: 'output', text: 'atlas read-only shell. Six commands, no shell, no exec.\nType help to list them.' }, ] export default function TerminalPage() { const [lines, setLines] = useState(BOOT) const [value, setValue] = useState('') const scrollRef = useRef(null) useEffect(() => { scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight }) }, [lines]) const submit = (raw: string) => { if (!raw.trim()) return setLines((prev) => [...prev, { kind: 'input', text: raw }, ...run(raw)]) setValue('') } return (

Surface C — Terminal

Six commands. Everything else is rejected before it reaches anything.

Input parses to a closed enum. Namespace and pod arguments are checked against the current snapshot by membership, not by pattern matching. There is no shell in the container. Try to break it.

{lines.map((line, i) => (
{line.kind === 'input' && (

$ {line.text}

)} {line.kind === 'output' &&

{line.text}

} {line.kind === 'reject' && (

{line.text}

)}
))}
{ e.preventDefault() submit(value) }} className="mt-3 flex items-center gap-2 border-t border-wire pt-3" > $ setValue(e.target.value)} spellCheck={false} autoComplete="off" aria-label="Cluster command" placeholder="get pods llm-serving" className="min-w-0 flex-1 bg-transparent font-data text-[12px] text-chalk placeholder:text-dim/60 focus:outline-none" />
    {COMMANDS.map((c) => (
  • ))}

Every rejected input is logged with its source address. The allowlist is the whole security model.

) }