use otherone_agent::types::{AiOptions, InputOptions};
use otherone_agent::StreamAgentEvent;
use otherone_ai::types::ProviderType;
use tokio::sync::mpsc;
pub struct Otherone;
impl Otherone {
pub fn set_localfile_root(root: impl Into<std::path::PathBuf>) {
otherone_storage::localfile::set_storage_root(root);
}
pub fn clear_localfile_root() {
otherone_storage::localfile::clear_storage_root();
}
pub fn localfile_storage_path() -> std::path::PathBuf {
otherone_storage::localfile::get_storage_path()
}
pub async fn invoke_agent(
input: &InputOptions,
ai: &mut AiOptions,
auxiliary_ai: Option<&mut AiOptions>,
) -> Result<otherone_ai::types::ParsedResponse, otherone_agent::error::AgentError> {
otherone_agent::invoke_agent(input, ai, auxiliary_ai).await
}
pub async fn invoke_agent_stream(
input: InputOptions,
ai: AiOptions,
auxiliary_ai: Option<AiOptions>,
) -> Result<mpsc::Receiver<StreamAgentEvent>, otherone_agent::error::AgentError> {
otherone_agent::invoke_agent_stream(input, ai, auxiliary_ai).await
}
pub async fn invoke_model(
provider: ProviderType,
api_key: &str,
base_url: &str,
config: serde_json::Value,
) -> Result<otherone_ai::types::ChatResponse, otherone_ai::error::AiError> {
otherone_ai::invoke_model(provider, api_key, base_url, config).await
}
pub fn process_tools(
tool_calls: &[otherone_ai::types::ToolCall],
tools_realize: &std::collections::HashMap<
String,
Box<dyn Fn(serde_json::Value) -> String + Send + Sync>,
>,
) -> Result<Vec<otherone_tools::types::ToolResult>, String> {
otherone_tools::process_tools(tool_calls, tools_realize)
}
pub fn check_threshold(
context_tokens: u32,
context_window: u32,
threshold_percentage: Option<f32>,
) -> bool {
otherone_context::compact::check_threshold::check_threshold(
context_tokens,
context_window,
threshold_percentage,
)
}
pub fn estimate_tokens(messages: &[otherone_ai::types::Message]) -> u32 {
otherone_context::compact::estimate_tokens::estimate_tokens(messages)
}
pub fn create_new_session() -> Result<String, otherone_storage::error::StorageError> {
otherone_storage::localfile::writer::create_new_session()
}
pub async fn create_new_session_in_database(
config: &otherone_storage::types::DatabaseConfig,
) -> Result<String, otherone_storage::error::StorageError> {
otherone_storage::database::writer::create_new_session_in_database(config).await
}
pub fn get_all_sessions(
) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
otherone_storage::localfile::reader::get_all_sessions()
}
pub async fn get_all_sessions_from_database(
config: &otherone_storage::types::DatabaseConfig,
) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
otherone_storage::database::reader::get_all_sessions_from_database(config).await
}
pub fn read_session_data(
session_id: &str,
) -> Result<otherone_storage::types::SessionData, otherone_storage::error::StorageError> {
otherone_storage::localfile::reader::read_session_data(session_id)
}
pub async fn read_session_data_from_database(
session_id: &str,
config: &otherone_storage::types::DatabaseConfig,
) -> Result<otherone_storage::types::SessionData, otherone_storage::error::StorageError> {
otherone_storage::database::reader::read_session_data_from_database(session_id, config)
.await
}
pub async fn init_database(
config: &otherone_storage::types::DatabaseConfig,
) -> Result<(), otherone_storage::error::StorageError> {
otherone_storage::database::init::init_database(config).await
}
pub fn read_storage_file(
) -> Result<otherone_storage::types::StorageFile, otherone_storage::error::StorageError> {
otherone_storage::localfile::reader::read_storage_file()
}
pub async fn combine_context(
options: &otherone_context::types::CombineContextOptions,
) -> Result<Vec<otherone_ai::types::Message>, otherone_context::error::ContextError> {
otherone_context::combine_context(options).await
}
pub async fn compact_messages(
messages: &[otherone_ai::types::Message],
context_tokens: u32,
context_window: u32,
compact_ratio: Option<f32>,
ai_config: Option<&serde_json::Value>,
has_compacted_content: bool,
session_id: Option<&str>,
storage_type: Option<&otherone_storage::types::StorageType>,
database_config: Option<&otherone_storage::types::DatabaseConfig>,
original_entries: Option<&[otherone_storage::types::Entry]>,
) -> Result<Vec<otherone_ai::types::Message>, otherone_context::error::ContextError> {
otherone_context::compact::compact_messages(
messages,
context_tokens,
context_window,
compact_ratio,
ai_config,
has_compacted_content,
session_id,
storage_type,
database_config,
original_entries,
)
.await
}
}
pub use otherone_agent::types::{ContextLoadType as AgentContextLoadType, StorageType};
pub use otherone_storage::database::mongodb;
pub use otherone_storage::database::mysql;
pub use otherone_storage::localfile::encrypt;
pub use otherone_storage::redis;
pub use otherone_storage::types::DatabaseConfig;
pub mod ai {
pub use otherone_ai::*;
}
pub mod agent {
pub use otherone_agent::*;
}
pub mod context {
pub use otherone_context::*;
}
pub mod memory {
pub use otherone_memory::*;
}
pub mod tools {
pub use otherone_tools::*;
}
pub mod storage {
pub use otherone_storage::*;
}
pub mod skills {
pub use otherone_skills::*;
}
pub mod mcp {
pub use otherone_mcp::*;
}