feat(daemon): direct ollama/llama.cpp probing fallback in probe_capabilities() #260

Merged
clawdie merged 1 commit from feat/direct-capabilities-fallback into main 2026-06-28 08:13:04 +02:00

View file

@ -648,9 +648,11 @@ pub async fn autospawn_agent_if_configured(state: &SharedState) {
let caps = probe_capabilities();
match state.store.try_lock() {
Ok(store) => {
if let Err(e) =
store.register_agent(aid, serde_json::to_value(&caps).unwrap_or_default(), Some(&hostname))
{
if let Err(e) = store.register_agent(
aid,
serde_json::to_value(&caps).unwrap_or_default(),
Some(&hostname),
) {
warn!(agent_id = %aid, error = %e, "autospawn: failed to register agent in store");
} else {
info!(agent_id = %aid, hostname = %hostname, capabilities = ?caps, "autospawn: agent registered for task work");
@ -886,7 +888,7 @@ async fn try_register_hw_with_mother(hostname: &str, hw_profile: &str) {
}
/// Run `clawdie-hw-probe --capabilities` to get a dynamic capability list.
/// Falls back to a platform-agnostic minimum if the probe is unavailable.
/// Falls back to direct probing if the script is unavailable.
fn probe_capabilities() -> Vec<String> {
match std::process::Command::new("clawdie-hw-probe")
.arg("--capabilities")
@ -899,8 +901,42 @@ fn probe_capabilities() -> Vec<String> {
}
_ => {}
}
// Fallback: minimum capabilities that any zot node has.
vec!["shell".to_string(), "code".to_string()]
// Fallback: direct probing when hw-probe isn't available.
let mut caps = vec!["shell".to_string(), "code".to_string()];
// OS
caps.push(
if cfg!(target_os = "freebsd") {
"freebsd"
} else {
"linux"
}
.to_string(),
);
// ollama
if let Ok(out) = std::process::Command::new("ollama").arg("list").output() {
if out.status.success() && !out.stdout.is_empty() {
caps.push("ollama".to_string());
caps.push("local-llm".to_string());
}
}
// llama.cpp models
if let Ok(entries) = std::fs::read_dir("/var/db/models") {
if entries
.filter_map(|e| e.ok())
.any(|e| e.path().extension().map_or(false, |ext| ext == "gguf"))
{
if !caps.contains(&"local-llm".to_string()) {
caps.push("local-llm".to_string());
}
caps.push("llama-cpp".to_string());
}
}
caps
}
fn basename(path: &str) -> String {