Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
control plane: keep live secrets across deploys, and list only the relay node that exists
milind-sonif9a13b216e2f
diff --git a/cloudflare/control-plane/README.md b/cloudflare/control-plane/README.mdindex 85585cbeb3..940469f7d7 100644--- a/cloudflare/control-plane/README.md+++ b/cloudflare/control-plane/README.md@@ -622,7 +622,8 @@ Setup, once:1. `wrangler d1 migrations apply DB --config wrangler.jsonc` (0012).2. Make a key pair: a 32-byte Ed25519 seed for this Worker, its public key for the relay's `RELAY_TOKEN_KEYS`(`{"k1":"<b64u public key>"}`). `wrangler secret put RELAY_TOKEN_SIGNING_KEY --config wrangler.jsonc` with the seed as- base64url. It is deliberately not in `secrets.required`: until it exists every request answers 503.+ base64url. Until it exists every request answers 503. Once it is set it is listed in `secrets.required`: a deploy+ keeps only the secrets listed there, so an unlisted one is dropped. Set it before deploying a config that lists it.3. Admit the team with `RELAY_ALLOW_INSTALLATIONS`, then raise `RELAY_ROLLOUT_PERCENT` 10, 50, 100 while watching therelay alerts. `RELAY_DISABLED: "1"` turns every token off at once; tokens already issued expire within 12 hours.4. To rotate, give the relay both public keys, set `RELAY_TOKEN_KID` and the new secret, deploy, then drop the old key@@ -660,9 +661,10 @@ Setup, once:On a running Worker, apply 0010 before deploying a Worker built from thiscode: its callback marks the flow in `callback_at`. An older Workerignores the column.-4. `wrangler secret put HIGHLEVEL_CLIENT_SECRET --config wrangler.jsonc`. It is- deliberately not in `secrets.required`: until it exists the routes answer- `503 highlevel_unavailable`.+4. `wrangler secret put HIGHLEVEL_CLIENT_SECRET --config wrangler.jsonc`. Until+ it exists the routes answer `503 highlevel_unavailable`. It is live, so it is+ listed in `secrets.required`: a deploy keeps only the secrets listed there and+ would otherwise drop it.5. `wrangler deploy --config wrangler.jsonc`.A private app stops accepting installs past five external agencies; publish itdiff --git a/cloudflare/control-plane/test/control-plane.test.ts b/cloudflare/control-plane/test/control-plane.test.tsindex 280053f4f4..3e8fbd732f 100644--- a/cloudflare/control-plane/test/control-plane.test.ts+++ b/cloudflare/control-plane/test/control-plane.test.ts@@ -404,6 +404,8 @@ describe("control-plane migrations and health", () => {RELAY_ALLOW_INSTALLATIONS: env.RELAY_ALLOW_INSTALLATIONS,RELAY_DISABLED: env.RELAY_DISABLED,RELAY_CAPABLE_MIN_VERSION: env.RELAY_CAPABLE_MIN_VERSION,+ HIGHLEVEL_CLIENT_SECRET: "",+ RELAY_TOKEN_SIGNING_KEY: "",BETTER_AUTH_SECRET: "too-short",};const request = new Request(`${BASE_URL}/healthz`);diff --git a/cloudflare/control-plane/test/relay.test.ts b/cloudflare/control-plane/test/relay.test.tsindex dbba8c3163..3fce0113f5 100644--- a/cloudflare/control-plane/test/relay.test.ts+++ b/cloudflare/control-plane/test/relay.test.ts@@ -98,8 +98,10 @@ describe("relay host tokens", () => {it("mint a 12 h token for a stable host id, with the node order and the refresh time", async () => {const { credential, id } = await installation("[email protected]");const before = Math.floor(Date.now() / 1000);- const first = await (await ask(relayEnv(), credential)).json<Issued>();- const second = await (await ask(relayEnv(), credential)).json<Issued>();+ // Two nodes, whatever wrangler.jsonc lists today, so the order is still tested.+ const twoNodes = relayEnv({ RELAY_NODES: "relay1.openmausbot.com,relay2.openmausbot.com" });+ const first = await (await ask(twoNodes, credential)).json<Issued>();+ const second = await (await ask(twoNodes, credential)).json<Issued>();expect(second.hostId).toBe(first.hostId);expect(fromB64u(first.hostId)).toHaveLength(16);const { ok, claims } = await verify(first.token, await publicKeyOf(seed));diff --git a/cloudflare/control-plane/wrangler.jsonc b/cloudflare/control-plane/wrangler.jsoncindex 19f872d3aa..bc109d59c2 100644--- a/cloudflare/control-plane/wrangler.jsonc+++ b/cloudflare/control-plane/wrangler.jsonc@@ -65,19 +65,21 @@"OMB_CLEANUP_SWEEP_LIMIT": "20",// HighLevel OAuth relay (README "HighLevel OAuth relay"). The client id// is public (it is in the authorization URL); the secret is- // HIGHLEVEL_CLIENT_SECRET, set with `wrangler secret put` and deliberately- // not in secrets.required: the relay answers 503 highlevel_unavailable- // until it exists. The redirect URL must match the one registered in the- // HighLevel Marketplace app exactly.+ // HIGHLEVEL_CLIENT_SECRET, set with `wrangler secret put`. It is live, so it+ // is in secrets.required: a deploy keeps only the secrets listed there, and+ // an unlisted one is dropped (the relay would then answer 503+ // highlevel_unavailable). The redirect URL must match the one registered in+ // the HighLevel Marketplace app exactly."HIGHLEVEL_CLIENT_ID": "6ad0c3b87999ff4de949c785-mv9n5v73","HIGHLEVEL_REDIRECT_URL": "https://accounts.openmausbot.com/v1/highlevel/callback","HIGHLEVEL_SCOPES": "contacts.readonly contacts.write opportunities.readonly opportunities.write conversations.readonly locations.readonly calendars.readonly calendars/events.readonly users.readonly",// MausBot Relay (README "MausBot Relay"). Host tokens are signed with RELAY_TOKEN_SIGNING_KEY (b64u of a 32-byte- // Ed25519 seed, `wrangler secret put`), deliberately not in secrets.required: until it exists the endpoint answers- // 503 relay_unavailable and desktops stay on Wi-Fi and Tailscale. The relay holds only the matching public key.+ // Ed25519 seed, `wrangler secret put`). It is in secrets.required so a deploy can't drop it: set it before the+ // first deploy that lists it. The relay holds only the matching public key. RELAY_NODES lists only nodes that+ // exist; add relay2 when its box and DNS are up.// RELAY_ROLLOUT_PERCENT (0-100) admits computers by a stable hash of their host id; RELAY_ALLOW_INSTALLATIONS// (comma-separated installation ids) admits a few by name; RELAY_DISABLED "1" turns every token off.- "RELAY_NODES": "relay1.openmausbot.com,relay2.openmausbot.com",+ "RELAY_NODES": "relay1.openmausbot.com","RELAY_NODES_AMERICAS": "","RELAY_TOKEN_KID": "k1","RELAY_ROLLOUT_PERCENT": "0",@@ -88,7 +90,7 @@"RELAY_CAPABLE_MIN_VERSION": ""},"secrets": {- "required": ["BETTER_AUTH_SECRET", "CLOUDFLARE_API_TOKEN", "CLOUDFLARE_API_TOKEN_MAUSBOT_SI"]+ "required": ["BETTER_AUTH_SECRET", "CLOUDFLARE_API_TOKEN", "CLOUDFLARE_API_TOKEN_MAUSBOT_SI", "HIGHLEVEL_CLIENT_SECRET", "RELAY_TOKEN_SIGNING_KEY"]},"d1_databases": [{