Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
fix(host): stop saving which cloud a host uses
leepokaib8515d49a61e
diff --git a/apps/desktop/src/renderer/store/cloud.ts b/apps/desktop/src/renderer/store/cloud.tsindex 9b18d333..96c29773 100644--- a/apps/desktop/src/renderer/store/cloud.ts+++ b/apps/desktop/src/renderer/store/cloud.ts@@ -243,11 +243,9 @@ export class CloudModel extends Observable {}}- /** A host without a cloud URL of its own gets this app's. */+ /** The host's cloud comes with its build; this only turns it on. */private async enableCloud(store: BotStore) {- const url = store.cloud?.url ? null : account.cloudURL- if (!store.cloud?.url && !url) throw new CloudError(400, 'badRequest', 'This build of Codync has no cloud to connect to.')- return (await store.ready()).call<CloudStatus>('setCloud', { enabled: true, url }, 30_000)+ return (await store.ready()).call<CloudStatus>('setCloud', { enabled: true }, 30_000)}async removeFromAccount(computerId: string) {diff --git a/docs/guides/accounts-and-ssh.md b/docs/guides/accounts-and-ssh.mdindex de9c4fcf..28dc8744 100644--- a/docs/guides/accounts-and-ssh.md+++ b/docs/guides/accounts-and-ssh.md@@ -189,7 +189,7 @@ directly (the encrypted channel wasn't ported to the desktop app), so their"Ask for access" rows show status only. See [desktop app](../architecture/desktop-app.md).**Computers & devices** (Settings) shows, for this computer and each SSH computer:-*Reach from anywhere* (`setCloud`, using the app's `cloudURL` when the host has none),+*Reach from anywhere* (`setCloud`, on/off; the host's build decides which cloud),*Add to account* (claim: `POST /v1/claims` → loopback `claimSign` → complete) and*Remove from account* (`unclaim`), a pairing QR, and the authorized devices with revoke.A device asking for access raises the menu bar dot and opens the approval sheet with thediff --git a/docs/guides/environments-and-deployment.md b/docs/guides/environments-and-deployment.mdindex 82d7204e..22dce365 100644--- a/docs/guides/environments-and-deployment.md+++ b/docs/guides/environments-and-deployment.md@@ -8,11 +8,11 @@ Reviewed against repository configuration on 2026-09-26. Checked-in configuratio| --- | --- | --- || Apple app | `apps/shared/Config/dev.plist`, `main.plist` | `project.yml` copies the selected file to bundled `AccountConfig.plist`; Debug uses dev, Release uses main || Account SDK | `apps/shared/AccountSession.swift` | Public Clerk configuration; development environment overrides are supported |-| Host | `host/src/remote/cloud.rs` | `CODYNC_CLOUD=off` or stored disable wins; then `CODYNC_CLOUD_URL`, stored URL, compiled default |+| Host | `host/src/remote/cloud.rs` | `CODYNC_CLOUD=off` or stored disable wins; then `CODYNC_CLOUD_URL`, then the build's cloud (`CODYNC_ENV` at compile time) || Cloud Worker / D1 / DO | `cloud/wrangler.toml` | Root production, `dev`, or `local` environment || APNs Worker | `relay/wrangler.toml` | Separate deployment and secrets; see [relay README](../../relay/README.md) |-The host's compiled default is dev (`https://dev-api.codync.dev`) for every local build, debug or release; only the release workflows build with `CODYNC_ENV=main` and get `https://api.codync.dev`. Local builds of every client are dev (iOS Debug, desktop `account-config.mjs dev`, any `cargo build`), and main is built only by CI, so they never mix. Override it with the Mac's **Reach from anywhere** control or `codync-host cloud --url <url>`. `codync-host cloud` displays status; `--disable` turns access off. App and host must point at the same intended cloud.+The environment is chosen when building, never stored: the host compiles in its cloud from `CODYNC_ENV` (`main` → `https://api.codync.dev`, unset or anything else → `https://dev-api.codync.dev`, debug or release alike), and the only cloud setting a host saves is on/off (**Reach from anywhere**, `codync-host cloud --enable|--disable`). `CODYNC_CLOUD_URL` points a host at a cloud you're developing (https, or http to this computer). Build the host with the same environment as the app next to it; the release workflows set `CODYNC_ENV=main`.## Checked-in readinessdiff --git a/docs/guides/linux-servers.md b/docs/guides/linux-servers.mdindex caa67a95..30f00168 100644--- a/docs/guides/linux-servers.md+++ b/docs/guides/linux-servers.md@@ -35,7 +35,7 @@ Other commands work the same as on a desktop: `codync-host pair`, `codync-host tThe phone connects over the encrypted device channel. The pairing link lists only **Tailscale** and **private (LAN/VPC)** addresses; the host never advertises a public IP.- **Tailscale (recommended for VMs):** install Tailscale on the VM and on the phone, then `codync-host pair`. The Tailscale name comes first in the link. You don't need to open port 19222 in the cloud firewall.-- **Cloudflare cloud:** `codync-host cloud --url https://…` if you run your own Codync cloud. The production cloud isn't live yet (see [environments](environments-and-deployment.md)).+- **Cloudflare cloud:** start the host with `CODYNC_CLOUD_URL=https://…` if you run your own Codync cloud. The production cloud isn't live yet (see [environments](environments-and-deployment.md)).- **Desktop app over SSH:** the desktop app (macOS or Linux) can attach an SSH computer and tunnel to its loopback API ([Accounts and SSH](accounts-and-ssh.md)). From any terminal: `ssh -L 19222:127.0.0.1:19222 vm`, then `codync-host tui` locally.The host listens on `0.0.0.0:19222`. The local API (`/api/*`, `/events`, terminals; bearer token) answers **loopback callers only**, so a public address never exposes it. From outside, only `/health` (host id, computer id, version) and the end-to-end encrypted device channel answer, and the channel only serves devices holding this host's pairing keys. Keep 19222 closed in the cloud firewall anyway unless you deliberately pair over a VPN or private network.diff --git a/host/src/api/mod.rs b/host/src/api/mod.rsindex 70bb2b6d..5e395b2f 100644--- a/host/src/api/mod.rs+++ b/host/src/api/mod.rs@@ -743,7 +743,7 @@ pub async fn dispatch(hub: &Arc<Hub>, caller: &Caller, method: &str, b: Value) -"cloudStatus" => serde_json::to_value(hub.cloud.status())?,"setCloud" => {let enabled = b["enabled"].as_bool().ok_or_else(|| anyhow!("`enabled` is required"))?;- serde_json::to_value(crate::remote::cloud::set_cloud(hub, enabled, b["url"].as_str())?)?+ serde_json::to_value(crate::remote::cloud::set_cloud(hub, enabled)?)?}"setApproval" => {let approval = serde_json::from_value(b["approval"].clone()).context("`approval` is code or auto")?;diff --git a/host/src/main.rs b/host/src/main.rsindex 1a0c5641..2a5b4e24 100644--- a/host/src/main.rs+++ b/host/src/main.rs@@ -109,9 +109,6 @@ enum Sub {enable: bool,#[arg(long)]disable: bool,- /// Cloud base URL (https://…); turns the cloud on unless --disable.- #[arg(long)]- url: Option<String>,/// How devices on this computer's account get in: `code` (compare the 6-digit code,/// the default) or `auto` (no check: anyone who gets into the account, or controls/// the cloud, can then add a device).@@ -335,12 +332,12 @@ async fn main() -> Result<()> {}},Sub::Access { port, action } => access(port, action.unwrap_or(AccessAction::List)).await,- Sub::Cloud { port, enable, disable, url, approval } => {+ Sub::Cloud { port, enable, disable, approval } => {if let Some(approval) = approval {local_call(port, "setApproval", json!({ "approval": approval })).await?;}- let status = if enable || disable || url.is_some() {- local_call(port, "setCloud", json!({"enabled": !disable, "url": url})).await?+ let status = if enable || disable {+ local_call(port, "setCloud", json!({"enabled": !disable})).await?} else {local_call(port, "cloudStatus", json!({})).await?};diff --git a/host/src/remote/cloud.rs b/host/src/remote/cloud.rsindex 313235e0..065f9fbc 100644--- a/host/src/remote/cloud.rs+++ b/host/src/remote/cloud.rs@@ -16,17 +16,11 @@ use std::sync::Mutex;use std::time::Duration;use tokio::sync::watch;-/// The cloud a fresh host uses: main only for builds made with `CODYNC_ENV=main` (the release-/// workflows), dev for every local build, debug or release, like the apps built next to it.-/// Unit tests have none, so they never reach a real cloud.-fn default_cloud_url() -> Option<&'static str> {- if cfg!(test) {- None- } else if option_env!("CODYNC_ENV") == Some("main") {- Some("https://api.codync.dev")- } else {- Some("https://dev-api.codync.dev")- }+/// The cloud this build belongs to: main only for builds made with `CODYNC_ENV=main` (the+/// release workflows), dev for every local build, debug or release, like the apps built next+/// to it.+fn build_cloud_url() -> &'static str {+ if option_env!("CODYNC_ENV") == Some("main") { "https://api.codync.dev" } else { "https://dev-api.codync.dev" }}/// How long one successful state pull keeps an account device allowed.@@ -49,19 +43,23 @@ const SAS_NONCES_PER_HOUR: usize = 5;const HOUR_MS: i64 = 60 * 60 * 1000;/// The cloud base URL in use, or `None` when the cloud is off.-/// `CODYNC_CLOUD=off` > turned off here > `CODYNC_CLOUD_URL` > kv `cloud_url` > the default.+/// `CODYNC_CLOUD=off` > turned off here > `CODYNC_CLOUD_URL` (a cloud you're developing) > the+/// build's cloud. Which cloud is never saved here: on/off is the only stored cloud setting.+/// Unit tests point at a fake cloud through kv `test_cloud_url`, so they never reach a real one.pub fn url(store: &Store) -> Option<String> {if std::env::var("CODYNC_CLOUD").is_ok_and(|v| v == "off")|| store.kv_get("cloud_enabled").as_deref() == Some("false"){return None;}- std::env::var("CODYNC_CLOUD_URL")+ if cfg!(test) {+ return store.kv_get("test_cloud_url");+ }+ let custom = std::env::var("CODYNC_CLOUD_URL").ok()- .or_else(|| store.kv_get("cloud_url"))- .or_else(|| default_cloud_url().map(str::to_owned))- .map(|u| u.trim_end_matches('/').to_owned())- .filter(|u| !u.is_empty())+ .map(|u| u.trim().trim_end_matches('/').to_owned())+ .filter(|u| valid_url(&format!("{u}/")));+ Some(custom.unwrap_or_else(|| build_cloud_url().to_owned()))}/// A cloud URL this host may be pointed at: https, or plain http to this computer (local dev).@@ -607,15 +605,8 @@ pub async fn unclaim(hub: &Hub) -> Result<()> {pull(hub, &base).await}-/// `setCloud`: turns the cloud on or off (optionally pointing it elsewhere); the relay restarts.-pub fn set_cloud(hub: &Hub, enabled: bool, new_url: Option<&str>) -> Result<CloudStatus> {- if let Some(u) = new_url {- let u = u.trim().trim_end_matches('/');- if !valid_url(&format!("{u}/")) {- bail!("The cloud URL must be https://… (or http:// to this computer).");- }- hub.store.kv_set("cloud_url", u)?;- }+/// `setCloud`: turns the cloud on or off; the relay restarts.+pub fn set_cloud(hub: &Hub, enabled: bool) -> Result<CloudStatus> {hub.store.kv_set("cloud_enabled", if enabled { "true" } else { "false" })?;let now = url(&hub.store);update_status(hub, |s| {@@ -726,7 +717,7 @@ mod tests {let hub = temp_hub();let fake = Arc::new(FakeCloud::default());let base = fake_cloud(fake.clone()).await;- hub.store.kv_set("cloud_url", &base).unwrap();+ hub.store.kv_set("test_cloud_url", &base).unwrap();let (dk, other_dk): ([u8; 32], [u8; 32]) = (crypto::random(), crypto::random());let (nd, wrong): ([u8; 32], [u8; 32]) = (crypto::random(), crypto::random());let request = |id: &str, host_nonce: Option<String>, device_nonce: Option<[u8; 32]>| {@@ -772,7 +763,7 @@ mod tests {let hub = temp_hub();let fake = Arc::new(FakeCloud::default());let base = fake_cloud(fake.clone()).await;- hub.store.kv_set("cloud_url", &base).unwrap();+ hub.store.kv_set("test_cloud_url", &base).unwrap();set_approval(&hub, Approval::Auto).unwrap();let (dk, nd): ([u8; 32], [u8; 32]) = (crypto::random(), crypto::random());let request = |host_nonce: Option<String>, device_nonce: Option<[u8; 32]>| {diff --git a/host/src/remote/relay.rs b/host/src/remote/relay.rsindex d67975ef..43e04787 100644--- a/host/src/remote/relay.rs+++ b/host/src/remote/relay.rs@@ -709,7 +709,7 @@ mod tests {];let base = fake_cloud(fake.clone(), hub.clone()).await;- hub.store.kv_set("cloud_url", &base).unwrap();+ hub.store.kv_set("test_cloud_url", &base).unwrap();tokio::spawn(run(hub.clone()));wait_for(&fake, |m| m.iter().filter(|v| v["t"] == "mbox.ack").count() == 3).await;@@ -769,7 +769,7 @@ mod tests {vec![item(1, &key, "d1"), item(2, &key, "d1"), item(3, "wrong", "d2"), item(4, &key, "d3")];let base = fake_cloud(fake.clone(), hub.clone()).await;- hub.store.kv_set("cloud_url", &base).unwrap();+ hub.store.kv_set("test_cloud_url", &base).unwrap();tokio::spawn(run(hub.clone()));wait_for(&fake, |m| m.iter().filter(|v| v["t"] == "hook.ack").count() == 4).await;@@ -840,7 +840,7 @@ mod tests {vec![json!({"t": "mbox.item", "seq": 1, "from": dk, "nonce": nonce, "d": blob, "exp": now_ms() + 1000})];let base = fake_cloud(fake.clone(), hub.clone()).await;- hub.store.kv_set("cloud_url", &base).unwrap();+ hub.store.kv_set("test_cloud_url", &base).unwrap();tokio::spawn(run(hub.clone()));wait_for(&fake, |m| m.iter().any(|v| v["t"] == "mbox.ack")).await;