Files
rhema-together/README.md
T
vhaudiquet 64d7f359f5
ci / checks (push) Successful in 57s
ci / test (push) Successful in 1m0s
ci / chart (push) Successful in 4s
ci / web (push) Successful in 21s
ci / docker (push) Successful in 1m48s
ci / publish-edge-image (push) Successful in 12s
ci / publish-edge-chart (push) Successful in 4s
feat(api): retire ChatGPT plan sign-in by default
A room's provider serves every member, while a ChatGPT plan belongs to
one account, so sharing it breaks OpenAI's terms. Together now hides
the chatgpt kind, refuses to store a new one, and fails a room that
still points at it with a message that names the API-key route.

Existing provider rows stay in the database. The room settings dialog
keeps the room's current provider visible even when its kind is
retired, so the room shows what it is pinned to instead of silently
losing it. Creating or updating a room to that provider is refused.

`RHEMA_TOGETHER_I_WANT_CHATGPT_BAN=1` lifts the block for a single-user
local test. The value has to be exactly `1`; any other value leaves the
block in place.
2026-12-03 16:10:14 +01:00

246 lines
10 KiB
Markdown

# rhema-together
A shared room where people and a [Rhema](https://github.com/vhaudiquet/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 and can carry images when the room's model has vision;
the agent speaks through a `message` tool so that its private
reasoning never leaks into the room.
- **Preview** iframe for a dev server or a static build, set from the
chat by the agent's `preview` tool.
- **Files** pane: the tree, a read-only file view, `git status`, and
`git 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.
```sh
cargo build --release
cd web && pnpm install && pnpm build && cd ..
```
The client lands in `web/.output/public`; that is `TOGETHER_WEB_DIR`.
## Run
```sh
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.
```sh
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.
CI publishes the image and chart to the home Gitea registry on every
push to `main`; a `v*` tag publishes the exact version. The chart
repository is
`https://git.vhaudiquet.fr/api/packages/vhaudiquet/helm`.
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
1. **Settings → Providers.** Add a provider kind and its key, address,
or sign-in. For GitHub Copilot and Mistral Vibe the dialog runs the
provider's sign-in. Together does not offer ChatGPT plan sign-in;
use the openai kind with an API key instead. Set
`RHEMA_TOGETHER_I_WANT_CHATGPT_BAN=1` to lift the block for a
single-user local test; a shared room still breaks OpenAI's terms.
The credential is sealed with the server's master key before it
touches SQLite. A new provider stores no model; the room picks one.
2. **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_keys` on 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.
3. **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. The Model field opens the provider's
model list with context, output, price, and vision. Pick a row, or
type an id the list does not carry.
4. **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.
5. 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 shows one target per room. It is either a port inside the
sandbox, or a static HTML file or folder read over ssh and served by the
app. The agent sets it with the `preview` tool, and the choice is stored
with the room, so a later visitor sees the same target.
A static target does not start a process. Point it at a build folder
(`dist`, `web/.output/public`) or a single HTML file. The app reads files
over the same ssh target the agent uses, refuses `..` and dotfiles, and
stops at 16 MiB per file. Point it at a build folder rather than the
repository root unless the whole tree is meant to be public.
The preview host is a signed subdomain of `TOGETHER_PREVIEW_ORIGIN`:
```
http://preview.localhost:7800 local development
https://preview.together.example.com production
```
A port is served from
`<scheme>://r<room>-p<port>-<expiry>-<hmac>.<preview host>/`.
A static target is served from
`<scheme>://r<room>-s<hash>-<expiry>-<hmac>.<preview host>/`, where
`hash` covers the target's root and entry file. A link minted for one
static target stops working when the preview moves. The HMAC covers the
target 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; loading 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 target.
For a port, the proxy forwards ordinary HTTP through an ssh
`direct-tcpip` channel to `127.0.0.1:<port>` inside the sandbox. For a
static target, each request runs one short read over ssh. WebSocket
upgrades (Vite HMR) are not forwarded in v1; reload the pane after an
edit, and disable HMR for the preview when a dev server insists on it.
### 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 |
| `TOGETHER_ALLOW_PRIVATE_TARGETS` | `false` | whether a sandbox target may use a loopback or private address |
## 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 one target,
either a port or a static tree. 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`.