Seed missing daemon installs from complete local CLI packages (#45558)

## Why

Daemon lifecycle commands previously required a standalone managed installation. A complete CLI package can supply the daemon executable and helpers without requiring a separate installer run.

## What changed

- Let `codex app-server daemon start`, `restart`, and `bootstrap` copy the invoking package into `CODEX_HOME/packages/app-server-daemon` when no daemon installation exists.
- Validate the package's platform, required helpers, executable identity, and copied contents before selecting the staged release.
- Preserve existing dedicated and legacy daemon selections, reject broken selections instead of replacing them, and leave the CLI package and selection unchanged.
- Preserve standalone release pins and latest-channel eligibility, and select dedicated releases using Unix symlinks or Windows junctions.

## Testing

Add package preparation tests for complete copies, incomplete packages, broken selections, legacy preservation, and update-channel handling. Add Windows junction creation and retargeting coverage, plus CLI integration tests that launch the copied package through `start`, `restart`, and `bootstrap`.

GitOrigin-RevId: abd2f4f82eae0885434ea30603c2c1c0ca760bef
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-15 00:33:41 +00:00
1 parent 446b771049
commit 653e5fbb9d
12 files changed
+815 -50

No files matched your search

@@ -14,7 +14,7 @@ use tokio::fs;
use tokio::process::Command;
use tokio::time::timeout;
/// Dedicated daemon packages take precedence over standalone installations.
/// New daemons own their packages, regardless of how the calling CLI was installed.
/// Preserve legacy launch state, including logs left after a daemon is stopped;
/// settings, installer selections, and lock files alone do not prove a prior launch.
pub(crate) fn package_root(codex_home: &Path) -> PathBuf {
@@ -52,13 +52,6 @@ pub(crate) fn package_root(codex_home: &Path) -> PathBuf {
return codex_home.join("packages").join(package);
}
}
// Retain CLI installs until the next stage adds dedicated package seeding.
let standalone = codex_home.join("packages/standalone");
if !matches!(standalone.join("current").symlink_metadata(),
Err(error) if error.kind() == std::io::ErrorKind::NotFound)
{
return standalone;
}
dedicated
}