pub mod agent;
pub mod appraisal;
pub mod backlog;
pub mod batch;
pub mod boredom;
pub mod cache_lens;
pub mod candidate;
pub mod capture;
pub mod charter;
pub mod compact;
pub mod config;
pub mod counterfactual;
pub mod cron;
pub mod diagnose;
pub mod distill;
pub mod doctor;
pub mod eval;
pub mod frontdoor;
pub mod goal;
pub mod gossip;
pub mod guilt;
pub mod harness;
pub mod homeostat;
pub mod hooks;
pub mod image;
pub mod learning;
pub mod mail_triage;
pub mod mailbox;
pub mod mcp;
pub mod message;
pub mod onboarding;
pub mod outbox;
pub mod outbox_source;
pub mod permit;
pub mod pressure;
pub mod provider;
pub mod quarantine;
pub mod questions;
pub mod replay;
pub mod replay_run;
pub mod runlog;
pub mod runmarker;
pub mod sample;
pub mod sandbox;
pub mod search;
pub mod session;
pub mod skill;
pub mod step;
pub mod subagent;
pub mod surface;
pub(crate) mod text;
pub mod tool;
pub mod trigger;
pub mod work;
pub use agent::{Agent, AgentEvent, RunOutcome};
pub use config::Config;
pub use message::{Block, Effort, Message, Role, StopReason, Usage};
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn process_alive(pid: u32) -> bool {
let Ok(pid) = libc::pid_t::try_from(pid) else {
return false;
};
if pid <= 0 {
return false;
}
let rc = unsafe { libc::kill(pid, 0) };
rc == 0 || std::io::Error::last_os_error().kind() == std::io::ErrorKind::PermissionDenied
}
pub fn create_private_dir(dir: &std::path::Path) -> std::io::Result<()> {
std::fs::create_dir_all(dir)?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o700))?;
}
Ok(())
}
#[cfg(test)]
mod process_alive_tests {
#[test]
fn a_pid_that_is_not_a_pid_is_never_alive() {
assert!(!super::process_alive(u32::MAX));
assert!(!super::process_alive(0), "0 means my whole process group");
assert!(
!super::process_alive(i32::MAX as u32),
"real-looking and far above any pid_max"
);
assert!(
super::process_alive(std::process::id()),
"and the negative is not vacuous: we are alive"
);
}
}