ai-agent 0.13.4

Idiomatic agent sdk inspired by the claude code source leak
Documentation
use std::env;

pub fn get_env(key: &str) -> Option<String> {
    env::var(key).ok()
}

pub fn get_env_or(key: &str, default: &str) -> String {
    env::var(key).unwrap_or_else(|_| default.to_string())
}

pub fn get_env_bool(key: &str) -> bool {
    env::var(key)
        .map(|v| v == "1" || v.to_lowercase() == "true")
        .unwrap_or(false)
}

pub fn get_env_int(key: &str) -> Option<i64> {
    env::var(key).ok().and_then(|v| v.parse().ok())
}

pub fn set_env(key: &str, value: &str) {
    env::set_var(key, value);
}

pub fn remove_env(key: &str) {
    env::remove_var(key);
}

pub fn is_env_truthy(key: &str) -> bool {
    env::var(key)
        .map(|v| !v.is_empty() && v != "0" && v.to_lowercase() != "false")
        .unwrap_or(false)
}

pub fn get_platform() -> String {
    env::consts::OS.to_string()
}

pub fn is_windows() -> bool {
    cfg!(windows)
}

pub fn is_macos() -> bool {
    cfg!(target_os = "macos")
}

pub fn is_linux() -> bool {
    cfg!(target_os = "linux")
}