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.
3.9 KiB
3.9 KiB
AGENTS.md
Conventions for working in this tree.
Before every commit
cargo fmt --all
cargo clippy --all-targets -- -D warnings
cargo test
(cd web && pnpm typecheck && pnpm build)
cargo fmt may touch files you did not edit. Include those changes in
the commit rather than leaving the tree dirty. web/.output/public is
gitignored; the server rebuilds nothing, so build it before testing the
whole app.
What this is
rhema-together is a separate product that consumes the Rhema crates by
path (../rhema). It is not rhema-claw and it is not a mode of it.
The claw is resident and single-owner; this is a room with accounts,
many sandboxes, and invite links.
Rules:
- Do not edit
../rhemafrom here. If a framework change is needed, note it inspecs/rhema-together.md§11 and keep the workaround local. - Do not copy claw code.
rhema-codemay be read for a pattern (the turn-level steering insrc/room/runner.rsis copied from its turn loop), and the spec says where. - The sandbox is the security boundary. Approval is always
AllowAll; never add an approval prompt in the room. - Every path into the sandbox goes through
rhema_sandbox::SandboxorShellSandbox(agent tools, files, terminal, preview). Do not spawn a command on the host for room work. - Secrets never leave the server. Provider keys and ssh private keys are
sealed with
crypto::Secrets; no route returns a decrypted key.
Map
src/main.rs process start, listener, background jobs
src/config.rs YAML + TOGETHER_* env
src/db.rs schema and migrations
src/crypto.rs ChaCha20Poly1305 secrets, preview HMAC
src/auth.rs sessions, cookies, CSRF
src/state.rs AppState: db, hub, secrets, runner, tunnels
src/api/ routes: auth, settings, rooms, messages, files
src/room/agent.rs per-turn config, ssh sandbox, HostAgent assembly
src/room/runner.rs one task per room; mention -> turn; steering
src/room/message_tool.rs the agent's only voice
src/ssh.rs russh client, PTY terminal, direct-tcpip
src/preview.rs signed preview hosts and the ssh HTTP proxy
web/app/ Nuxt 4 SPA (no SSR)
Invariants
- A room is visible only to its members. Every room route calls
member_of(or checks the member row directly). - Mutating API calls require the
X-CSRF-Tokenheader matching thetogether_csrfcookie. The cookie is readable by JS; the session cookie isHttpOnly. - Guests may join and chat. Only
kind = "user"accounts create rooms or add providers and sandbox targets. - Room log events are append-only.
seqis the ordering. Durable events (message,notice,turn_start,turn_end,tool_result) are stored and replay from?since=; deltas are broadcast only and may leave gaps. - The agent speaks through
messageonly. It must always send one before the turn ends.messageisReplaySafety::Unsafe. - Turns are serialized per room. A new mention while a turn runs drops the turn future (turn-level steering) and starts a new turn over the committed session. Do not drop the room task.
- The preview host label is
r<room>-p<port>-<hmac>.<preview host>. The HMAC coversroom:portwith a key derived from the master key. The preview origin must be a wildcard DNS zone for subdomains to resolve.
Testing
cargo testruns the unit tests in the binary.- An end-to-end turn needs an ssh target and a provider. A fake
OpenAI-compatible server (SSE
chat/completions) plussshdon localhost is enough; seespecs/and the commit log for the manual run. Do not commit a live API key. - The first account is created through
/setupand printed as a one-time URL in the server log; there is no default password.
Commits
Conventional Commits, a short imperative subject, a body that says why
when the change is not obvious. Scopes: server, api, room, ssh,
preview, web, spec, docs. One logical change per commit.