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 <poc@bcachefs.org>
This commit is contained in:
parent
9598e8b86c
commit
39965556dd
4 changed files with 1 additions and 56 deletions
|
|
@ -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<HttpResponse> {
|
||||
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<HttpResponse> {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -1008,8 +1008,6 @@ impl Agent {
|
|||
self.client.clone()
|
||||
}
|
||||
|
||||
pub fn entries_mut(&mut self) -> &mut Vec<ConversationEntry> {
|
||||
&mut self.context.entries
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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::<u32>() 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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue