Files
rhema-together/web/app/middleware/auth.global.ts
T
vhaudiquet 0035f4e031 feat: add the multiplayer room server and client
A room is one conversation, one ssh sandbox, and one agent. Accounts
create rooms; friends join through a single-use invite link and a
display name; the agent speaks only through the message tool.

The server is Axum and SQLite. It serves the built Nuxt client, streams
room events over SSE, and runs one serialized turn loop per room with
turn-level steering copied from rhema-code. The client has the chat,
preview iframe, read-only file pane, xterm terminal, and presence.

Preview URLs are signed wildcard hosts, and the proxy tunnels HTTP over
ssh direct-tcpip. HostAgent::step remains deferred in the framework.
2026-11-28 01:09:37 +01:00

29 lines
768 B
TypeScript

const PUBLIC_PATHS = ['/setup', '/login', '/register', '/join']
function isPublic(path: string) {
return PUBLIC_PATHS.some((prefix) => path === prefix || path.startsWith(`${prefix}/`))
}
export default defineNuxtRouteMiddleware(async (to) => {
const { load, session } = useSession()
try {
await load()
} catch {
return
}
const state = session.value
if (state.needsSetup) {
return to.path === '/setup' ? undefined : navigateTo('/setup')
}
if (to.path === '/setup') {
return navigateTo(state.user ? '/rooms' : '/login')
}
if (!state.user && !isPublic(to.path)) {
return navigateTo('/login')
}
if (state.user && (to.path === '/login' || to.path === '/register')) {
return navigateTo('/rooms')
}
return undefined
})