mod agent;
mod config;
mod error;
mod ffi;
mod result;
pub use agent::GopherAgent;
pub use config::{Config, ConfigBuilder};
pub use error::{Error, Result};
pub use result::{AgentResult, AgentResultStatus};
#[cfg(feature = "auth")]
pub use ffi::auth::{GopherAuthClient, TokenPayload, ValidationResult};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Once;
static INIT: Once = Once::new();
static INITIALIZED: AtomicBool = AtomicBool::new(false);
pub fn init() -> Result<()> {
let mut init_result = Ok(());
INIT.call_once(|| {
if !ffi::is_available() {
init_result = Err(Error::Library(
"Failed to load gopher-orch native library".into(),
));
return;
}
INITIALIZED.store(true, Ordering::SeqCst);
});
init_result
}
pub fn is_initialized() -> bool {
INITIALIZED.load(Ordering::SeqCst)
}
pub fn shutdown() {
INITIALIZED.store(false, Ordering::SeqCst);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_init() {
let _ = init();
}
#[test]
fn test_config_builder() {
let config = ConfigBuilder::new()
.with_provider("TestProvider")
.with_model("test-model")
.with_api_key("test-key")
.build();
assert_eq!(config.provider(), "TestProvider");
assert_eq!(config.model(), "test-model");
assert!(config.has_api_key());
}
}