hivecode-mcp 0.14.1 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HIVE_RULES.md +98 -98
- package/LICENSE +21 -21
- package/README.md +421 -421
- package/core.js +91 -91
- package/docs/ALWAYS_ON.md +310 -310
- package/docs/GITHUB_WORKFLOW.md +394 -394
- package/docs/HIVE_RULES.md +41 -41
- package/docs/MCP.md +157 -157
- package/docs/QUICKSTART.md +266 -266
- package/docs/SELF_HOSTING.md +256 -256
- package/docs/SLACK_SETUP.md +474 -474
- package/docs/TROUBLESHOOTING.md +105 -105
- package/hive-activity.js +336 -336
- package/hive-authors.js +46 -44
- package/hive-await.js +230 -230
- package/hive-branch.js +608 -607
- package/hive-busy.js +88 -88
- package/hive-coord.js +110 -110
- package/hive-gate.js +135 -135
- package/hive-github.js +3 -1
- package/hive-hook-install.js +179 -179
- package/hive-instructions.js +74 -74
- package/hive-land.js +695 -691
- package/hive-listen.js +81 -81
- package/hive-mailbox.js +520 -520
- package/hive-mcp-http.js +591 -591
- package/hive-mcp.js +33 -6
- package/hive-mux-proto.js +58 -58
- package/hive-mux.js +351 -351
- package/hive-notify.js +234 -233
- package/hive-obligations.js +247 -247
- package/hive-poll-proto.js +50 -50
- package/hive-pr-staleness.js +189 -189
- package/hive-pr.js +600 -512
- package/hive-privacy.js +327 -327
- package/hive-receipts.js +233 -233
- package/hive-relay-health.js +234 -234
- package/hive-repos.js +430 -430
- package/hive-room-key.js +210 -210
- package/hive-room-mode.js +1668 -1668
- package/hive-room-watcher.js +562 -561
- package/hive-secrets.js +89 -89
- package/hive-session.js +114 -114
- package/hive-setup.js +560 -560
- package/hive-slack-agent.js +408 -408
- package/hive-slack.js +2384 -2367
- package/hive-stdio.js +172 -172
- package/hive-stop-hook.js +293 -293
- package/hive-throttle.js +118 -118
- package/hive-time.js +71 -71
- package/hive-transport.js +578 -578
- package/hive-update.js +58 -58
- package/hive-version.js +110 -110
- package/hive-webhook.js +55 -54
- package/icr-merge.js +58 -58
- package/icr.js +851 -851
- package/lang-brace.js +305 -305
- package/lang-js.js +651 -651
- package/lang-json.js +211 -211
- package/lang-python.js +588 -588
- package/lang-ruby.js +230 -230
- package/lang-toml.js +136 -136
- package/lang-yaml.js +183 -183
- package/limits.js +413 -413
- package/package.json +1 -1
- package/reconcile.cjs +621 -621
- package/slack-app-manifest-agent.json +61 -61
- package/slack-app-manifest-inbound.json +36 -36
- package/slack-app-manifest.json +27 -27
- package/substrate.js +252 -252
- package/sync.js +169 -11
- package/token.js +201 -201
package/docs/SELF_HOSTING.md
CHANGED
|
@@ -1,256 +1,256 @@
|
|
|
1
|
-
# Run your own relay
|
|
2
|
-
|
|
3
|
-
Hivecode is **three pieces, and only one of them needs hosting: the relay.** Run that one
|
|
4
|
-
server and your team's source never reaches a machine you do not own.
|
|
5
|
-
|
|
6
|
-
This is the supported path for any team that cannot send its code to a third party. It is
|
|
7
|
-
also the only path that does not depend on somebody else's uptime.
|
|
8
|
-
|
|
9
|
-
For the click-by-click cloud deploy see [DEPLOY.md](DEPLOY.md). For how it all works under
|
|
10
|
-
the hood see [ARCHITECTURE.md](ARCHITECTURE.md). For tokens and scopes see [RBAC.md](RBAC.md).
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
> **You install one package, not a repository.** `npx hivecode-relay` downloads the relay and
|
|
15
|
-
> nothing else — no agent client, no editor extension, no test suite, no build tooling. It is a
|
|
16
|
-
> separate npm package from `hivecode-mcp`, which is what your developers and agents install.
|
|
17
|
-
|
|
18
|
-
## What you actually host
|
|
19
|
-
|
|
20
|
-
Only the relay. It is plain Node with no native dependencies, it holds **no canonical copy
|
|
21
|
-
of your code**, and it never writes your files to disk unless you turn persistence on (which
|
|
22
|
-
you should — see below). It passes CRDT updates between clients in the same room and enforces
|
|
23
|
-
access at the handshake. The editor extension and the agent MCP server run on each
|
|
24
|
-
participant's own machine.
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
You host ONE relay ─────► wss://your-relay.example.com
|
|
28
|
-
▲ ▲ ▲
|
|
29
|
-
humans humans AI agents
|
|
30
|
-
(VS Code) (VS Code) (MCP)
|
|
31
|
-
all pointed at your relay
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## Step 1 — Start the relay
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npx hivecode-relay
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
That is the whole command. It starts the relay with **persistence on**, prints the join link,
|
|
43
|
-
and prints the exact settings each teammate needs. Useful flags:
|
|
44
|
-
|
|
45
|
-
| Flag | Default | What it does |
|
|
46
|
-
|---|---|---|
|
|
47
|
-
| `--port 1234` | `1234` | Port to listen on. |
|
|
48
|
-
| `--data ./hive-data` | `./hive-data` | Where rooms are persisted. |
|
|
49
|
-
| `--room my-project` | random | Print the link for a named room instead of a random one. |
|
|
50
|
-
| `--secret <string>` | none | Turn on **auth-required** mode: only holders of a minted token may connect. |
|
|
51
|
-
| `--seats 25` | `25` | Connection budget. See *How much can one relay handle?* below. |
|
|
52
|
-
|
|
53
|
-
Three ways to run it, in increasing order of "a real team depends on this":
|
|
54
|
-
|
|
55
|
-
**A. On a laptop or a box on your LAN.** `npx hivecode-relay`, hand out the `ws://192.168.x.x:1234`
|
|
56
|
-
address it prints. Good for a trial, a workshop, or a co-located team. It is **not encrypted**
|
|
57
|
-
— fine inside a network you trust, not fine across the internet.
|
|
58
|
-
|
|
59
|
-
**B. On your own server, behind TLS.** Run it behind a reverse proxy that terminates TLS and
|
|
60
|
-
upgrades WebSockets, and hand out the `wss://` address. This is the normal production shape.
|
|
61
|
-
|
|
62
|
-
**C. On a container host.** The included [`Dockerfile`](../Dockerfile) works on Fly.io, Railway,
|
|
63
|
-
Render, Cloud Run or anything else that runs containers. [`render.yaml`](../render.yaml) makes
|
|
64
|
-
Render one-click; the walkthrough is in [DEPLOY.md](DEPLOY.md).
|
|
65
|
-
|
|
66
|
-
You deploy once. After that it stays up.
|
|
67
|
-
|
|
68
|
-
### A remote team, keeping it private
|
|
69
|
-
|
|
70
|
-
A relay on a laptop is reachable only from that network. For teammates in other places there
|
|
71
|
-
are three real options, and they are **not** equally private:
|
|
72
|
-
|
|
73
|
-
| Option | Private? | Stays up? | Setup |
|
|
74
|
-
|---|---|---|---|
|
|
75
|
-
| **Private network (Tailscale or similar)** — relay on any team machine, teammates join the same private network and use its `100.x.y.z` or `*.ts.net` address | **Yes.** WireGuard end to end; nothing outside the network can even reach the relay | Only while that machine is on | Each person installs the app and logs in once |
|
|
76
|
-
| **Your own server** — a small cloud VM or office box in *your* account, TLS terminated on it | **Yes.** You run every machine the traffic touches | Yes | One-time server setup |
|
|
77
|
-
| **Public tunnel** (`cloudflared tunnel --url http://localhost:1234`, ngrok) | **No.** The tunnel provider decrypts traffic at its edge, and the URL is public | Only while the laptop is on; quick tunnels get a new URL every restart | One command |
|
|
78
|
-
|
|
79
|
-
A public tunnel works — verified end to end: two clients synced a file through a Cloudflare
|
|
80
|
-
quick tunnel, and a client holding the URL but no token was refused. Use it for a trial, and
|
|
81
|
-
**always with `--secret`**, because a public URL on an open relay is an open room. `hive_status`
|
|
82
|
-
says so on every join: `YOUR RELAY — through a public tunnel`.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## Step 2 — Point EVERY client at it
|
|
87
|
-
|
|
88
|
-
This is the step teams get half-right, so it is worth being blunt about what "half-right"
|
|
89
|
-
costs. There are two kinds of client and they read two different settings:
|
|
90
|
-
|
|
91
|
-
| Client | Setting | Where |
|
|
92
|
-
|---|---|---|
|
|
93
|
-
| **Human** (VS Code) | `hivecode.relayUrl` | VS Code settings |
|
|
94
|
-
| **AI agent** (MCP) | `HIVE_RELAY` | the `env` block of the agent's MCP server config |
|
|
95
|
-
|
|
96
|
-
**If you set one and forget the other, nothing fails.** The agent falls back to the public
|
|
97
|
-
relay this build ships as a default, joins a room with the same name, reports `connected`,
|
|
98
|
-
and publishes your files there. Your humans are on your relay, your agent is on ours, and
|
|
99
|
-
every status line on both sides is green.
|
|
100
|
-
|
|
101
|
-
So set the pin as well:
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
HIVE_RELAY_PIN = wss://your-relay.example.com
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
`HIVE_RELAY` is a *default*. `HIVE_RELAY_PIN` is a *rule*: this machine may only ever talk
|
|
108
|
-
to these relays, and any attempt to connect anywhere else is refused **before the socket
|
|
109
|
-
opens**, with error **Q550**, having published nothing. Set it on every machine — humans'
|
|
110
|
-
and agents' alike — and a stale link, a typo'd host or a forgotten environment variable
|
|
111
|
-
becomes a loud refusal instead of a silent upload.
|
|
112
|
-
|
|
113
|
-
Two more knobs:
|
|
114
|
-
|
|
115
|
-
- `HIVE_RELAY_PIN` accepts a comma-separated list, for teams with a staging relay and a
|
|
116
|
-
production one.
|
|
117
|
-
- `HIVE_PRIVATE=1` refuses the shipped public default (**Q551**) even when no pin is set.
|
|
118
|
-
Use it as a belt-and-braces setting on a machine that must never reach our relay.
|
|
119
|
-
|
|
120
|
-
A pin that cannot be parsed is **refused (Q552)**, never ignored. A typo that silently
|
|
121
|
-
degraded to "no pin" would leave you believing a machine was locked down when it was not.
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Step 3 — Create a room and invite people
|
|
126
|
-
|
|
127
|
-
A connection is encoded as a **join link**:
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
wss://your-relay.example.com|room-myproject
|
|
131
|
-
└──── your relay ────┘ └──── room id ────┘
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
1. `npx hivecode-relay --room myproject` prints the link.
|
|
135
|
-
2. Share it with teammates and agents.
|
|
136
|
-
3. **Humans** run **Hivecode: Join a Session** in VS Code and paste it.
|
|
137
|
-
4. **Agents** get it as the `link` argument to `hive_join`.
|
|
138
|
-
5. Same link = same room = one live codebase for everyone.
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## Step 4 — Add AI agents
|
|
143
|
-
|
|
144
|
-
Agents join through the MCP server. Register it once in the agent's host (Claude Code,
|
|
145
|
-
Cursor, Windsurf, or your own bot):
|
|
146
|
-
|
|
147
|
-
```json
|
|
148
|
-
{
|
|
149
|
-
"mcpServers": {
|
|
150
|
-
"hivecode": {
|
|
151
|
-
"command": "npx",
|
|
152
|
-
"args": ["-y", "hivecode-mcp@latest"],
|
|
153
|
-
"env": {
|
|
154
|
-
"HIVE_RELAY": "wss://your-relay.example.com",
|
|
155
|
-
"HIVE_RELAY_PIN": "wss://your-relay.example.com"
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
Then hand it the join link. It appears in the room as an `ai` member, scoped to exactly the
|
|
163
|
-
folders you invited it to. See [JOIN_WITH_AGENT.md](JOIN_WITH_AGENT.md) and [MCP.md](MCP.md).
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## Step 5 — Check that it is actually private
|
|
168
|
-
|
|
169
|
-
Do not take a green join as evidence. Two checks, thirty seconds:
|
|
170
|
-
|
|
171
|
-
**1. Ask each client where it is.** `hive_status` reports a `privacy` field next to
|
|
172
|
-
`connected`:
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
privacy: "PRIVATE — relay on your network" ← yours
|
|
176
|
-
privacy: "PUBLIC RELAY — not yours" ← ours. Your files are on our server.
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
A human client shows the same thing in the join banner: `relay: <url> [VERDICT]`.
|
|
180
|
-
|
|
181
|
-
**2. Ask your relay who is on it.** `curl http://your-relay:1234/health` reports
|
|
182
|
-
`connections` and `rooms`. The number of connections should account for everybody. If a
|
|
183
|
-
teammate says they are in the room and your relay's count did not move, they are in
|
|
184
|
-
*a* room — just not on your relay.
|
|
185
|
-
|
|
186
|
-
You can prove the whole path on your own machine in about a minute, from a clone of the repo:
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
node tests/self-host-test.mjs
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
That suite starts a real relay, syncs a real file between two real clients through it,
|
|
193
|
-
asserts the relay's own counters moved, and asserts that a pinned client refuses the public
|
|
194
|
-
relay. It is the evidence behind every claim on this page.
|
|
195
|
-
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
## Step 6 — Lock it down before you invite anyone real
|
|
199
|
-
|
|
200
|
-
| Env var | Why you want it |
|
|
201
|
-
|---|---|
|
|
202
|
-
| `HIVE_AUTH_MODE=required` + `HIVE_JWT_SECRET=<secret>` | Every connection must present a valid token. This is your invite-only control. `npx hivecode-relay --secret <secret>` sets both. Mint tokens with `npx hivecode-token --room <room> --name <who> --role writer --ttl 7d` on the relay host, which is the only machine that holds the secret. See [RBAC.md](RBAC.md). |
|
|
203
|
-
| `HIVE_PERSIST_DIR=/var/data/hive` | **Important.** Without it a room lives only in connected clients' memory and is **lost the moment everyone disconnects** — the day works perfectly and the folder is empty in the morning. `npx hivecode-relay` turns this on by default; running the relay from a clone of the repo (`node server.js`) does not. |
|
|
204
|
-
| `HIVE_SEATS=<n>` | Per-room connection budget (8 per seat). It does **not** raise the whole-relay total — that is `HIVE_MAX_CONNS_TOTAL`. The free-tier ceiling is 8 per room, which is **not** 8 people — see below. |
|
|
205
|
-
| `HIVE_AUDIT_FILE=./audit.log` | One line per admit and reject. This is your evidence of who connected and when. |
|
|
206
|
-
| `HIVE_RELAY_MUX=off` | Turns off one-socket-per-participant mode. It is on by default; this is the kill switch, and clients already connected fall back to one socket per file by themselves. |
|
|
207
|
-
| `RENDER_EXTERNAL_URL` (auto on Render) | Keeps a free-tier host warm so the first join is not a 30-second cold start. |
|
|
208
|
-
|
|
209
|
-
> ⚠️ **An open relay on a public IP is a public relay.** Without `HIVE_AUTH_MODE=required`,
|
|
210
|
-
> anyone who can reach the port and guesses a room id can read and write your files. On a
|
|
211
|
-
> laptop or a private LAN that is a reasonable trade. On a public IP it is not.
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## How much can one relay handle?
|
|
216
|
-
|
|
217
|
-
**Count sockets and open files, not people.** A current client holds **two sockets** — one for
|
|
218
|
-
the room, one carrying all of its files — and each open file is a channel on the second.
|
|
219
|
-
Clients on the older transport (the VS Code extension, the browser panel, `HIVE_MUX=0`, or any
|
|
220
|
-
client against a relay that predates this) still hold one base-room socket **plus one per open
|
|
221
|
-
file**, up to `1 + HIVE_MAX_OPEN_FILES` (default 128) each.
|
|
222
|
-
|
|
223
|
-
Two different ceilings refuse you, with two different remedies:
|
|
224
|
-
|
|
225
|
-
| You see | Meaning | Fix |
|
|
226
|
-
|---|---|---|
|
|
227
|
-
| **Q430** (503) | the whole relay is at `maxConnsTotal` (default 2048, ~56 KB of memory each) | `HIVE_MAX_CONNS_TOTAL` — **`HIVE_SEATS` does not help here** |
|
|
228
|
-
| **Q431** (429) | one room is at its per-room cap | `HIVE_SEATS` |
|
|
229
|
-
| **Q438** (503) | open files across all participants are at `HIVE_MAX_CHANNELS_TOTAL` (default 8,192; ~25.8 KB each unshared, ~2.4 KB per extra participant) | `HIVE_MAX_CHANNELS_TOTAL`, with the memory to match |
|
|
230
|
-
|
|
231
|
-
- **A focused team (~10 humans and their agents in one room): comfortably**, on a small
|
|
232
|
-
always-on instance (≈1 vCPU / 1–2 GB). Free tiers are fine for a trial.
|
|
233
|
-
- **Hundreds of concurrent users across many rooms:** scale the instance up, or — the natural
|
|
234
|
-
model — let each team run its own relay so the load distributes.
|
|
235
|
-
|
|
236
|
-
Two operational rules:
|
|
237
|
-
|
|
238
|
-
1. **Turn on persistence** before real users join.
|
|
239
|
-
2. **Do not redeploy the relay while people are working** — a restart drops everyone. Deploy
|
|
240
|
-
from a stable tag, off-hours.
|
|
241
|
-
|
|
242
|
-
---
|
|
243
|
-
|
|
244
|
-
## What self-hosting does not give you
|
|
245
|
-
|
|
246
|
-
Said plainly, because discovering it later is worse:
|
|
247
|
-
|
|
248
|
-
- **Uptime is yours.** Nobody is paged when your box dies at 2am.
|
|
249
|
-
- **`ws://` is plaintext.** Self-hosting is not encryption. Put TLS in front of it.
|
|
250
|
-
- **An open relay is open.** Running it yourself controls *where* the bytes go, not *who*
|
|
251
|
-
may fetch them. That is what `HIVE_AUTH_MODE=required` is for.
|
|
252
|
-
- **Path scoping needs auth mode.** The `--paths` globs in a token are only enforced when the
|
|
253
|
-
relay runs in `required` mode. On an open relay every token is ignored, so a "scoped" agent
|
|
254
|
-
gets the whole room.
|
|
255
|
-
- **Mixed client versions do not sync.** Everyone on the relay must be on the same Hivecode
|
|
256
|
-
version; announce yours on join.
|
|
1
|
+
# Run your own relay
|
|
2
|
+
|
|
3
|
+
Hivecode is **three pieces, and only one of them needs hosting: the relay.** Run that one
|
|
4
|
+
server and your team's source never reaches a machine you do not own.
|
|
5
|
+
|
|
6
|
+
This is the supported path for any team that cannot send its code to a third party. It is
|
|
7
|
+
also the only path that does not depend on somebody else's uptime.
|
|
8
|
+
|
|
9
|
+
For the click-by-click cloud deploy see [DEPLOY.md](DEPLOY.md). For how it all works under
|
|
10
|
+
the hood see [ARCHITECTURE.md](ARCHITECTURE.md). For tokens and scopes see [RBAC.md](RBAC.md).
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
> **You install one package, not a repository.** `npx hivecode-relay` downloads the relay and
|
|
15
|
+
> nothing else — no agent client, no editor extension, no test suite, no build tooling. It is a
|
|
16
|
+
> separate npm package from `hivecode-mcp`, which is what your developers and agents install.
|
|
17
|
+
|
|
18
|
+
## What you actually host
|
|
19
|
+
|
|
20
|
+
Only the relay. It is plain Node with no native dependencies, it holds **no canonical copy
|
|
21
|
+
of your code**, and it never writes your files to disk unless you turn persistence on (which
|
|
22
|
+
you should — see below). It passes CRDT updates between clients in the same room and enforces
|
|
23
|
+
access at the handshake. The editor extension and the agent MCP server run on each
|
|
24
|
+
participant's own machine.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
You host ONE relay ─────► wss://your-relay.example.com
|
|
28
|
+
▲ ▲ ▲
|
|
29
|
+
humans humans AI agents
|
|
30
|
+
(VS Code) (VS Code) (MCP)
|
|
31
|
+
all pointed at your relay
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Step 1 — Start the relay
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx hivecode-relay
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
That is the whole command. It starts the relay with **persistence on**, prints the join link,
|
|
43
|
+
and prints the exact settings each teammate needs. Useful flags:
|
|
44
|
+
|
|
45
|
+
| Flag | Default | What it does |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `--port 1234` | `1234` | Port to listen on. |
|
|
48
|
+
| `--data ./hive-data` | `./hive-data` | Where rooms are persisted. |
|
|
49
|
+
| `--room my-project` | random | Print the link for a named room instead of a random one. |
|
|
50
|
+
| `--secret <string>` | none | Turn on **auth-required** mode: only holders of a minted token may connect. |
|
|
51
|
+
| `--seats 25` | `25` | Connection budget. See *How much can one relay handle?* below. |
|
|
52
|
+
|
|
53
|
+
Three ways to run it, in increasing order of "a real team depends on this":
|
|
54
|
+
|
|
55
|
+
**A. On a laptop or a box on your LAN.** `npx hivecode-relay`, hand out the `ws://192.168.x.x:1234`
|
|
56
|
+
address it prints. Good for a trial, a workshop, or a co-located team. It is **not encrypted**
|
|
57
|
+
— fine inside a network you trust, not fine across the internet.
|
|
58
|
+
|
|
59
|
+
**B. On your own server, behind TLS.** Run it behind a reverse proxy that terminates TLS and
|
|
60
|
+
upgrades WebSockets, and hand out the `wss://` address. This is the normal production shape.
|
|
61
|
+
|
|
62
|
+
**C. On a container host.** The included [`Dockerfile`](../Dockerfile) works on Fly.io, Railway,
|
|
63
|
+
Render, Cloud Run or anything else that runs containers. [`render.yaml`](../render.yaml) makes
|
|
64
|
+
Render one-click; the walkthrough is in [DEPLOY.md](DEPLOY.md).
|
|
65
|
+
|
|
66
|
+
You deploy once. After that it stays up.
|
|
67
|
+
|
|
68
|
+
### A remote team, keeping it private
|
|
69
|
+
|
|
70
|
+
A relay on a laptop is reachable only from that network. For teammates in other places there
|
|
71
|
+
are three real options, and they are **not** equally private:
|
|
72
|
+
|
|
73
|
+
| Option | Private? | Stays up? | Setup |
|
|
74
|
+
|---|---|---|---|
|
|
75
|
+
| **Private network (Tailscale or similar)** — relay on any team machine, teammates join the same private network and use its `100.x.y.z` or `*.ts.net` address | **Yes.** WireGuard end to end; nothing outside the network can even reach the relay | Only while that machine is on | Each person installs the app and logs in once |
|
|
76
|
+
| **Your own server** — a small cloud VM or office box in *your* account, TLS terminated on it | **Yes.** You run every machine the traffic touches | Yes | One-time server setup |
|
|
77
|
+
| **Public tunnel** (`cloudflared tunnel --url http://localhost:1234`, ngrok) | **No.** The tunnel provider decrypts traffic at its edge, and the URL is public | Only while the laptop is on; quick tunnels get a new URL every restart | One command |
|
|
78
|
+
|
|
79
|
+
A public tunnel works — verified end to end: two clients synced a file through a Cloudflare
|
|
80
|
+
quick tunnel, and a client holding the URL but no token was refused. Use it for a trial, and
|
|
81
|
+
**always with `--secret`**, because a public URL on an open relay is an open room. `hive_status`
|
|
82
|
+
says so on every join: `YOUR RELAY — through a public tunnel`.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Step 2 — Point EVERY client at it
|
|
87
|
+
|
|
88
|
+
This is the step teams get half-right, so it is worth being blunt about what "half-right"
|
|
89
|
+
costs. There are two kinds of client and they read two different settings:
|
|
90
|
+
|
|
91
|
+
| Client | Setting | Where |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| **Human** (VS Code) | `hivecode.relayUrl` | VS Code settings |
|
|
94
|
+
| **AI agent** (MCP) | `HIVE_RELAY` | the `env` block of the agent's MCP server config |
|
|
95
|
+
|
|
96
|
+
**If you set one and forget the other, nothing fails.** The agent falls back to the public
|
|
97
|
+
relay this build ships as a default, joins a room with the same name, reports `connected`,
|
|
98
|
+
and publishes your files there. Your humans are on your relay, your agent is on ours, and
|
|
99
|
+
every status line on both sides is green.
|
|
100
|
+
|
|
101
|
+
So set the pin as well:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
HIVE_RELAY_PIN = wss://your-relay.example.com
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`HIVE_RELAY` is a *default*. `HIVE_RELAY_PIN` is a *rule*: this machine may only ever talk
|
|
108
|
+
to these relays, and any attempt to connect anywhere else is refused **before the socket
|
|
109
|
+
opens**, with error **Q550**, having published nothing. Set it on every machine — humans'
|
|
110
|
+
and agents' alike — and a stale link, a typo'd host or a forgotten environment variable
|
|
111
|
+
becomes a loud refusal instead of a silent upload.
|
|
112
|
+
|
|
113
|
+
Two more knobs:
|
|
114
|
+
|
|
115
|
+
- `HIVE_RELAY_PIN` accepts a comma-separated list, for teams with a staging relay and a
|
|
116
|
+
production one.
|
|
117
|
+
- `HIVE_PRIVATE=1` refuses the shipped public default (**Q551**) even when no pin is set.
|
|
118
|
+
Use it as a belt-and-braces setting on a machine that must never reach our relay.
|
|
119
|
+
|
|
120
|
+
A pin that cannot be parsed is **refused (Q552)**, never ignored. A typo that silently
|
|
121
|
+
degraded to "no pin" would leave you believing a machine was locked down when it was not.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Step 3 — Create a room and invite people
|
|
126
|
+
|
|
127
|
+
A connection is encoded as a **join link**:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
wss://your-relay.example.com|room-myproject
|
|
131
|
+
└──── your relay ────┘ └──── room id ────┘
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
1. `npx hivecode-relay --room myproject` prints the link.
|
|
135
|
+
2. Share it with teammates and agents.
|
|
136
|
+
3. **Humans** run **Hivecode: Join a Session** in VS Code and paste it.
|
|
137
|
+
4. **Agents** get it as the `link` argument to `hive_join`.
|
|
138
|
+
5. Same link = same room = one live codebase for everyone.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Step 4 — Add AI agents
|
|
143
|
+
|
|
144
|
+
Agents join through the MCP server. Register it once in the agent's host (Claude Code,
|
|
145
|
+
Cursor, Windsurf, or your own bot):
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"mcpServers": {
|
|
150
|
+
"hivecode": {
|
|
151
|
+
"command": "npx",
|
|
152
|
+
"args": ["-y", "hivecode-mcp@latest"],
|
|
153
|
+
"env": {
|
|
154
|
+
"HIVE_RELAY": "wss://your-relay.example.com",
|
|
155
|
+
"HIVE_RELAY_PIN": "wss://your-relay.example.com"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Then hand it the join link. It appears in the room as an `ai` member, scoped to exactly the
|
|
163
|
+
folders you invited it to. See [JOIN_WITH_AGENT.md](JOIN_WITH_AGENT.md) and [MCP.md](MCP.md).
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Step 5 — Check that it is actually private
|
|
168
|
+
|
|
169
|
+
Do not take a green join as evidence. Two checks, thirty seconds:
|
|
170
|
+
|
|
171
|
+
**1. Ask each client where it is.** `hive_status` reports a `privacy` field next to
|
|
172
|
+
`connected`:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
privacy: "PRIVATE — relay on your network" ← yours
|
|
176
|
+
privacy: "PUBLIC RELAY — not yours" ← ours. Your files are on our server.
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
A human client shows the same thing in the join banner: `relay: <url> [VERDICT]`.
|
|
180
|
+
|
|
181
|
+
**2. Ask your relay who is on it.** `curl http://your-relay:1234/health` reports
|
|
182
|
+
`connections` and `rooms`. The number of connections should account for everybody. If a
|
|
183
|
+
teammate says they are in the room and your relay's count did not move, they are in
|
|
184
|
+
*a* room — just not on your relay.
|
|
185
|
+
|
|
186
|
+
You can prove the whole path on your own machine in about a minute, from a clone of the repo:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
node tests/self-host-test.mjs
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
That suite starts a real relay, syncs a real file between two real clients through it,
|
|
193
|
+
asserts the relay's own counters moved, and asserts that a pinned client refuses the public
|
|
194
|
+
relay. It is the evidence behind every claim on this page.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Step 6 — Lock it down before you invite anyone real
|
|
199
|
+
|
|
200
|
+
| Env var | Why you want it |
|
|
201
|
+
|---|---|
|
|
202
|
+
| `HIVE_AUTH_MODE=required` + `HIVE_JWT_SECRET=<secret>` | Every connection must present a valid token. This is your invite-only control. `npx hivecode-relay --secret <secret>` sets both. Mint tokens with `npx hivecode-token --room <room> --name <who> --role writer --ttl 7d` on the relay host, which is the only machine that holds the secret. See [RBAC.md](RBAC.md). |
|
|
203
|
+
| `HIVE_PERSIST_DIR=/var/data/hive` | **Important.** Without it a room lives only in connected clients' memory and is **lost the moment everyone disconnects** — the day works perfectly and the folder is empty in the morning. `npx hivecode-relay` turns this on by default; running the relay from a clone of the repo (`node server.js`) does not. |
|
|
204
|
+
| `HIVE_SEATS=<n>` | Per-room connection budget (8 per seat). It does **not** raise the whole-relay total — that is `HIVE_MAX_CONNS_TOTAL`. The free-tier ceiling is 8 per room, which is **not** 8 people — see below. |
|
|
205
|
+
| `HIVE_AUDIT_FILE=./audit.log` | One line per admit and reject. This is your evidence of who connected and when. |
|
|
206
|
+
| `HIVE_RELAY_MUX=off` | Turns off one-socket-per-participant mode. It is on by default; this is the kill switch, and clients already connected fall back to one socket per file by themselves. |
|
|
207
|
+
| `RENDER_EXTERNAL_URL` (auto on Render) | Keeps a free-tier host warm so the first join is not a 30-second cold start. |
|
|
208
|
+
|
|
209
|
+
> ⚠️ **An open relay on a public IP is a public relay.** Without `HIVE_AUTH_MODE=required`,
|
|
210
|
+
> anyone who can reach the port and guesses a room id can read and write your files. On a
|
|
211
|
+
> laptop or a private LAN that is a reasonable trade. On a public IP it is not.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## How much can one relay handle?
|
|
216
|
+
|
|
217
|
+
**Count sockets and open files, not people.** A current client holds **two sockets** — one for
|
|
218
|
+
the room, one carrying all of its files — and each open file is a channel on the second.
|
|
219
|
+
Clients on the older transport (the VS Code extension, the browser panel, `HIVE_MUX=0`, or any
|
|
220
|
+
client against a relay that predates this) still hold one base-room socket **plus one per open
|
|
221
|
+
file**, up to `1 + HIVE_MAX_OPEN_FILES` (default 128) each.
|
|
222
|
+
|
|
223
|
+
Two different ceilings refuse you, with two different remedies:
|
|
224
|
+
|
|
225
|
+
| You see | Meaning | Fix |
|
|
226
|
+
|---|---|---|
|
|
227
|
+
| **Q430** (503) | the whole relay is at `maxConnsTotal` (default 2048, ~56 KB of memory each) | `HIVE_MAX_CONNS_TOTAL` — **`HIVE_SEATS` does not help here** |
|
|
228
|
+
| **Q431** (429) | one room is at its per-room cap | `HIVE_SEATS` |
|
|
229
|
+
| **Q438** (503) | open files across all participants are at `HIVE_MAX_CHANNELS_TOTAL` (default 8,192; ~25.8 KB each unshared, ~2.4 KB per extra participant) | `HIVE_MAX_CHANNELS_TOTAL`, with the memory to match |
|
|
230
|
+
|
|
231
|
+
- **A focused team (~10 humans and their agents in one room): comfortably**, on a small
|
|
232
|
+
always-on instance (≈1 vCPU / 1–2 GB). Free tiers are fine for a trial.
|
|
233
|
+
- **Hundreds of concurrent users across many rooms:** scale the instance up, or — the natural
|
|
234
|
+
model — let each team run its own relay so the load distributes.
|
|
235
|
+
|
|
236
|
+
Two operational rules:
|
|
237
|
+
|
|
238
|
+
1. **Turn on persistence** before real users join.
|
|
239
|
+
2. **Do not redeploy the relay while people are working** — a restart drops everyone. Deploy
|
|
240
|
+
from a stable tag, off-hours.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## What self-hosting does not give you
|
|
245
|
+
|
|
246
|
+
Said plainly, because discovering it later is worse:
|
|
247
|
+
|
|
248
|
+
- **Uptime is yours.** Nobody is paged when your box dies at 2am.
|
|
249
|
+
- **`ws://` is plaintext.** Self-hosting is not encryption. Put TLS in front of it.
|
|
250
|
+
- **An open relay is open.** Running it yourself controls *where* the bytes go, not *who*
|
|
251
|
+
may fetch them. That is what `HIVE_AUTH_MODE=required` is for.
|
|
252
|
+
- **Path scoping needs auth mode.** The `--paths` globs in a token are only enforced when the
|
|
253
|
+
relay runs in `required` mode. On an open relay every token is ignored, so a "scoped" agent
|
|
254
|
+
gets the whole room.
|
|
255
|
+
- **Mixed client versions do not sync.** Everyone on the relay must be on the same Hivecode
|
|
256
|
+
version; announce yours on join.
|