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

+190
View File
@@ -0,0 +1,190 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import type {
CreateRoomBody,
CreateRoomResponse,
ProviderConfig,
ProviderListResponse,
SandboxListResponse,
SandboxTarget,
} from '~/types'
import { apiErrorMessage } from '~/utils/errors'
import BaseDialog from '~/components/BaseDialog.vue'
const emit = defineEmits<{ close: [] }>()
const api = useApi()
const router = useRouter()
const rooms = useRooms()
const providers = ref<ProviderConfig[]>([])
const targets = ref<SandboxTarget[]>([])
const loading = ref(true)
const loadError = ref('')
const name = ref('')
const providerId = ref('')
const targetId = ref('')
const workspace = ref('')
const repoUrl = ref('')
const model = ref('')
const submitting = ref(false)
const error = ref('')
const canSubmit = computed(
() => !loading.value && !submitting.value && !!name.value.trim() && !!providerId.value && !!targetId.value,
)
const missing = computed(() => {
if (loading.value) return ''
if (providers.value.length === 0 && targets.value.length === 0) {
return 'Add a provider and a sandbox in settings before creating a room.'
}
if (providers.value.length === 0) return 'Add a provider in settings before creating a room.'
if (targets.value.length === 0) return 'Add a sandbox in settings before creating a room.'
return ''
})
onMounted(async () => {
try {
const [providerList, targetList] = await Promise.all([
api.get<ProviderListResponse>('/provider-configs'),
api.get<SandboxListResponse>('/sandbox-targets'),
])
providers.value = providerList.providers
targets.value = targetList.targets
providerId.value = providers.value[0]?.id ?? ''
targetId.value = targets.value[0]?.id ?? ''
const current = providers.value.find((provider) => provider.id === providerId.value)
model.value = current?.model ?? ''
} catch (err) {
loadError.value = apiErrorMessage(err)
} finally {
loading.value = false
}
})
function onProviderChange() {
const current = providers.value.find((provider) => provider.id === providerId.value)
if (current && !model.value.trim()) model.value = current.model
}
async function submit() {
if (!canSubmit.value) return
submitting.value = true
error.value = ''
const body: CreateRoomBody = {
name: name.value.trim(),
provider_config_id: providerId.value,
sandbox_target_id: targetId.value,
}
if (workspace.value.trim()) body.workspace = workspace.value.trim()
if (repoUrl.value.trim()) body.repo_url = repoUrl.value.trim()
if (model.value.trim()) body.model = model.value.trim()
try {
const response = await api.post<CreateRoomResponse>('/rooms', body)
await rooms.refresh()
emit('close')
await router.push(`/room/${response.room.id}`)
} catch (err) {
error.value = apiErrorMessage(err)
} finally {
submitting.value = false
}
}
</script>
<template>
<BaseDialog title="New room" description="A room has one workspace, one provider, and one shared log." @close="emit('close')">
<p v-if="loading" class="meta">Loading providers and sandboxes.</p>
<p v-else-if="loadError" class="form-error">{{ loadError }}</p>
<form class="form" @submit.prevent="submit">
<p v-if="missing" class="form-note">
{{ missing }}
<NuxtLink to="/settings" @click="emit('close')">Open settings</NuxtLink>
</p>
<div class="field">
<label class="field-label" for="new-room-name">Room name</label>
<input
id="new-room-name"
v-model="name"
class="input"
type="text"
maxlength="60"
autocomplete="off"
autofocus
required
>
</div>
<div class="field">
<label class="field-label" for="new-room-provider">Provider</label>
<select
id="new-room-provider"
v-model="providerId"
class="select"
:disabled="providers.length === 0"
required
@change="onProviderChange"
>
<option v-for="provider in providers" :key="provider.id" :value="provider.id">
{{ provider.name }} ({{ provider.kind }})
</option>
</select>
</div>
<div class="field">
<label class="field-label" for="new-room-sandbox">Sandbox</label>
<select id="new-room-sandbox" v-model="targetId" class="select" :disabled="targets.length === 0" required>
<option v-for="target in targets" :key="target.id" :value="target.id">
{{ target.name }} ({{ target.user_name }}@{{ target.host }}:{{ target.port }})
</option>
</select>
</div>
<div class="field">
<label class="field-label" for="new-room-model">Model <span class="field-optional">optional</span></label>
<input id="new-room-model" v-model="model" class="input" type="text" autocomplete="off">
<span class="hint">Leave this as the provider model unless the room needs another one.</span>
</div>
<div class="field">
<label class="field-label" for="new-room-workspace">Workspace <span class="field-optional">optional</span></label>
<input
id="new-room-workspace"
v-model="workspace"
class="input"
type="text"
autocomplete="off"
placeholder="/root/my-project"
>
<span class="hint">An absolute path. Without one, the server creates a directory under the sandbox workspace root.</span>
</div>
<div class="field">
<label class="field-label" for="new-room-repo">Repository <span class="field-optional">optional</span></label>
<input
id="new-room-repo"
v-model="repoUrl"
class="input"
type="text"
autocomplete="off"
placeholder="https://github.com/owner/project.git"
>
</div>
<p v-if="error" class="form-error" role="alert">{{ error }}</p>
<div class="dialog-actions">
<button type="button" class="btn btn-quiet" @click="emit('close')">Cancel</button>
<button type="submit" class="btn btn-primary" :disabled="!canSubmit">
{{ submitting ? 'Creating' : 'Create room' }}
</button>
</div>
</form>
</BaseDialog>
</template>