1use otherone_agent::types::{AiOptions, InputOptions};
6use otherone_agent::{AgentStreamHandle, StreamAgentEvent};
7use otherone_ai::types::ProviderType;
8use tokio::sync::mpsc;
9
10pub struct Otherone;
12
13impl Otherone {
14 pub fn multi_agent_runtime() -> otherone_agent::multi_agent::AgentRuntimeBuilder {
16 otherone_agent::multi_agent::AgentRuntime::builder()
17 }
18
19 pub fn set_localfile_root(root: impl Into<std::path::PathBuf>) {
25 otherone_storage::localfile::set_storage_root(root);
26 }
27
28 pub fn clear_localfile_root() {
30 otherone_storage::localfile::clear_storage_root();
31 }
32
33 pub fn localfile_storage_path() -> std::path::PathBuf {
35 otherone_storage::localfile::get_storage_path()
36 }
37
38 pub async fn invoke_agent(
40 input: &InputOptions,
41 ai: &mut AiOptions,
42 auxiliary_ai: Option<&mut AiOptions>,
43 ) -> Result<otherone_ai::types::ParsedResponse, otherone_agent::error::AgentError> {
44 otherone_agent::invoke_agent(input, ai, auxiliary_ai).await
45 }
46
47 pub async fn invoke_agent_stream(
52 input: InputOptions,
53 ai: AiOptions,
54 auxiliary_ai: Option<AiOptions>,
55 ) -> Result<mpsc::Receiver<StreamAgentEvent>, otherone_agent::error::AgentError> {
56 otherone_agent::invoke_agent_stream(input, ai, auxiliary_ai).await
57 }
58
59 pub async fn invoke_agent_stream_interactive(
62 input: InputOptions,
63 ai: AiOptions,
64 auxiliary_ai: Option<AiOptions>,
65 ) -> Result<AgentStreamHandle, otherone_agent::error::AgentError> {
66 otherone_agent::invoke_agent_stream_interactive(input, ai, auxiliary_ai).await
67 }
68
69 pub async fn invoke_model(
71 provider: ProviderType,
72 api_key: &str,
73 base_url: &str,
74 config: serde_json::Value,
75 ) -> Result<otherone_ai::types::ChatResponse, otherone_ai::error::AiError> {
76 otherone_ai::invoke_model(provider, api_key, base_url, config).await
77 }
78
79 pub fn process_tools(
81 tool_calls: &[otherone_ai::types::ToolCall],
82 tools_realize: &std::collections::HashMap<
83 String,
84 Box<dyn Fn(serde_json::Value) -> String + Send + Sync>,
85 >,
86 ) -> Result<Vec<otherone_tools::types::ToolResult>, String> {
87 otherone_tools::process_tools(tool_calls, tools_realize)
88 }
89
90 pub fn check_threshold(
92 context_tokens: u32,
93 context_window: u32,
94 threshold_percentage: Option<f32>,
95 ) -> bool {
96 otherone_context::compact::check_threshold::check_threshold(
97 context_tokens,
98 context_window,
99 threshold_percentage,
100 )
101 }
102
103 pub fn estimate_tokens(messages: &[otherone_ai::types::Message]) -> u32 {
105 otherone_context::compact::estimate_tokens::estimate_tokens(messages)
106 }
107
108 pub fn create_new_session() -> Result<String, otherone_storage::error::StorageError> {
110 otherone_storage::localfile::writer::create_new_session()
111 }
112
113 pub async fn create_new_session_in_database(
115 config: &otherone_storage::types::DatabaseConfig,
116 ) -> Result<String, otherone_storage::error::StorageError> {
117 otherone_storage::database::writer::create_new_session_in_database(config).await
118 }
119
120 pub async fn create_new_session_in_database_with_context(
121 config: &otherone_storage::types::DatabaseConfig,
122 runtime_context: &otherone_storage::types::RuntimeContext,
123 ) -> Result<String, otherone_storage::error::StorageError> {
124 otherone_storage::database::writer::create_new_session_in_database_with_context(
125 config,
126 runtime_context,
127 )
128 .await
129 }
130
131 pub fn get_all_sessions(
133 ) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
134 otherone_storage::localfile::reader::get_all_sessions()
135 }
136
137 pub fn get_all_sessions_including_internal(
139 ) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
140 otherone_storage::localfile::reader::get_all_sessions_with_internal(true)
141 }
142
143 pub async fn get_all_sessions_from_database(
145 config: &otherone_storage::types::DatabaseConfig,
146 ) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
147 otherone_storage::database::reader::get_all_sessions_from_database(config).await
148 }
149
150 pub async fn get_all_sessions_from_database_with_context(
151 config: &otherone_storage::types::DatabaseConfig,
152 runtime_context: &otherone_storage::types::RuntimeContext,
153 ) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
154 otherone_storage::database::reader::get_all_sessions_from_database_with_context(
155 config,
156 runtime_context,
157 )
158 .await
159 }
160
161 pub async fn get_all_sessions_from_database_with_context_including_internal(
163 config: &otherone_storage::types::DatabaseConfig,
164 runtime_context: &otherone_storage::types::RuntimeContext,
165 ) -> Result<Vec<otherone_storage::types::Session>, otherone_storage::error::StorageError> {
166 otherone_storage::database::reader::get_all_sessions_from_database_with_context_and_internal(
167 config,
168 runtime_context,
169 true,
170 )
171 .await
172 }
173
174 pub fn read_session_data(
176 session_id: &str,
177 ) -> Result<otherone_storage::types::SessionData, otherone_storage::error::StorageError> {
178 otherone_storage::localfile::reader::read_session_data(session_id)
179 }
180
181 pub async fn read_session_data_from_database(
183 session_id: &str,
184 config: &otherone_storage::types::DatabaseConfig,
185 ) -> Result<otherone_storage::types::SessionData, otherone_storage::error::StorageError> {
186 otherone_storage::database::reader::read_session_data_from_database(session_id, config)
187 .await
188 }
189
190 pub async fn read_session_data_from_database_with_context(
191 session_id: &str,
192 config: &otherone_storage::types::DatabaseConfig,
193 runtime_context: &otherone_storage::types::RuntimeContext,
194 ) -> Result<otherone_storage::types::SessionData, otherone_storage::error::StorageError> {
195 otherone_storage::database::reader::read_session_data_from_database_with_context(
196 session_id,
197 config,
198 runtime_context,
199 )
200 .await
201 }
202
203 pub async fn init_database(
205 config: &otherone_storage::types::DatabaseConfig,
206 ) -> Result<(), otherone_storage::error::StorageError> {
207 otherone_storage::database::init::init_database(config).await
208 }
209
210 pub fn read_storage_file(
215 ) -> Result<otherone_storage::types::StorageFile, otherone_storage::error::StorageError> {
216 otherone_storage::localfile::reader::read_storage_file()
217 }
218
219 pub async fn combine_context(
224 options: &otherone_context::types::CombineContextOptions,
225 ) -> Result<Vec<otherone_ai::types::Message>, otherone_context::error::ContextError> {
226 otherone_context::combine_context(options).await
227 }
228
229 pub async fn compact_messages(
234 messages: &[otherone_ai::types::Message],
235 context_tokens: u32,
236 context_window: u32,
237 compact_ratio: Option<f32>,
238 ai_config: Option<&serde_json::Value>,
239 has_compacted_content: bool,
240 session_id: Option<&str>,
241 storage_type: Option<&otherone_storage::types::StorageType>,
242 database_config: Option<&otherone_storage::types::DatabaseConfig>,
243 original_entries: Option<&[otherone_storage::types::Entry]>,
244 ) -> Result<Vec<otherone_ai::types::Message>, otherone_context::error::ContextError> {
245 otherone_context::compact::compact_messages(
246 messages,
247 context_tokens,
248 context_window,
249 compact_ratio,
250 ai_config,
251 has_compacted_content,
252 session_id,
253 storage_type,
254 database_config,
255 original_entries,
256 )
257 .await
258 }
259}
260
261pub use otherone_agent::multi_agent::{
263 AccessPolicy, AgentAccessPolicy, AgentCallAuthorizer, AgentCallId, AgentCallRequest,
264 AgentCallResult, AgentDefinition, AgentEvent, AgentEventEnvelope, AgentId, AgentInput,
265 AgentLimits, AgentOutput, AgentRegistry, AgentRunCommand, AgentRunCommandSender,
266 AgentRunHandle as MultiAgentRunHandle, AgentRunRequest, AgentRunResult, AgentRuntime,
267 AgentRuntimeBuilder, AuthorizationDecision, ContextTransferPolicy, DefaultModelExecutor,
268 EventVisibility, InMemoryRunStore, MemoryPolicy, ModelExecutor, ModelProfile, ModelProfileId,
269 ModelRegistry, ModelSelector, ResultContract, RunId, RunLimitOverrides, RunOutcome, RunRecord,
270 RunStatus, RunUsage, RuntimeLimits, RuntimePolicy, SessionTarget, SkillAccessPolicy,
271 ToolAccessPolicy, AGENT_CALL_TOOL_NAME, MEMORY_RECALL_TOOL_NAME, MEMORY_STORE_TOOL_NAME,
272};
273pub use otherone_agent::types::{ContextLoadType as AgentContextLoadType, StorageType};
274pub use otherone_storage::database::mongodb;
275pub use otherone_storage::database::mysql;
276pub use otherone_storage::localfile::encrypt;
277pub use otherone_storage::redis;
278pub use otherone_storage::types::{AttributeBag, DatabaseConfig, RuntimeContext};
279
280pub mod ai {
282 pub use otherone_ai::*;
283}
284pub mod agent {
285 pub use otherone_agent::*;
286}
287pub mod context {
288 pub use otherone_context::*;
289}
290pub mod memory {
291 pub use otherone_memory::*;
292}
293pub mod tools {
294 pub use otherone_tools::*;
295}
296pub mod storage {
297 pub use otherone_storage::*;
298}
299pub mod skills {
300 pub use otherone_skills::*;
301}
302pub mod mcp {
303 pub use otherone_mcp::*;
304}