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
feat(host): install and run npm agents without Node.js
leepokai4eb219b79ef2
diff --git a/docs/architecture/file-structure.md b/docs/architecture/file-structure.mdindex 4b44158c..87cb39f8 100644--- a/docs/architecture/file-structure.md+++ b/docs/architecture/file-structure.md@@ -87,7 +87,7 @@ Codync/| Prompt snapshots and memory keeper | `host/src/chat/context.rs`, `memory/` (`engram/`, `manage.rs`, `read.rs`, `extract.rs`, `keeper.rs`, `search.rs`) || Identity, encryption and direct channel | `host/src/remote/identity.rs`, `crypto.rs`, `channel.rs` || Host cloud state and relay connection | `host/src/remote/cloud.rs`, `relay.rs` |-| Agent discovery, sign-in, setup terminal | `host/src/agent/backends.rs`, `registry.rs`, `auth.rs`, `term.rs` |+| Agent discovery, sign-in, setup terminal, Node.js for npm agents | `host/src/agent/backends.rs`, `registry.rs`, `auth.rs`, `term.rs`, `node.rs` || Marketplace, Composio, connector OAuth | `host/src/market/` || Screen bridge and built-in MCP tools | `host/src/screen/`, `mcp.rs` || Swift transport and cloud API | `apps/ios/Kit/Sources/CodyncKit/Client/` |diff --git a/docs/archive/windows-npm-agents-2026-10-14.md b/docs/archive/windows-npm-agents-2026-10-14.mdindex 1bdb184a..c869103e 100644--- a/docs/archive/windows-npm-agents-2026-10-14.md+++ b/docs/archive/windows-npm-agents-2026-10-14.md@@ -65,9 +65,9 @@ failed download reports the last stderr line that isn't an `npm notice`.## Seen, not fixed-- Without Node.js, an npx-only agent's install hint still names the harness setup (Claude Code),- which is already done; it should say to install Node.js. `list()` in- `host/src/agent/backends.rs`.+- Without Node.js, an npx-only agent couldn't start at all, and its install hint named the harness+ setup (Claude Code), which was already done. Resolved in the same release: Codync provides+ Node.js itself and installs Claude Code and Codex with npm ([agent setup](../features/marketplace.md)).- Every new bot on Windows posts `Memory is unavailable; … installing Engram: Access is denied.(os error 5)`.diff --git a/docs/features/marketplace.md b/docs/features/marketplace.mdindex 6b352aa4..bbcdd738 100644--- a/docs/features/marketplace.md+++ b/docs/features/marketplace.md@@ -4,11 +4,13 @@ The Extensions screen configures capabilities installed on the selected computer| Capability | Implementation | Behavior || --- | --- | --- |-| Agents | `host/src/agent/backends.rs`, `host/src/agent/registry.rs` | Detect installed harnesses and resolve ACP registry adapters |+| Agents | `host/src/agent/backends.rs`, `host/src/agent/registry.rs`, `host/src/agent/node.rs` | Detect installed harnesses, resolve ACP registry adapters, provide Node.js for npm agents || Connectors | `host/src/market/mod.rs`, `registry.rs`, `install.rs` | Discover MCP servers or add one manually; install per computer; on for every bot unless a bot turns it off || Connected apps | `host/src/market/composio.rs` | Expose connected Composio apps as connectors || Skills | `host/src/market/skills.rs` | Instruction folders containing `SKILL.md`, stored under `~/.codync/skills/<id>`; on for every bot unless a bot turns it off |+Agents never need Node.js installed first. Install for an npm CLI (Claude Code `@anthropic-ai/claude-code`, Codex `@openai/codex`, Pi) runs `codync-host npm install -g <package>` in a setup terminal: npm on the computer's own Node when it has one, else on Codync's. Codync's Node is the official build of a pinned version (`VERSION` and SHA-256s in `node.rs`), downloaded once into `~/.codync/node/<version>`; npm installs CLIs with it into `~/.codync/node/global`. Agents launched through `npx` (the Claude and Codex ACP adapters, Gemini, Qwen…) use the same Node, downloaded on their first start if missing. Both folders come last on the agent search path, so the computer's own Node and CLIs always win. Linux builds of Node need glibc: on musl distros (Alpine) install Node.js yourself.+The Connectors shelf opens with a short featured list, then pages through the whole MCP Registry (`marketConnectors {search, cursor}` → `{items, nextCursor}`, 60 metadata records per API page; the UI initially shows 12 and reveals another 12 only when *Load more connectors* is pressed). Apps through Composio use the same 12-at-a-time display with *Load more apps*. Searching resets the visible batch; late responses from an older search are ignored. Scrolling never triggers another catalog fetch. Listed: stdio npm/PyPI/OCI/NuGet packages (the registry's runtime and package arguments become inputs) and streamable-HTTP or SSE remotes (URL `{variables}` become inputs). Not listed: MCPB bundles and packages that serve HTTP locally; add those as a custom connector.Registry package installs use pinned package references: npm, PyPI and NuGet require the package’s own version; OCI uses the tag or SHA-256 digest already in its image identifier, even when the separate package version is omitted. Untagged images, `latest` tags without a digest, and invalid references are rejected; a server-level version does not pin the executable package.diff --git a/docs/guides/linux-servers.md b/docs/guides/linux-servers.mdindex a63416d4..45cde327 100644--- a/docs/guides/linux-servers.md+++ b/docs/guides/linux-servers.md@@ -9,7 +9,7 @@| x86_64 or arm64 Linux | Release builds exist for both architectures || `ca-certificates` | HTTPS to the ACP registry, push relay and cloud. Every normal VM image has it; bare container images (`debian`, `ubuntu`) need `apt-get install ca-certificates`. Without it every command exits with `TLS setup failed: install the ca-certificates package` || systemd | Only for `codync-host install` (background service). Without systemd, run `codync-host serve` under your own supervisor |-| Node.js | Claude Code, Codex and Pi run through ACP adapters fetched with `npx` |+| Node.js (optional) | Claude Code, Codex and Pi run through ACP adapters fetched with `npx`. Without Node, Codync downloads its own (glibc distros); on musl distros (Alpine) install Node.js || The agents you want, signed in | The host drives the CLIs installed on this machine with their own credentials. Sign in over SSH (`claude`, `codex login`…) as the same user that runs the host |Distro and C library don't matter. From the first release built by the updated workflow, Linux release binaries are static musl builds with no glibc dependency. Earlier releases (≤ 2.1.0) were built against glibc 2.39 and only start on Ubuntu 24.04 or newer. On older distros they fail with `GLIBC_2.39 not found`; build from source or use a newer release there.diff --git a/docs/guides/windows-testing.md b/docs/guides/windows-testing.mdindex 326a6277..107858d7 100644--- a/docs/guides/windows-testing.md+++ b/docs/guides/windows-testing.md@@ -36,16 +36,16 @@ when a change or a bug depends on Windows itself (paths, `cmd.exe`, `.cmd` shims```powershell$t = Get-Content "$env:USERPROFILE\.codync\token"- Invoke-RestMethod -Method Post -Uri http://127.0.0.1:19222/api/backends `+ Invoke-RestMethod -Method Post -Uri http://127.0.0.1:19222/api/refreshBackends `-Headers @{ Authorization = "Bearer $t" } -ContentType application/json -Body '{}'````createBot`, `send` and `history` cover most agent checks; a failed start shows up as an errornotice in `history`. Host logs are under `%USERPROFILE%\.codync`.-4. Agents: install each harness with the command its setup hint gives (Claude Code:- `irm https://claude.ai/install.ps1 | iex`). Adapters that come from npm (Claude, Codex, Gemini,- Qwen, …) also need Node.js (`winget install OpenJS.NodeJS`); agents shipped as binaries- (OpenCode, Grok) don't.+4. Agents: *Install* in the agent sheet (or the CLI's own installer). Agents that come from npm+ (Claude, Codex, Gemini, Qwen, …) don't need Node.js on the VM: without one, Codync downloads its+ own into `%USERPROFILE%\.codync\node` (see [agent setup](../features/marketplace.md)). To test+ the computer's own Node instead, `winget install OpenJS.NodeJS`.## Limitsdiff --git a/host/src/agent/backends.rs b/host/src/agent/backends.rsindex 2e340c84..2631d666 100644--- a/host/src/agent/backends.rs+++ b/host/src/agent/backends.rs@@ -40,7 +40,7 @@ pub enum Install {Script(&'static str),/// Vendor install scripts for Unix and for Windows (PowerShell).Scripts { unix: &'static str, windows: &'static str },- /// A global npm package.+ /// A global npm package, installed on the computer's Node or else Codync's (`codync-host npm`).Npm(&'static str),}@@ -51,12 +51,9 @@ impl Install {Self::Script(s) | Self::Scripts { unix: s, .. } if cfg!(unix) => Some(s.to_owned()),Self::Script(_) => None,Self::Scripts { windows, .. } => Some(windows.to_owned()),- Self::Npm(pkg) if cfg!(windows) => Some(format!(- "where npm >nul 2>nul || (echo This needs Node.js first: https://nodejs.org & exit /b 1) & npm install -g {pkg}"- )),- Self::Npm(pkg) => Some(format!(- "command -v npm >/dev/null || {{ echo 'This needs Node.js first: https://nodejs.org'; exit 1; }}; npm install -g {pkg}"- )),+ Self::Npm(pkg) => crate::service::current_exe()+ .ok()+ .map(|exe| format!("{} npm install -g {pkg}", shell::quote(&exe.to_string_lossy()))),}}}@@ -93,10 +90,7 @@ pub const HARNESSES: &[Harness] = &[local: None,registry: Some("claude-acp"),setup: "Install Claude Code and run `claude auth login`.",- install: Some(Install::Scripts {- unix: "curl -fsSL https://claude.ai/install.sh | bash",- windows: "powershell -NoProfile -ExecutionPolicy Bypass -Command \"irm https://claude.ai/install.ps1 | iex\"",- }),+ install: Some(Install::Npm("@anthropic-ai/claude-code")),login: "{bin} auth login",signed_in: Some(SignInCheck { args: "auth status", ok: claude_signed_in }),},@@ -107,7 +101,7 @@ pub const HARNESSES: &[Harness] = &[local: None,registry: Some("codex-acp"),setup: "Install Codex CLI and run `codex login --device-auth`.",- install: Some(Install::Script("curl -fsSL https://chatgpt.com/codex/install.sh | sh")),+ install: Some(Install::Npm("@openai/codex")),login: "{bin} login --device-auth",signed_in: Some(SignInCheck { args: "login status", ok: exit_ok }),},@@ -482,6 +476,8 @@ fn well_known_dirs() -> Vec<PathBuf> {versions.sort_by_key(|p| std::cmp::Reverse(node_version(p)));dirs.extend(versions.into_iter().map(|p| p.join("bin")));}+ // Last, so the computer's own Node comes first.+ dirs.extend(crate::agent::node::search_dirs());dirs}diff --git a/host/src/agent/mod.rs b/host/src/agent/mod.rsindex b1c0b500..162d15a9 100644--- a/host/src/agent/mod.rs+++ b/host/src/agent/mod.rs@@ -5,6 +5,7 @@ pub mod acp;pub mod auth;pub mod backends;pub mod bot;+pub mod node;pub mod registry;pub mod term;pub mod workspace;diff --git a/host/src/agent/node.rs b/host/src/agent/node.rsnew file mode 100644index 00000000..349fc73e--- /dev/null+++ b/host/src/agent/node.rs@@ -0,0 +1,169 @@+//! Node.js for the agents that come from npm (Claude, Codex, Gemini, …) and for installing npm+//! CLIs: the computer's own when it has one, else a checksum-pinned official build Codync+//! downloads once into `~/.codync/node`, so installing an agent never needs Node.js first.++use crate::agent::{backends, registry};+use anyhow::{Context, Result, ensure};+use std::path::{Path, PathBuf};+use std::time::Duration;++const VERSION: &str = "24.21.0";+const MAX_ARCHIVE_BYTES: usize = 128 * 1024 * 1024;+static INSTALL: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());++/// nodejs.org's name for a platform, and its archive's SHA-256 (from `SHASUMS256.txt`).+fn archive(os: &str, arch: &str) -> Option<(&'static str, &'static str)> {+ Some(match (os, arch) {+ ("macos", "aarch64") => ("darwin-arm64", "bed7eea5325e1108f32ce5228ddd6a5f0f08a499ee42aa7442aea583702f6057"),+ ("macos", "x86_64") => ("darwin-x64", "1462cb3b3046b815cf8ea436d3da450ec1a9f11dac7e5a46b0ada5305d7e8097"),+ ("linux", "aarch64") => ("linux-arm64", "724282c3b43aec998aa9527380465b45d229e021b58035f5f4f63095eabfe5d5"),+ ("linux", "x86_64") => ("linux-x64", "6e1db87ef58b8819e5d5402eff1536491b18edd8eb7bee5ef7897876e88dc5ff"),+ ("windows", "aarch64") => ("win-arm64", "8779b1bde1d39f8d420e3b57aa657b39891af434d3de44a919044cec06785921"),+ ("windows", "x86_64") => ("win-x64", "158f7685b44de51f6c0df1d153526cbcd3e1bc739a8dfc607721cef75de9e541"),+ _ => return None,+ })+}++/// `~/.codync/node/<version>`: Codync's Node.+fn root() -> PathBuf {+ crate::service::data_dir().join("node").join(VERSION)+}++/// Where `npm install -g` puts CLIs when it runs on Codync's Node; outlives Node updates.+fn global_prefix() -> PathBuf {+ crate::service::data_dir().join("node").join("global")+}++/// The commands under an npm prefix: Windows keeps them at the top.+fn bin_dir(prefix: PathBuf) -> PathBuf {+ if cfg!(windows) { prefix } else { prefix.join("bin") }+}++/// Codync's Node and the CLIs installed with it, for the agent search path (after the+/// computer's own, so its Node wins).+pub fn search_dirs() -> [PathBuf; 2] {+ [bin_dir(root()), bin_dir(global_prefix())]+}++/// Codync can run npm agents here: the computer has Node, or Codync has one for it.+pub fn available() -> bool {+ backends::on_path("npx") || archive(std::env::consts::OS, std::env::consts::ARCH).is_some()+}++/// Makes `npx` runnable for agents, downloading Codync's Node the first time it's missing.+pub async fn ensure(progress: &impl Fn(&str)) -> Result<()> {+ if backends::on_path("npx") {+ return Ok(());+ }+ install(progress).await?;+ tokio::task::spawn_blocking(backends::hydrate_path).await?;+ Ok(())+}++/// `codync-host npm …`: npm on the computer's Node, else on Codync's, whose global installs+/// land in `global_prefix`. Setup terminals install npm CLIs through it.+pub async fn npm(args: &[String]) -> Result<i32> {+ let mut command =+ if let Some(npm) = backends::which("npm") { tokio::process::Command::new(npm) } else { codync_npm().await? };+ let status = command.args(args).status().await.context("running npm")?;+ Ok(status.code().unwrap_or(1))+}++/// npm on Codync's Node (downloaded first), with its own Node first on PATH.+async fn codync_npm() -> Result<tokio::process::Command> {+ install(&|line| println!("{line}")).await?;+ let bin = bin_dir(root());+ let mut command = tokio::process::Command::new(bin.join(if cfg!(windows) { "npm.cmd" } else { "npm" }));+ let path = std::env::var_os("PATH").unwrap_or_default();+ let path = std::env::join_paths(std::iter::once(bin).chain(std::env::split_paths(&path)))?;+ command.env("PATH", path).env("npm_config_prefix", global_prefix());+ Ok(command)+}++async fn install(progress: &impl Fn(&str)) -> Result<()> {+ let _one_at_a_time = INSTALL.lock().await;+ let root = root();+ if tokio::fs::try_exists(root.join(".installed")).await.unwrap_or(false) {+ return Ok(());+ }+ let (platform, checksum) = archive(std::env::consts::OS, std::env::consts::ARCH)+ .context("Codync has no Node.js build for this computer: install Node.js from nodejs.org")?;+ let name = format!("node-v{VERSION}-{platform}");+ let file = format!("{name}.{}", if cfg!(windows) { "zip" } else { "tar.gz" });+ progress("Downloading Node.js…");+ let mut response = crate::http()+ .get(format!("https://nodejs.org/dist/v{VERSION}/{file}"))+ .timeout(Duration::from_secs(600))+ .send()+ .await?+ .error_for_status()?;+ let mut bytes = Vec::new();+ while let Some(chunk) = response.chunk().await? {+ ensure!(bytes.len() + chunk.len() <= MAX_ARCHIVE_BYTES, "Node.js download exceeds size limit");+ bytes.extend_from_slice(&chunk);+ }+ ensure!(registry::sha256_hex(&bytes) == checksum, "Node.js download checksum mismatch");+ progress("Installing Node.js…");+ tokio::task::spawn_blocking(move || unpack(&root, &name, &file, &bytes)).await?.context("installing Node.js")+}++/// Blocking: extracts into a staging folder next to `root`, then moves it into place.+fn unpack(root: &Path, name: &str, file: &str, bytes: &[u8]) -> Result<()> {+ let parent = root.parent().context("Node.js folder has no parent")?;+ let stage = parent.join(format!(".staging-{}", uuid::Uuid::new_v4()));+ let placed = place(root, &stage, name, file, bytes);+ let _ = std::fs::remove_dir_all(&stage);+ if placed.is_ok() {+ remove_other_versions(root);+ }+ placed+}++fn place(root: &Path, stage: &Path, name: &str, file: &str, bytes: &[u8]) -> Result<()> {+ std::fs::create_dir_all(stage)?;+ let archive = stage.join(file);+ std::fs::write(&archive, bytes)?;+ let node = Path::new(name).join(if cfg!(windows) { "node.exe" } else { "bin/node" });+ registry::extract(&archive, stage, &node)?;+ let out = std::process::Command::new(stage.join(&node)).arg("--version").output()?;+ let runs = out.status.success() && String::from_utf8_lossy(&out.stdout).trim() == format!("v{VERSION}");+ ensure!(runs, "the downloaded Node.js doesn't run on this computer");+ // Another process (a setup terminal's `codync-host npm`) may have finished first.+ if !root.join(".installed").exists() {+ let _ = std::fs::remove_dir_all(root);+ std::fs::rename(stage.join(name), root)?;+ std::fs::write(root.join(".installed"), VERSION)?;+ }+ Ok(())+}++/// Older Nodes Codync downloaded (version-named folders; never `global` or a staging folder+/// another process is still filling).+fn remove_other_versions(root: &Path) {+ let Some(parent) = root.parent() else { return };+ let Ok(entries) = std::fs::read_dir(parent) else { return };+ for path in entries.flatten().map(|e| e.path()) {+ let versioned =+ path.file_name().and_then(|n| n.to_str()).is_some_and(|n| n.starts_with(|c: char| c.is_ascii_digit()));+ if versioned && path != root && path.is_dir() {+ let _ = std::fs::remove_dir_all(path);+ }+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn every_supported_platform_has_a_pinned_archive() {+ for os in ["macos", "linux", "windows"] {+ for arch in ["x86_64", "aarch64"] {+ let (platform, checksum) = archive(os, arch).expect("supported");+ assert!(!platform.is_empty());+ assert!(checksum.len() == 64 && checksum.chars().all(|c| c.is_ascii_hexdigit()));+ }+ }+ assert!(archive("linux", "riscv64").is_none());+ }+}diff --git a/host/src/agent/registry.rs b/host/src/agent/registry.rsindex ce9cf958..6c7b3f16 100644--- a/host/src/agent/registry.rs+++ b/host/src/agent/registry.rs@@ -92,7 +92,7 @@ pub fn launch_kind(agent: &Value) -> Option<Launch> {{return Some(Launch::Download);}- if d["npx"].is_object() && on_path("npx") {+ if d["npx"].is_object() && crate::agent::node::available() {return Some(Launch::Npx);}if d["uvx"].is_object() && on_path("uvx") {@@ -160,6 +160,7 @@ pub async fn command(agent: &Value, progress: impl Fn(&str)) -> Result<Cmd> {})}Some(Launch::Npx) => {+ crate::agent::node::ensure(&progress).await?;prepare_npx(d["npx"]["package"].as_str().unwrap_or_default(), name, &progress).await?;Ok(npx_cmd(&d["npx"]))}@@ -257,7 +258,7 @@ fn npx_hash(package: &str) -> String {})}-fn sha256_hex(bytes: &[u8]) -> String {+pub(crate) fn sha256_hex(bytes: &[u8]) -> String {use std::fmt::Write as _;Sha256::digest(bytes).iter().fold(String::with_capacity(64), |mut s, b| {let _ = write!(s, "{b:02x}");diff --git a/host/src/main.rs b/host/src/main.rsindex 6ff00d45..fc07ceca 100644--- a/host/src/main.rs+++ b/host/src/main.rs@@ -181,6 +181,13 @@ enum Sub {#[arg(long, default_value_t = service::DEFAULT_PORT)]port: u16,},+ /// npm on this computer's Node, else on Codync's own (downloaded first): what setup+ /// terminals install npm CLIs with.+ #[command(hide = true)]+ Npm {+ #[arg(trailing_var_arg = true, allow_hyphen_values = true)]+ args: Vec<String>,+ },/// Built-in MCP servers that bots are started with (stdio).#[command(hide = true)]Mcp {@@ -465,6 +472,7 @@ async fn main() -> Result<()> {);Ok(())}+ Sub::Npm { args } => std::process::exit(agent::node::npm(&args).await?),Sub::Statusline { port, wrapped } => {statusline(port, wrapped.join(" ")).await;Ok(())