Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

make nightly updates fetch the beta installer directly (#3276)

kt0280fcc16d82
diff --git a/.changes/nightly-update-direct.md b/.changes/nightly-update-direct.md
new file mode 100644
index 0000000000..b6265a5644
--- /dev/null
+++ b/.changes/nightly-update-direct.md
@@ -0,0 +1 @@
+- Nightly updates download the nightly installer directly instead of going through the stable installer first.
diff --git a/crates/pa-cli/src/command_registry.rs b/crates/pa-cli/src/command_registry.rs
index e1099d74e2..6fed799f95 100644
--- a/crates/pa-cli/src/command_registry.rs
+++ b/crates/pa-cli/src/command_registry.rs
@@ -212,14 +212,14 @@ pub const COMMAND_SPECS: &[CommandSpec] = &[
])
.description(
"Move from the TypeScript version to the Rust port in one step: `prime-agent update` \
- fetches the installer from the official domain endpoint \
- (https://app.primeintellect.ai/prime-agent/install.sh — never a GitHub raw or workflow \
- URL) and runs it, which uninstalls the TypeScript version and installs the latest Rust \
- build; your sessions and configuration (~/.prime/agent) are never touched. Restart \
- prime-agent after the update to run the new build. This command exists only in the \
- Rust binary — the TypeScript version does not have it; the move happens when you run \
- the installer's curl|sh URL (the README's Install section) or `prime-agent update` \
- (after the Rust install exists).",
+ fetches the update channel's installer (stable: \
+ https://app.primeintellect.ai/prime-agent/install.sh; nightly: install-beta.sh from the \
+ release download base — never a GitHub raw or workflow URL) and runs it, which \
+ uninstalls the TypeScript version and installs the latest Rust build; your sessions and \
+ configuration (~/.prime/agent) are never touched. Restart prime-agent after the update \
+ to run the new build. This command exists only in the Rust binary — the TypeScript \
+ version does not have it; the move happens when you run the installer's curl|sh URL (the \
+ README's Install section) or `prime-agent update` (after the Rust install exists).",
),
CommandSpec::new(&["model"], "model list [search]", "Inspect available models"),
CommandSpec::new(&["model", "list"], "model list [search]", "List available models"),
diff --git a/crates/pa-cli/src/installer_update.rs b/crates/pa-cli/src/installer_update.rs
index 13cb7c0f1b..f17b243b09 100644
--- a/crates/pa-cli/src/installer_update.rs
+++ b/crates/pa-cli/src/installer_update.rs
@@ -1,7 +1,8 @@
//! The `prime-agent update` body: the TS->Rust migration path. One step —
-//! the update fetches the installer from the OFFICIAL DOMAIN endpoint
-//! (`https://app.primeintellect.ai/prime-agent/install.sh`, never a
-//! GitHub raw or workflow URL) and runs it; the script uninstalls the
+//! the update fetches the update channel's installer (stable: the official
+//! domain's `https://app.primeintellect.ai/prime-agent/install.sh`;
+//! nightly: the download base's `install-beta.sh`; never a GitHub raw or
+//! workflow URL) and runs it; the script uninstalls the
//! TypeScript version, installs the latest Rust build of the update
//! channel, and never touches `~/.prime/agent` (the sessions and
//! configuration). The TUI's `/update` runs the same core out-of-band
@@ -93,11 +94,11 @@ pub fn run(options: &UpdateOptions) -> i32 {
// pin (a test or a pinned install) changes where the funnel actually
// fetches from, and the banner must not claim a source the run will
// not use.
+ let channel = requested_installer_channel(options.channel);
println!(
"Updating to the latest Rust build — fetching the installer from {}:",
- installer::installer_script_url()
+ installer::installer_script_url(Some(channel))
);
- let channel = requested_installer_channel(options.channel);
match runtime.block_on(installer::run_installer(
Some(channel),
InstallerOutput::Inherit,
diff --git a/crates/pa-cli/tests/installer_update_e2e.rs b/crates/pa-cli/tests/installer_update_e2e.rs
index f4954f3dff..e71cc293b0 100644
--- a/crates/pa-cli/tests/installer_update_e2e.rs
+++ b/crates/pa-cli/tests/installer_update_e2e.rs
@@ -53,6 +53,12 @@ const FAILING_INSTALLER: &str =
/// Serve `body` over one plain HTTP request; return the URL the funnel
/// fetches.
fn serve(body: &'static str) -> String {
+ format!("{}/install-rust.sh", serve_at("/install-rust.sh", body))
+}
+
+/// Serve `body` at `path` over one plain HTTP request (any other path
+/// answers 404); return the server's base URL.
+fn serve_at(path: &'static str, body: &'static str) -> String {
let listener = TcpListener::bind("127.0.0.1:0").expect("bind loopback");
let address = listener.local_addr().expect("local address");
std::thread::spawn(move || {
@@ -68,8 +74,18 @@ fn serve(body: &'static str) -> String {
Ok(_) => head.push(byte[0]),
}
}
+ let requested = String::from_utf8_lossy(&head)
+ .split_whitespace()
+ .nth(1)
+ .unwrap_or_default()
+ .to_string();
+ let (status, body) = if requested == path {
+ ("200 OK", body)
+ } else {
+ ("404 Not Found", "")
+ };
let response = format!(
- "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}",
+ "HTTP/1.1 {status}\r\nContent-Type: text/plain\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}",
body.len(),
body
);
@@ -77,7 +93,7 @@ fn serve(body: &'static str) -> String {
let _ = stream.flush();
}
});
- format!("http://{address}/install-rust.sh")
+ format!("http://{address}")
}
/// One sandbox: a HOME with the session store the update must preserve,
@@ -133,17 +149,23 @@ fn uuid_probe() -> String {
}
fn run_prime_agent(args: &[&str], sandbox: &Sandbox, url: &str) -> std::process::Output {
- Command::new(env!("CARGO_BIN_EXE_prime-agent"))
+ let mut command = prime_agent(args, sandbox);
+ command.env(ENV_INSTALLER_URL, url);
+ command.output().expect("run the prime-agent binary")
+}
+
+fn prime_agent(args: &[&str], sandbox: &Sandbox) -> Command {
+ let mut command = Command::new(env!("CARGO_BIN_EXE_prime-agent"));
+ command
.args(args)
.env("HOME", sandbox.root.join("home"))
- .env(ENV_INSTALLER_URL, url)
+ .env_remove(ENV_INSTALLER_URL)
.env(ENV_PREFIX, &sandbox.prefix)
.env(
"PRIME_AGENT_CODING_AGENT_DIR",
sandbox.root.join("home/.prime/agent"),
- )
- .output()
- .expect("run the prime-agent binary")
+ );
+ command
}
/// `prime-agent update` downloads the script, runs it, the launcher
@@ -182,6 +204,43 @@ fn update_runs_the_downloaded_installer_and_preserves_the_session_store() {
sandbox.assert_session_preserved();
}
+/// A nightly install's `prime-agent update` fetches `install-beta.sh` from
+/// the download base (no installer override): the domain only forwards
+/// the stable `install.sh`, so nightly updates go to the bucket directly.
+#[test]
+fn a_nightly_update_fetches_install_beta_from_the_download_base() {
+ let sandbox = Sandbox::new();
+ let share = sandbox.prefix.join("share/prime-agent");
+ std::fs::create_dir_all(&share).expect("share dir");
+ std::fs::write(
+ share.join(".prime-agent-install"),
+ "install-rust.sh channel beta\nversion 0.9.9-beta.11\n",
+ )
+ .expect("install marker");
+ let base = serve_at("/install-beta.sh", MOCK_INSTALLER);
+ let output = prime_agent(&["update"], &sandbox)
+ .env("PRIME_AGENT_DOWNLOAD_BASE_URL", &base)
+ .output()
+ .expect("run the prime-agent binary");
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ assert!(
+ output.status.success(),
+ "the nightly update succeeds:\nstdout:\n{stdout}\nstderr:\n{}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ assert!(
+ stdout.contains(&format!(
+ "fetching the installer from {base}/install-beta.sh"
+ )),
+ "the banner names the nightly installer:\n{stdout}"
+ );
+ assert!(
+ stdout.contains("updated to 9.9.9-continuous.0123456789abcdef"),
+ "the nightly installer ran:\n{stdout}"
+ );
+ sandbox.assert_session_preserved();
+}
+
/// A failing installer reports the error and keeps the previous install.
#[test]
fn a_failing_installer_keeps_the_previous_install() {
diff --git a/crates/pa-core/src/update/installer.rs b/crates/pa-core/src/update/installer.rs
index 5108c44203..c37dba36dd 100644
--- a/crates/pa-core/src/update/installer.rs
+++ b/crates/pa-core/src/update/installer.rs
@@ -1,14 +1,15 @@
//! The installer-takeover update funnel: `prime-agent update` and the TUI's
-//! `/update` download the installer from the OFFICIAL DOMAIN endpoint and
-//! run it — never a GitHub raw or workflow URL. The script is the single
-//! source of truth for the whole move — it resolves and downloads the
-//! latest build, uninstalls the TypeScript version, publishes the payload,
-//! and never touches `~/.prime/agent` (the sessions and configuration the
-//! products share). The command's contract is "fetch from the official
-//! source, run it". This module only fetches and execs the script, then
-//! reports what landed; every install/uninstall decision stays in the
-//! script the installer-takeover lane owns, so the two surfaces can never
-//! drift from it.
+//! `/update` download the update channel's installer and run it — the
+//! official domain endpoint for stable, the download base's
+//! `install-beta.sh` for nightly; never a GitHub raw or workflow URL. The
+//! script is the single source of truth for the whole move — it resolves
+//! and downloads the latest build, uninstalls the TypeScript version,
+//! publishes the payload, and never touches `~/.prime/agent` (the sessions
+//! and configuration the products share). The command's contract is "fetch
+//! from the official source, run it". This module only fetches and execs
+//! the script, then reports what landed; every install/uninstall decision
+//! stays in the script the installer-takeover lane owns, so the two
+//! surfaces can never drift from it.
use std::path::{Path, PathBuf};
use std::time::Duration;
@@ -33,10 +34,13 @@ pub const ENV_DOWNLOAD_BASE_URL: &str = "PRIME_AGENT_DOWNLOAD_BASE_URL";
/// manifests (`latest.json`, `beta.json`) are published.
pub const DEFAULT_DOWNLOAD_BASE_URL: &str = "https://pub-728493de92a943e2a9b2d17b4719f318.r2.dev";
-/// The official domain's install endpoint — the one source the funnel
-/// fetches the installer from; never a GitHub raw or workflow URL (the
-/// override env var stays for tests and pinned installs).
+/// The official domain's install endpoint — the stable channel's installer
+/// source; never a GitHub raw or workflow URL (the override env var stays
+/// for tests and pinned installs).
pub const OFFICIAL_INSTALLER_URL: &str = "https://app.primeintellect.ai/prime-agent/install.sh";
+/// The nightly installer's file under the download base (the domain only
+/// forwards `install.sh`, so nightly updates fetch it from the base).
+pub const BETA_INSTALLER_FILE: &str = "install-beta.sh";
/// The small-file budget for the script download (the script is a few KB;
/// a hung fetch must not hang the update).
@@ -45,17 +49,25 @@ const SCRIPT_FETCH_TIMEOUT: Duration = Duration::from_secs(30);
/// probe uses; a hung launcher must not hang the report).
const LAUNCHER_PROBE_TIMEOUT: Duration = Duration::from_secs(10);
-/// The installer script URL: the official domain's install endpoint by
-/// default (`PRIME_AGENT_RUST_INSTALLER_URL` overrides it — tests serve
-/// their own script, a pinned install can point elsewhere).
+/// The installer script URL for an installer channel (`stable` | `beta`):
+/// `<download base>/install-beta.sh` for beta, the official domain's
+/// install endpoint otherwise. `PRIME_AGENT_RUST_INSTALLER_URL` overrides
+/// both — tests serve their own script, a pinned install can point
+/// elsewhere.
#[must_use]
-pub fn installer_script_url() -> String {
+pub fn installer_script_url(channel: Option<&str>) -> String {
if let Ok(url) = std::env::var(ENV_INSTALLER_URL) {
if !url.trim().is_empty() {
return url;
}
}
- OFFICIAL_INSTALLER_URL.to_string()
+ match channel {
+ Some("beta") => format!(
+ "{}/{BETA_INSTALLER_FILE}",
+ download_base_url().trim_end_matches('/')
+ ),
+ _ => OFFICIAL_INSTALLER_URL.to_string(),
+ }
}
/// The download base `--check` reads the channel manifest from: the
@@ -150,10 +162,10 @@ pub struct UpdateFailure {
pub message: String,
}
-/// Run the takeover update with the environment's knobs (the script URL
-/// and the install prefix): the composition root's entry. `channel` is the
-/// requested release channel (`stable` | `beta`); `None` keeps the
-/// installed one.
+/// Run the takeover update with the environment's knobs (the install
+/// prefix and the channel's script URL): the composition root's entry.
+/// `channel` is the requested release channel (`stable` | `beta`); `None`
+/// keeps the installed one.
///
/// # Errors
/// Returns the failure message for every non-installing outcome (see
@@ -162,7 +174,9 @@ pub async fn run_installer(
channel: Option<&'static str>,
output: InstallerOutput,
) -> std::result::Result<Installed, UpdateFailure> {
- run_installer_from(&installer_script_url(), &install_prefix(), channel, output).await
+ let prefix = install_prefix();
+ let channel = channel.or_else(|| installed_channel(&prefix));
+ run_installer_from(&installer_script_url(channel), &prefix, channel, output).await
}
/// Run the takeover update from one explicit script URL and install
@@ -552,29 +566,51 @@ echo "installed: 9.9.8-continuous.fedcba9876543210"
(root, preserve, prefix)
}
- /// The default funnel URL is the official domain's install endpoint —
- /// never a GitHub raw or workflow URL (the operator ships the Rust
- /// installer through the domain itself; the override stays for tests
- /// and pinned installs).
+ /// The funnel URL follows the channel: stable fetches the official
+ /// domain's install endpoint, nightly (beta) fetches `install-beta.sh`
+ /// from the download base (the domain forwards only `install.sh`), and
+ /// the override pins both.
#[test]
- fn the_default_installer_url_is_the_official_domain_endpoint() {
- // The override is SAVED and RESTORED around the probe: the test
- // asserts the default resolution, but a pinned value in the
- // surrounding environment (a test or a pinned install) must
- // survive it (the env is process-global — leave it as found).
+ fn the_installer_url_follows_the_channel() {
+ // The knobs are SAVED and RESTORED around the probe: the env is
+ // process-global, so a pinned value in the surrounding
+ // environment must survive it.
let prior_override = std::env::var(ENV_INSTALLER_URL).ok();
+ let prior_base = std::env::var(ENV_DOWNLOAD_BASE_URL).ok();
std::env::remove_var(ENV_INSTALLER_URL);
- assert_eq!(installer_script_url(), OFFICIAL_INSTALLER_URL);
+ std::env::remove_var(ENV_DOWNLOAD_BASE_URL);
assert_eq!(
- OFFICIAL_INSTALLER_URL,
+ installer_script_url(Some("stable")),
"https://app.primeintellect.ai/prime-agent/install.sh"
);
- assert!(
- !OFFICIAL_INSTALLER_URL.contains("github"),
- "the official endpoint never points at GitHub"
+ assert_eq!(installer_script_url(None), OFFICIAL_INSTALLER_URL);
+ assert_eq!(
+ installer_script_url(Some("beta")),
+ "https://pub-728493de92a943e2a9b2d17b4719f318.r2.dev/install-beta.sh"
+ );
+ std::env::set_var(ENV_DOWNLOAD_BASE_URL, "https://mirror.example/");
+ assert_eq!(
+ installer_script_url(Some("beta")),
+ "https://mirror.example/install-beta.sh"
);
- if let Some(value) = prior_override {
- std::env::set_var(ENV_INSTALLER_URL, value);
+ assert_eq!(installer_script_url(Some("stable")), OFFICIAL_INSTALLER_URL);
+ std::env::set_var(ENV_INSTALLER_URL, "http://127.0.0.1:9/pinned.sh");
+ assert_eq!(
+ installer_script_url(Some("beta")),
+ "http://127.0.0.1:9/pinned.sh"
+ );
+ assert_eq!(
+ installer_script_url(Some("stable")),
+ "http://127.0.0.1:9/pinned.sh"
+ );
+ for (name, prior) in [
+ (ENV_INSTALLER_URL, prior_override),
+ (ENV_DOWNLOAD_BASE_URL, prior_base),
+ ] {
+ match prior {
+ Some(value) => std::env::set_var(name, value),
+ None => std::env::remove_var(name),
+ }
}
}
diff --git a/crates/pa-core/src/update/mod.rs b/crates/pa-core/src/update/mod.rs
index c3b951395d..5de44ca175 100644
--- a/crates/pa-core/src/update/mod.rs
+++ b/crates/pa-core/src/update/mod.rs
@@ -4,8 +4,8 @@
//! driver lives in pa-cli; everything here is the mechanism it drives, kept
//! daemon-free so pa-core stays the shared client/service layer. The
//! `installer` module is the other update body: the installer-takeover
-//! funnel `prime-agent update` and the TUI's `/update` run — the official
-//! domain's installer (never a GitHub raw or workflow URL) owns the whole
+//! funnel `prime-agent update` and the TUI's `/update` run — the update
+//! channel's installer (never a GitHub raw or workflow URL) owns the whole
//! move, exec'd through the trusted absolute `/bin/sh` (never a
//! `PATH`-resolved interpreter), kept beside the staged flow the
//! `package update` self target still serves.