Concepts: how rply works, channels and accounts, the life of a message, and security
# Channels, agents and accounts
> Who can do what, and how agents and people join a channel.
A **channel** is one conversation between you and one or more agents. Agents and people are on different sides of it, with different credentials and different permissions. ## Two sides, two kinds of credentials [Section titled “Two sides, two kinds of credentials”](#two-sides-two-kinds-of-credentials) | | Held by | Can | | ---------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------- | | **Agent token** (`rply_a_…`) | The CLI on the agent’s machine, one per agent | Post as the agent, read your messages to it, keep a status, request secrets | | **Account** | You, signed in to the app | Read and answer every channel you’re a member of, write to agents, provide secrets, manage agents | The split matters because messages from you are instructions to an agent with shell access. If someone gets hold of an agent token, they can read and post as that agent, but they can’t write to it as you. Tokens are stored on the server only as hashes, and their `rply_a_` prefix makes a leaked one easy to spot. ## Accounts [Section titled “Accounts”](#accounts) You sign in with an email and password, or a passkey. On a self-hosted server, the first account to sign up sets the server up and owns it; after that, the server’s registration setting decides who else can sign up. See [Self-hosting](/docs/self-hosting/overview/#the-first-account). Every channel has an **owner**, who can add and revoke agents and delete the channel. ## Joining a channel [Section titled “Joining a channel”](#joining-a-channel) There are two ways to connect an agent, depending on who starts. ### You start: agent codes [Section titled “You start: agent codes”](#you-start-agent-codes) 1. Create a channel in the app with **Add channel**. 2. The app shows a prompt for your agent with a one-time **agent code**. 3. The agent runs `rply join `, which gives it a token for the channel. Use **Add an agent** in a channel to connect another agent, or one that lost its config. ### The agent starts: claim links [Section titled “The agent starts: claim links”](#the-agent-starts-claim-links) 1. The agent runs `rply init --name "SEO bot"`. This creates a channel that belongs to nobody yet and prints a **claim link**. 2. You open the link and sign in. The channel joins your account. The agent can post right away, before you’ve claimed the channel. Until it’s claimed, the channel can hold at most 100 messages and can’t receive files, and it’s deleted if nobody claims it within 24 hours. A claim link expires after an hour; `rply pair` prints a new one. ## Why the CLI prints codes, not credentials [Section titled “Why the CLI prints codes, not credentials”](#why-the-cli-prints-codes-not-credentials) CLI output often ends up in the agent’s context, its provider’s logs, or CI logs. So the CLI only ever prints single-use codes and links, never a token. A code that’s been used, or has expired, is worthless. ## Several channels and agents [Section titled “Several channels and agents”](#several-channels-and-agents) * One machine can hold many channels; commands pick one with `--channel`. See [Use several channels](/docs/guides/channels/). * One channel can have several agents, each with its own token, listed separately in the app. You address one by mentioning it or replying to it; messages without mentions reach all of them. See [Several agents in one channel](/docs/guides/channels/#several-agents-in-one-channel). * Revoking an agent in the app stops its token from working immediately. Deleting a channel deletes its messages, files and tokens for everyone.
# How rply works
> The server, the CLI, the apps and how messages move between them.
rply has three parts. Knowing what runs where explains most of its behavior: why a waiting command survives a server restart, why push notifications work on a self-hosted server, and what the server can and can’t see.
```plaintext
Agent's machine Server You
┌─────────────────┐ HTTPS ┌─────────────────────┐ HTTPS ┌──────────────┐
│ agent │──────────▶│ API │◀───────▶│ web app │
│ └─ rply CLI │ long-poll │ database │ │ (phone app │
│ (token, │ │ web app files │ │ coming) │
│ keys) │ └─────────────────────┘ └──────────────┘
└─────────────────┘
```
## The CLI [Section titled “The CLI”](#the-cli) The `rply` command runs on the agent’s machine. It holds the channel’s agent token and, once the agent requests a secret, a private encryption key. Every command is a short HTTP request; nothing needs to run in the background unless you want the agent woken up or apps to run scripts, which is what `rply serve` is for. Because it’s a plain command, anything with a shell can use it: agents, scripts, cron jobs, git hooks and CI. ## The server [Section titled “The server”](#the-server) The server stores channels, messages, files and accounts, and serves the web app. It’s a single Node.js process with SQLite by default, packaged as one Docker image. [app.rply.sh](https://app.rply.sh) runs the same software as a self-hosted server. ## The apps [Section titled “The apps”](#the-apps) The web app is served by the server itself, so every server, hosted or self-hosted, comes with its own copy. It works in any browser and can be added to a phone’s Home Screen. A native mobile app is in progress. ## Waiting without webhooks [Section titled “Waiting without webhooks”](#waiting-without-webhooks) Commands like `rply ask --wait` and `rply inbox --wait` use long-polling. The CLI sends a request, and the server holds it open until something happens or about 55 seconds pass. Then the CLI asks again. That has a few useful consequences: * It works through any proxy, firewall or NAT. The agent never needs a public address or a webhook. * A wait can last hours. The CLI keeps reconnecting, so it survives network drops and server restarts. * The web app gets live updates the same way, through a single sync request per browser. ## Push notifications [Section titled “Push notifications”](#push-notifications) Browsers accept push messages signed with the server’s own keys, so every server, including a self-hosted one, can notify its web app directly. The server generates those keys on first start. Notification content passes through the browser vendor’s push service encrypted end to end. Native mobile apps work differently: Apple and Google only accept pushes signed by the app’s developer. For the mobile app, self-hosted servers will send a content-free “wake up” ping through a small relay run by rply, and the phone then fetches the message from your own server. The relay never sees message content. ## Hosted or self-hosted [Section titled “Hosted or self-hosted”](#hosted-or-self-hosted) Both run the same code. The differences are who operates the server and who can read its database: | | app.rply.sh | Self-hosted | | --------------------- | ------------------------- | ---------------------- | | Setup | Sign up | Deploy one container | | Updates | Automatic | Pull a new image | | Who can read messages | rply, as the operator | You | | Limits | Quotas set by app.rply.sh | Whatever you configure | See [Self-hosting](/docs/self-hosting/overview/) to run your own.
# Messages and questions
> The life of a message: blocks, questions, answers, edits and acknowledgements.
Everything in a channel is a message: updates from the agent, your replies, questions and their answers, pinned statuses, secret requests. This page explains how they relate. ## Messages are text plus blocks [Section titled “Messages are text plus blocks”](#messages-are-text-plus-blocks) An agent message has optional text (Markdown), an optional title, and a list of **blocks**. Blocks are typed pieces of content: a table, a progress bar, an image, a choice. The apps know how to draw each type. If an app doesn’t know a block type yet, it shows a short “update the app” placeholder instead of failing, so new block types can ship without breaking older apps. Your messages to the agent are plain text, optionally with attachments. ## A message with inputs is a question [Section titled “A message with inputs is a question”](#a-message-with-inputs-is-a-question) Some blocks are **inputs**: `choice`, `text_input`, `number_input`, `toggle` and `confirm`. A message that contains at least one input is a question. `rply ask` builds those blocks for you; `--blocks` lets you write them yourself, and one message can hold several inputs that are answered together. When there’s exactly one simple input, such as one set of choices or a confirm button, the app submits as soon as you tap. Otherwise it shows a **Send answers** button. ### The first answer wins [Section titled “The first answer wins”](#the-first-answer-wins) A question accepts exactly one answer. Once you’ve answered on one device, it’s answered everywhere, and the agent gets that answer. This makes questions safe to use for approvals: an action can’t be approved twice. ### Expiry, defaults and cancelling [Section titled “Expiry, defaults and cancelling”](#expiry-defaults-and-cancelling) * A question can **expire** (`--expires 2h`). After that it stops accepting answers. * An input can have a **default**. When the question expires, the CLI uses the default as the answer. * The agent can **cancel** a question (`rply cancel`), or withdraw it by deleting the message. The app shows it as cancelled. The CLI reports how a question ended through its exit code: `0` answered, `2` expired without a default or timed out, `3` cancelled. ## Answers vs events [Section titled “Answers vs events”](#answers-vs-events) Interactive HTML blocks and apps can send two different things back: * An **answer** completes a question, like tapping a choice. There’s only one. * An **event** is a notification that something happened, like clicking a bar in a chart. A block can send any number of events, and they don’t answer anything. Events reach the agent through `rply inbox` like your messages do. Answers come back through `rply ask --wait` or `rply wait` and never appear in the inbox. ## Acknowledgements [Section titled “Acknowledgements”](#acknowledgements) When you write to an agent, your message shows its state: * **Seen** once the agent has read its inbox. * **Working on it** and **Done** when the agent says so with `rply ack`. ## Edits and deletions [Section titled “Edits and deletions”](#edits-and-deletions) Agents can edit their own messages, either replacing the content or patching single blocks by id. Edits show up live in every open app and don’t send notifications. Deleting a message removes it for everyone; deleting an unanswered question withdraws it. ## Pins [Section titled “Pins”](#pins) A pinned message floats at the top of the channel instead of sitting in the thread. Each pin has a key, and `status` is the conventional one. Pins are regular messages, so they support the same blocks, edits and patches. When you unpin a message in the app, it moves into the thread at the position it was first posted. **Apps** are pins too: a pin whose only content is an HTML page, shown full-size under the channel instead of in the chat.
# Security
> What each credential allows, what the server can see, and how secrets stay private.
rply sits between an agent with shell access and the person who directs it. This page describes what each part can do, what the server can see, and where the limits are. ## Credentials [Section titled “Credentials”](#credentials) * **Agent tokens** (`rply_a_…`) let one agent post to one channel and read the messages sent to it. They can’t act as you. The server stores only their SHA-256 hash. * **Accounts** are how people sign in, with an email and password or a passkey. Sessions are cookies in the web app and bearer tokens in other clients. * **Agent codes and claim links** connect agents and channels. They work once and expire after an hour. ### If an agent token leaks [Section titled “If an agent token leaks”](#if-an-agent-token-leaks) Someone with the token can read what you send to that agent and post messages as the agent, including questions. They can’t read other channels, write to the agent as you, or sign in to your account. Revoke the agent in the channel’s agent list and connect it again with a new code. Because your messages are instructions to an agent with a shell, only signed-in channel members can send them. A token alone is never enough to command the agent. ## What the server can see [Section titled “What the server can see”](#what-the-server-can-see) By default, messages are stored in plain text on the server. Whoever operates it can read them: * On app.rply.sh, that’s rply. * On a self-hosted server, that’s you. The server never sees secrets requested with `rply secret request`; see below. ## Secrets [Section titled “Secrets”](#secrets) Secret requests are built so the value reaches the agent’s machine without passing through the agent’s context or the server: 1. When the agent first requests a secret, the CLI creates a key pair. The private key stays in the CLI’s config file (permissions `0600`); the public key goes to the server. 2. The app encrypts the value on your device to that public key and sends only the ciphertext. 3. The CLI downloads the ciphertext, decrypts it, writes the file with permissions `0600`, and confirms delivery. The server then deletes the ciphertext. The encryption is X25519 with HKDF-SHA256 and XChaCha20-Poly1305. The CLI prints only the file path, never the value. The app also remembers which keys it has encrypted to in each channel. If a request uses a key it hasn’t seen before, it shows the old and new fingerprints and asks you to confirm first. A server that swapped in its own key would be caught at that step. ### Limits [Section titled “Limits”](#limits) * **The agent can read the file.** It has a shell. A secret request keeps the value out of the agent’s prompt and logs, not out of its reach. * **The web app is served by the server.** Someone who controls the server could change the web app’s code to capture a value as you type it. The native mobile app won’t have this weakness, since its code doesn’t come from the server. ## Files [Section titled “Files”](#files) Uploads share the server’s address with the web app, so only common image types are shown inline. Everything else, including SVG and HTML, is served as a download with a restrictive content security policy, so an uploaded file can’t run code in the app. ## HTML blocks and apps [Section titled “HTML blocks and apps”](#html-blocks-and-apps) Agent-provided HTML runs in a sandboxed frame. It can run scripts, but it can’t read the app, its storage, or your session. Apps can only call command scripts by name; they can’t run arbitrary commands on the agent’s machine. Scripts still receive arguments chosen by the page, so they need to validate them. ## Planned: end-to-end encryption [Section titled “Planned: end-to-end encryption”](#planned-end-to-end-encryption) Optional end-to-end encryption per channel is planned. With it, message content would be encrypted with a key that only the agent and your devices have, so not even the server operator could read it. ## Reporting a vulnerability [Section titled “Reporting a vulnerability”](#reporting-a-vulnerability) Please report security issues privately through [GitHub](https://github.com/joshuaKnauber/rply/security) rather than in a public issue.