From 39965556dd444ddd68487c8401c5932c575e4ec3 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 7 Apr 2026 13:25:18 -0400 Subject: [PATCH] Remove dead code: scan_pid_files, backend_label, entries_mut, post_json All confirmed unused anywhere in src/ or channels/. Co-Authored-By: Proof of Concept --- src/agent/api/http.rs | 9 --------- src/agent/api/mod.rs | 8 -------- src/agent/mod.rs | 4 +--- src/agent/oneshot.rs | 36 ------------------------------------ 4 files changed, 1 insertion(+), 56 deletions(-) diff --git a/src/agent/api/http.rs b/src/agent/api/http.rs index c11efdd..6220792 100644 --- a/src/agent/api/http.rs +++ b/src/agent/api/http.rs @@ -56,15 +56,6 @@ impl HttpClient { self.send_empty(req).await } - /// Send a POST request with a JSON body. - pub async fn post_json(&self, url: &str, body: &impl serde::Serialize) -> Result { - let json = serde_json::to_vec(body).context("serializing JSON body")?; - let req = Request::post(url) - .header("content-type", "application/json") - .body(Full::new(Bytes::from(json))) - .context("building POST request")?; - self.send_full(req).await - } /// Send a POST request with URL-encoded form data. pub async fn post_form(&self, url: &str, params: &[(&str, &str)]) -> Result { diff --git a/src/agent/api/mod.rs b/src/agent/api/mod.rs index b67307e..38fe71d 100644 --- a/src/agent/api/mod.rs +++ b/src/agent/api/mod.rs @@ -187,14 +187,6 @@ impl ApiClient { pub fn base_url(&self) -> &str { &self.base_url } pub fn api_key(&self) -> &str { &self.api_key } - /// Return a label for the active backend, used in startup info. - pub fn backend_label(&self) -> &str { - if self.base_url.contains("openrouter") { - "openrouter" - } else { - "openai-compat" - } - } } /// Send an HTTP request and check for errors. Shared by both backends. diff --git a/src/agent/mod.rs b/src/agent/mod.rs index 016ce97..98f2e3f 100644 --- a/src/agent/mod.rs +++ b/src/agent/mod.rs @@ -1008,8 +1008,6 @@ impl Agent { self.client.clone() } - pub fn entries_mut(&mut self) -> &mut Vec { - &mut self.context.entries - } + } diff --git a/src/agent/oneshot.rs b/src/agent/oneshot.rs index fb34060..cb2a24d 100644 --- a/src/agent/oneshot.rs +++ b/src/agent/oneshot.rs @@ -549,42 +549,6 @@ pub fn call_api_with_tools_sync( // Process management — PID tracking and subprocess spawning // --------------------------------------------------------------------------- -/// Check for live agent processes in a state dir. Returns (phase, pid) pairs. -/// Cleans up stale pid files and kills timed-out processes. -pub fn scan_pid_files(state_dir: &std::path::Path, timeout_secs: u64) -> Vec<(String, u32)> { - let mut live = Vec::new(); - let Ok(entries) = fs::read_dir(state_dir) else { return live }; - for entry in entries.flatten() { - let name = entry.file_name(); - let name_str = name.to_string_lossy(); - let Some(pid_str) = name_str.strip_prefix("pid-") else { continue }; - let Ok(pid) = pid_str.parse::() else { continue }; - - if unsafe { libc::kill(pid as i32, 0) } != 0 { - fs::remove_file(entry.path()).ok(); - continue; - } - - if timeout_secs > 0 { - if let Ok(meta) = entry.metadata() { - if let Ok(modified) = meta.modified() { - if modified.elapsed().unwrap_or_default().as_secs() > timeout_secs { - unsafe { libc::kill(pid as i32, libc::SIGTERM); } - fs::remove_file(entry.path()).ok(); - continue; - } - } - } - } - - let phase = fs::read_to_string(entry.path()) - .unwrap_or_default() - .trim().to_string(); - live.push((phase, pid)); - } - live -} - pub struct SpawnResult { pub child: std::process::Child, pub log_path: PathBuf,