The origin check compared the browser's Origin with the configured public_url. Reaching the app through localhost or another LAN address then rejected the terminal and presence sockets even though the page and the socket were on the same origin. Compare the Origin authority with the request's Host header instead. That is the address the browser actually used, so the check still refuses another site while working behind a proxy and on every local address.
rhema-together
A shared room where people and a Rhema coding agent work on the same code. One conversation, one workspace, one agent; the people and the agent see the same sandbox.
The room is a browser workspace:
- Chat with the room and with
@rhema. Human messages carry their author's name; the agent speaks through amessagetool so that its private reasoning never leaks into the room. - Preview iframe for a dev server running inside the sandbox.
- Files pane: the tree, a read-only file view,
git status, andgit diff. - Terminal: a real PTY in the sandbox, same target and key as the agent, rendered with xterm.js.
- Presence: who is online, who is typing.
Accounts own rooms, plans, and providers. Friends join by a single-use magic link and a display name; joining a room is the trust boundary, and members can run commands in the room's sandbox. Use a dedicated machine or account for a sandbox.
What is here
src/ the Axum server (Rust)
web/ the Nuxt 4 client (Vue, no SSR)
specs/ the design document
AGENTS.md working conventions
The server serves the built client, so production is one process and one SQLite file.
Build
Requirements: Rust 1.98+, Node 22+, pnpm, and an SSH server reachable from the machine that runs rhema-together.
cargo build --release
cd web && pnpm install && pnpm build && cd ..
The client lands in web/.output/public; that is TOGETHER_WEB_DIR.
Run
TOGETHER_LISTEN=127.0.0.1:7800 \
TOGETHER_PUBLIC_URL=http://localhost:7800 \
TOGETHER_PREVIEW_ORIGIN=http://preview.localhost:7800 \
./target/release/rhema-together
Open http://localhost:7800. The first visit sends you to /setup to
create the first account. The server log also prints a one-time setup
link, in case someone already opened the app before the database
existed.
For a local-network test, bind 0.0.0.0:7800 and set
TOGETHER_PUBLIC_URL to the machine's LAN address, for example
http://10.4.1.222:7800. Invite links and cookies then use that
address. Preview hosts need a name that resolves from the other device;
TOGETHER_PREVIEW_ORIGIN=http://preview.10.4.1.222.nip.io:7800 works
when the network can reach a public DNS resolver.
During client development, run pnpm dev in web/ (port 3000) and
keep the server on port 7800; the Nuxt dev proxy forwards /api,
including the terminal WebSocket.
Deploy
The repository builds a self-contained image. The Dockerfile clones the
Rhema framework at the tag it names, builds the client and server, and
runs the result as UID 10001 with a writable /data volume.
docker build -t registry.example.com/rhema-together:0.1.0 .
docker run --rm -p 7800:7800 -v together-data:/data \
-e TOGETHER_PUBLIC_URL=https://together.example.com \
-e TOGETHER_ALLOW_REGISTRATION=false \
-e TOGETHER_PREVIEW_ORIGIN=https://preview.together.example.com \
registry.example.com/rhema-together:0.1.0
For Kubernetes, the chart in deploy/helm/rhema-together adds the
deployment, service, ingress, and persistent volume. It also documents
the wildcard DNS, wildcard TLS certificate, proxy buffering, and body
size the app needs. Read that README before exposing the service.
The preview host is a signed subdomain, so the ingress must route all
of *.preview.<your-domain> to the same service. The app does not
issue certificates.
First room
- Settings → Providers. Add a provider kind, model, and key. Keys are sealed with the server's master key before they touch SQLite.
- Settings → Sandboxes. Add a target. Leave the private key empty
and the server generates an ed25519 pair and shows the public key.
Append that line to
~/.ssh/authorized_keyson the target. Set the workspace root to a directory the ssh user can write (for a normal user,/home/<name>; the default is/root). Test the target; a green check means ssh works. - New room. Pick the target and provider, give the workspace
directory (for example
/home/me/rooms/demo), and optionally a git URL. The workspace is created on the first mention and seeded from the repository or a README. - Invite. The room's invite dialog creates a single-use link such
as
https://together.example.com/join/<token>. A friend opens it, picks a display name, and lands in the room as a guest. - Say
@rhema start a small Vite app on port 5173, then open the Preview pane on 5173.
The agent always runs with the room's sandbox, and every command is an ordinary ssh command. There is no approval prompt: the sandbox is the boundary.
Preview
The preview host is a signed subdomain of TOGETHER_PREVIEW_ORIGIN:
http://preview.localhost:7800 local development
https://preview.together.example.com production
Each preview is served from
<scheme>://r<room>-p<port>-<expiry>-<hmac>.<preview host>/. The HMAC
covers the room, port, and expiry and is derived from the server's
master key, so a room id alone is not enough to reach a preview. The
address expires after 24 hours; reloading the pane mints a new one. DNS
must resolve every subdomain of the preview host to the server (a
wildcard *.preview record), and TLS must cover the wildcard. A copied
preview URL works for anyone who has it until it expires; treat it as a
read capability for that port.
The proxy forwards ordinary HTTP through an ssh direct-tcpip channel
to 127.0.0.1:<port> inside the sandbox. WebSocket upgrades (Vite HMR)
are not forwarded in v1; reload the pane after an edit.
Caddy
together.example.com {
reverse_proxy 127.0.0.1:7800
}
*.preview.example.com {
tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}
reverse_proxy 127.0.0.1:7800
}
Set TOGETHER_PUBLIC_URL=https://together.example.com and
TOGETHER_PREVIEW_ORIGIN=https://preview.example.com. Cookies become
Secure automatically from the public URL.
Configuration
Every field can be set in the YAML file (TOGETHER_CONFIG, default
config.yaml when present) or overridden by an environment variable.
| variable | default | meaning |
|---|---|---|
TOGETHER_LISTEN |
127.0.0.1:7800 |
bind address |
TOGETHER_PUBLIC_URL |
http://localhost:7800 |
browser origin; invite links and cookies |
TOGETHER_PREVIEW_ORIGIN |
http://preview.localhost:7800 |
wildcard parent for previews; empty disables them |
TOGETHER_DATABASE |
data/together.db |
SQLite file |
TOGETHER_SECRET_KEY_FILE |
data/secret.key |
32-byte master key (created, mode 0600) |
TOGETHER_WEB_DIR |
web/.output/public |
built client |
TOGETHER_MAX_TURN_STEPS |
48 |
step cap per turn |
TOGETHER_ALLOW_REGISTRATION |
false |
whether /register works |
Security model
- The sandbox is remote and the target's account is the boundary. Give the room a dedicated user/machine.
- Provider keys and ssh private keys are encrypted with ChaCha20-Poly1305 under the master key. No API returns them.
- Session cookies are
HttpOnly; CSRF is a double-submit cookie for mutating calls. - Guests can chat, interrupt, use the terminal, and read files. Only full accounts create rooms, providers, and targets.
- Registration is closed by default; setup and invite links work
without it. A full account can make the server open an SSH connection
to a host it names, so open signup also makes the server reachable
from anywhere as a port scanner. Turn it on only when you trust
everyone who can reach
/register. - A preview host is a signed capability for one room and port. It
expires after 24 hours, and preview responses carry
Referrer-Policy: no-referrer. A copied URL works until it expires. - Removing a member or archiving a room ends that account's event feed, presence socket, and terminal within a few seconds. The terminal and preview proxy pin the SSH host key on first login and refuse a changed key.
- Preview URLs are signed capabilities, not authenticated pages.
- The app sets a CSP that frames only
*.<preview host>, and refuses to frame itself elsewhere. - The server must be reachable by the friends you invite. The default bind is loopback; put a TLS reverse proxy in front.
Roadmap
The spec's §12. Phases lists the path from this v1: ecrou live
sandboxes, multiple checkouts in the UI, port discovery, HMR, terminal
scrollback on reconnect, editor cursors, and co-editing. HostAgent::step
in the framework is the one upstream change still deferred; until then
steering is turn-level, the same pattern as rhema-code.