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.
This commit is contained in:
vhaudiquet committed 2026-11-28 01:09:37 +01:00
1 parent 04dd63c4ca
commit 0035f4e031
69 files changed
+22501 -48

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
import type { BootstrapResponse, User } from '~/types'
interface SessionState {
loaded: boolean
needsSetup: boolean
user: User | null
allowRegistration: boolean
publicUrl: string
previewOrigin: string
}
let inflight: Promise<SessionState> | null = null
export function useSession() {
const state = useState<SessionState>('session', () => ({
loaded: false,
needsSetup: false,
user: null,
allowRegistration: false,
publicUrl: '',
previewOrigin: '',
}))
const api = useApi()
function apply(boot: BootstrapResponse) {
state.value = {
loaded: true,
needsSetup: boot.needs_setup,
user: boot.user,
allowRegistration: boot.allow_registration,
publicUrl: boot.public_url,
previewOrigin: boot.preview_origin,
}
return state.value
}
async function load(force = false): Promise<SessionState> {
if (state.value.loaded && !force) return state.value
if (!inflight) {
inflight = api
.get<BootstrapResponse>('/bootstrap')
.then((boot) => apply(boot))
.finally(() => {
inflight = null
})
}
return inflight
}
async function signOut() {
try {
await api.post('/logout')
} catch {
// The cookie is cleared server-side when the session is still valid.
}
state.value = { ...state.value, user: null }
await navigateTo('/login')
}
return {
session: state,
user: computed(() => state.value.user),
load,
signOut,
}
}