use otherone_agent::types::{AiOptions, InputOptions};
use otherone_agent::{AgentStreamHandle, StreamAgentEvent};
use otherone_ai::types::ProviderType;
use tokio::sync::mpsc;
pub struct Otherone;
impl Otherone {
pub fn multi_agent_runtime() -> otherone_agent::multi_agent::AgentRuntimeBuilder {
otherone_agent::multi_agent::AgentRuntime::builder()
}
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_agent_stream_interactive(
input: InputOptions,
ai: AiOptions,
auxiliary_ai: Option<AiOptions>,
) -> Result<AgentStreamHandle, otherone_agent::error::AgentError> {
otherone_agent::invoke_agent_stream_interactive(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 async fn create_new_session_in_database_with_context(
config: &otherone_storage::types::DatabaseConfig,
runtime_context: &otherone_storage::types::RuntimeContext,
) -> Result<String, otherone_storage::error::StorageError> {
otherone_storage::database::writer::create_new_session_in_database_with_context(
config,
runtime_context,
)
.await
}
pub fn get_all_sessions(
) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
otherone_storage::localfile::reader::get_all_sessions()
}
pub fn get_all_sessions_including_internal(
) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
otherone_storage::localfile::reader::get_all_sessions_with_internal(true)
}
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 async fn get_all_sessions_from_database_with_context(
config: &otherone_storage::types::DatabaseConfig,
runtime_context: &otherone_storage::types::RuntimeContext,
) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
otherone_storage::database::reader::get_all_sessions_from_database_with_context(
config,
runtime_context,
)
.await
}
pub async fn get_all_sessions_from_database_with_context_including_internal(
config: &otherone_storage::types::DatabaseConfig,
runtime_context: &otherone_storage::types::RuntimeContext,
) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
otherone_storage::database::reader::get_all_sessions_from_database_with_context_and_internal(
config,
runtime_context,
true,
)
.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 read_session_data_from_database_with_context(
session_id: &str,
config: &otherone_storage::types::DatabaseConfig,
runtime_context: &otherone_storage::types::RuntimeContext,
) -> Result<otherone_storage::types::SessionData, otherone_storage::error::StorageError> {
otherone_storage::database::reader::read_session_data_from_database_with_context(
session_id,
config,
runtime_context,
)
.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::multi_agent::{
AccessPolicy, AgentAccessPolicy, AgentCallAuthorizer, AgentCallId, AgentCallRequest,
AgentCallResult, AgentDefinition, AgentEvent, AgentEventEnvelope, AgentId, AgentInput,
AgentLimits, AgentOutput, AgentRegistry, AgentRunCommand, AgentRunCommandSender,
AgentRunHandle as MultiAgentRunHandle, AgentRunRequest, AgentRunResult, AgentRuntime,
AgentRuntimeBuilder, AuthorizationDecision, ContextTransferPolicy, DefaultModelExecutor,
EventVisibility, InMemoryRunStore, MemoryPolicy, ModelExecutor, ModelProfile, ModelProfileId,
ModelRegistry, ModelSelector, ResultContract, RunId, RunLimitOverrides, RunOutcome, RunRecord,
RunStatus, RunUsage, RuntimeLimits, RuntimePolicy, SessionTarget, SkillAccessPolicy,
ToolAccessPolicy, AGENT_CALL_TOOL_NAME, MEMORY_RECALL_TOOL_NAME, MEMORY_STORE_TOOL_NAME,
};
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::{AttributeBag, DatabaseConfig, RuntimeContext};
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::*;
}