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

+100
View File
@@ -0,0 +1,100 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import type { InvitePreview, JoinResponse } from '~/types'
import { apiErrorMessage } from '~/utils/errors'
import { formatDate } from '~/utils/format'
definePageMeta({ layout: 'auth' })
useHead({ title: 'Join a room · rhema together' })
const route = useRoute()
const api = useApi()
const { session, load } = useSession()
const token = computed(() => String(route.params.token ?? ''))
const invite = ref<InvitePreview | null>(null)
const loading = ref(true)
const loadError = ref('')
const displayName = ref('')
const submitting = ref(false)
const error = ref('')
onMounted(async () => {
displayName.value = session.value.user?.display_name ?? ''
try {
invite.value = await api.get<InvitePreview>(`/invites/${encodeURIComponent(token.value)}`)
} catch (err) {
loadError.value = apiErrorMessage(err)
} finally {
loading.value = false
}
})
async function submit() {
if (submitting.value || !invite.value) return
submitting.value = true
error.value = ''
try {
const name = session.value.user?.display_name || displayName.value.trim()
const response = await api.post<JoinResponse>(`/invites/${encodeURIComponent(token.value)}`, {
display_name: name,
})
await load(true)
await navigateTo(`/room/${response.room_id}`, { replace: true })
} catch (err) {
error.value = apiErrorMessage(err)
} finally {
submitting.value = false
}
}
</script>
<template>
<div>
<template v-if="loading">
<p class="meta">Checking the invite.</p>
</template>
<template v-else-if="loadError">
<h1 class="auth-title">Invite</h1>
<p class="form-error" role="alert">{{ loadError }}</p>
<div class="auth-footer">
<NuxtLink to="/login">Sign in</NuxtLink> if you already have an account.
</div>
</template>
<template v-else-if="invite">
<h1 class="auth-title">Join {{ invite.room_name }}</h1>
<p class="auth-note">
Owned by {{ invite.owner }}. The link works once and expires {{ formatDate(invite.expires_at) }}.
</p>
<form class="form" @submit.prevent="submit">
<p v-if="session.user" class="form-note">Joining as {{ session.user.display_name }}.</p>
<div v-else class="field">
<label class="field-label" for="join-name">Display name</label>
<input
id="join-name"
v-model="displayName"
class="input"
type="text"
autocomplete="name"
autofocus
required
>
<span class="hint">This is how the room sees you. You can add an account later.</span>
</div>
<p v-if="error" class="form-error" role="alert">{{ error }}</p>
<button type="submit" class="btn btn-primary" :disabled="submitting || (!session.user && !displayName.trim())">
{{ submitting ? 'Joining' : 'Join room' }}
</button>
</form>
<div v-if="session.user" class="auth-footer">
<NuxtLink to="/rooms">Back to rooms</NuxtLink>
</div>
</template>
</div>
</template>