Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-daemon): compile without the client feature (#4937)

Francesco Bonacciac967b9006aa
diff --git a/libs/cua/crates/cua-daemon/src/client.rs b/libs/cua/crates/cua-daemon/src/client.rs
index 42de043410..4600c94a0f 100644
--- a/libs/cua/crates/cua-daemon/src/client.rs
+++ b/libs/cua/crates/cua-daemon/src/client.rs
@@ -3,6 +3,7 @@
use crate::{
Discovery, Error, Result, SandboxRecord,
convert::{dur, info_from_pb, probe_to_pb, provider_to_pb},
+ identity::version_key,
runtime::CreateRequest,
};
use cua_proto::daemon::v1::{
@@ -858,19 +859,6 @@ pub fn cua_binary() -> Option<PathBuf> {
.find(|p| p.is_file())
}
-/// `major.minor.patch` of a version string; a pre-release sorts before its
-/// release. `None` when it does not parse.
-pub(crate) fn version_key(version: &str) -> Option<(u64, u64, u64, bool)> {
- let version = version.trim().trim_start_matches('v');
- let (core, pre) = match version.split_once('-') {
- Some((core, _)) => (core, true),
- None => (version.split('+').next().unwrap_or(version), false),
- };
- let mut parts = core.split('.').map(|p| p.parse::<u64>().ok());
- let key = (parts.next()??, parts.next()??, parts.next()??, !pre);
- parts.next().is_none().then_some(key)
-}
-
/// Whether a daemon reporting `running` is older than a client at `ours`.
/// Unparsable versions are never called outdated.
pub fn daemon_is_outdated(running: &str, ours: &str) -> bool {
diff --git a/libs/cua/crates/cua-daemon/src/identity.rs b/libs/cua/crates/cua-daemon/src/identity.rs
index cf9d494535..beff8e465c 100644
--- a/libs/cua/crates/cua-daemon/src/identity.rs
+++ b/libs/cua/crates/cua-daemon/src/identity.rs
@@ -97,6 +97,19 @@ pub enum Verdict {
Replace(String),
}
+/// `major.minor.patch` of a version string; a pre-release sorts before its
+/// release. `None` when it does not parse.
+pub(crate) fn version_key(version: &str) -> Option<(u64, u64, u64, bool)> {
+ let version = version.trim().trim_start_matches('v');
+ let (core, pre) = match version.split_once('-') {
+ Some((core, _)) => (core, true),
+ None => (version.split('+').next().unwrap_or(version), false),
+ };
+ let mut parts = core.split('.').map(|p| p.parse::<u64>().ok());
+ let key = (parts.next()??, parts.next()??, parts.next()??, !pre);
+ parts.next().is_none().then_some(key)
+}
+
/// The version a daemon reports: `version`, else the one in its `build_id`
/// (`<version>-<size hex>-<mtime ns hex>`).
fn reported_version<'a>(version: &'a str, build_id: &'a str) -> &'a str {
@@ -164,10 +177,7 @@ fn verdict_for(
if theirs.is_empty() { "unknown" } else { theirs }
));
}
- match (
- crate::client::version_key(theirs),
- crate::client::version_key(ours),
- ) {
+ match (version_key(theirs), version_key(ours)) {
(Some(t), Some(o)) if !same_file && t >= o => Verdict::Keep(format!(
"{} (cua {theirs}, not older than this app's {ours})",
if executable.is_empty() {