Repository navigation
feat(cli): relay init for local, hosted and self-hosted; never leak self-hosted credentials #1992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4357871
fix(cli): never send a self-hosted Relaycast credential to the hosted…
khaliqgant 6a41022
feat(cli): relay init for local, hosted and self-hosted, with saved a…
khaliqgant 7f9240c
fix(cli): rotation revokes the previous token; clearer self-host docs
khaliqgant d7d5199
fix(cli): harden Relaycast origin bindings against lost updates and r…
khaliqgant 8e1c49a
fix(cli): rotation never strands an agent; safer relay init and token…
khaliqgant 1fc6762
test(cli): use ExitSignal in the workspace create preflight test
khaliqgant 7c598a6
feat(cli): run relay init's server from ~/.agentworkforce, not the np…
khaliqgant e38a418
fix(mcp): send a bound workspace key to its own server
khaliqgant a4784dd
Merge remote-tracking branch 'origin/main' into fix/relaycast-key-url…
khaliqgant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # Quickstart: two agents talking in five commands | ||
|
|
||
| Relay runs the same way in three places. Start on your own machine with no | ||
| account, move to the hosted service when agents on other machines need to | ||
| join, or point at your own server. The commands after `relay init` are the | ||
| same everywhere. | ||
|
|
||
| **You need:** Node.js 22 or 24, and npm. (The local server's SQLite module has no prebuilt binary for newer Node releases yet.) | ||
|
|
||
| ```bash | ||
| npm install -g agent-relay | ||
| ``` | ||
|
|
||
| ## 1. On this machine (no account) | ||
|
|
||
| ```bash | ||
| relay init | ||
| relay agent register alice | ||
| relay agent register bob | ||
| relay message dm send bob "hello" --as alice | ||
| relay message inbox check --as bob | ||
| relay message dm send alice "hi back" --as bob | ||
| ``` | ||
|
|
||
| `inbox check` lists unread messages with their ids and conversation ids. A | ||
| reply is just a DM in the other direction. Mark a message read with | ||
| `relay message inbox mark_read <message-id> --as bob`, and read a whole | ||
| conversation with `relay message dm list <conversation-id> --as bob`. | ||
|
|
||
| `relay init` starts a private Relaycast server on `http://127.0.0.1:8787`, | ||
| stores its data under `~/.agentworkforce/relay/local`. The server itself is | ||
| the standalone `relaycast-engine` in `~/.agentworkforce/relay/bin` when the | ||
| install script put one there, or is installed once under | ||
| `~/.agentworkforce/relay/engine`, and creates a workspace | ||
| called `local`. Nothing leaves your machine and there are no limits. | ||
|
|
||
| `relay agent register` prints the agent's token and also saves it, so | ||
| `--as <name>` works in any shell without exporting anything. If you lose a | ||
| token, run `relay agent rotate <name>` (or `register` again): it issues a new | ||
| one and the old one stops working. | ||
|
|
||
| Stop the server with `relay init --stop`. Run `relay init` again to restart it; | ||
| your workspace and agents are kept. | ||
|
|
||
| ## 2. Across machines (hosted) | ||
|
|
||
| On the first machine: | ||
|
|
||
| ```bash | ||
| relay init --hosted | ||
| ``` | ||
|
|
||
| It creates a hosted workspace and prints one command. Run that command on each | ||
| other machine: | ||
|
|
||
| ```bash | ||
| relay workspace join <name> <key> | ||
| ``` | ||
|
|
||
| Then register agents and send messages exactly as above. Treat the key like a | ||
| password: anyone with it can join the workspace. | ||
|
|
||
| The hosted service has a free tier, enough to try agents across machines. | ||
|
|
||
| ## 3. Your own server (self-hosted) | ||
|
|
||
| Run the Relaycast server ([self-hosting guide](self-hosting/README.md)), create | ||
| a workspace on it, then on each machine: | ||
|
|
||
| ```bash | ||
| relay init --url https://relay.example.com:8443 --key <workspace-key> | ||
| ``` | ||
|
|
||
| Any HTTPS port works. The URL is saved, so later commands need no environment | ||
| variables, and the key is only ever sent to that server: Relay never falls back | ||
| to the hosted service, even if `RELAY_BASE_URL` is unset. If your server uses | ||
| a private certificate authority, set `NODE_EXTRA_CA_CERTS` to its certificate | ||
| file, and keep it set for every `relay` command (for example in your shell | ||
| profile): the CLI does not save it. | ||
|
|
||
| To run coding agents on a node (`agent-relay node up`) against your own server, | ||
| follow the [self-hosting guide](self-hosting/README.md); nodes need extra | ||
| setup today. | ||
|
|
||
| ## Reading delivery status | ||
|
|
||
| A successful send reports `"status": "queued_unconfirmed"`. That is not an | ||
| error: Relay stored the message and it is in the recipient's inbox. "Unconfirmed" | ||
| only means nobody has read it yet. Check with | ||
| `relay message inbox get_readers <message-id>`; once the recipient has read it, | ||
| they are listed there. Do not resend a message just because of this status. | ||
|
|
||
| ## Next | ||
|
|
||
| - Give your coding agents these tools through MCP: `relay mcp`. | ||
| - [Messaging docs](https://agentrelay.com/docs/introduction) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If both
RELAY_WORKSPACE_KEYandRELAY_AGENT_TOKENare set,optionsFromEnvchecks only the key's saved server but sends the token there too. A hosted token alongside a stale self-hosted key previously used hosted; it now goes to the self-hosted server without checking the token's binding. This exposes the token to the wrong server and breaks messaging.Check both credentials against the chosen destination and reject conflicts before creating clients.
How this was verified: The key alone selects
baseUrl, whilegetAgentClientpasses the unchanged token to that URL without another server check.Prompt To Fix With AI