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

+106
View File
@@ -0,0 +1,106 @@
//! Rows and wire types shared by the API and the room.
use serde::{Deserialize, Serialize};
/// One chat line. The sequence number orders it in the room log.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
pub seq: u64,
pub id: String,
/// The member id for a human, `None` for the agent and system lines.
pub author_id: Option<String>,
pub author_name: String,
/// `human`, `agent`, or `system`.
pub author_kind: String,
pub text: String,
pub mentions: bool,
pub created_at: i64,
}
/// A room as the sidebar needs it.
#[derive(Debug, Clone, Serialize)]
pub struct RoomSummary {
pub id: String,
pub name: String,
pub role: String,
pub member_count: i64,
pub last_at: Option<i64>,
pub last_text: Option<String>,
}
/// A full room.
#[derive(Debug, Clone, Serialize)]
pub struct Room {
pub id: String,
pub name: String,
pub owner_id: String,
pub provider_config_id: Option<String>,
pub sandbox_target_id: Option<String>,
pub workspace: String,
pub repo_url: Option<String>,
pub model: Option<String>,
pub max_turn_steps: i64,
pub created_at: i64,
pub archived_at: Option<i64>,
}
/// A member row.
#[derive(Debug, Clone, Serialize)]
pub struct Member {
pub id: String,
pub account_id: String,
pub display_name: String,
pub role: String,
pub color: String,
pub online: bool,
}
/// The account as the client sees it.
#[derive(Debug, Clone, Serialize)]
pub struct User {
pub id: String,
pub handle: String,
pub display_name: String,
pub kind: String,
}
/// One server-sent event. Durable events are also rows in `events`;
/// deltas are live only.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Envelope {
pub seq: u64,
pub kind: String,
pub data: serde_json::Value,
}
/// A provider configuration without its key.
#[derive(Debug, Clone, Serialize)]
pub struct ProviderConfig {
pub id: String,
pub name: String,
pub kind: String,
pub model: String,
pub base_url: Option<String>,
}
/// A sandbox target without its private key.
#[derive(Debug, Clone, Serialize)]
pub struct SandboxTarget {
pub id: String,
pub name: String,
pub host: String,
pub port: i64,
pub user_name: String,
pub workspace_root: String,
pub public_key: String,
pub host_fingerprint: Option<String>,
}
/// A directory entry in the read-only file pane.
#[derive(Debug, Clone, Serialize)]
pub struct FileEntry {
pub name: String,
pub path: String,
pub kind: String,
pub size: i64,
}