pub mod a2a_api;
pub mod agent_api;
pub mod calendar_api;
pub mod email_api;
pub mod engine_api;
pub mod exec_api;
pub mod extension_api;
pub mod infra_api;
pub mod knowledge_lens;
pub mod marketplace_api;
pub mod mcp_api;
pub mod memory_api;
pub mod mount_api;
pub mod persona_api;
pub mod project_api;
pub mod security_api;
pub mod state_api;
pub use a2a_api::A2aApi;
pub use agent_api::AgentApi;
pub use calendar_api::CalendarApi;
pub use email_api::EmailApi;
pub use engine_api::{
EngineApi, EngineConfigResponse, FallbackEvent, InputModality, ModelInfo, ProviderCategory,
ProviderInfo, RoutingConfigSnapshot, RoutingStats, RoutingStatsSnapshot, RoutingUpdate,
ValidateKeyResult,
};
pub use exec_api::ExecApi;
pub use exec_api::SharedExecConfig;
pub use extension_api::ExtensionApi;
pub use infra_api::InfraApi;
pub use knowledge_lens::{
CopilotResponse, KnowledgeContext, KnowledgeLens, KnowledgeNote, MemoryNote,
};
pub use marketplace_api::MarketplaceApi;
pub use mcp_api::McpApi;
pub use memory_api::MemoryApi;
pub use mount_api::{MountApi, MountInfo};
pub use persona_api::PersonaApi;
pub use project_api::{ProjectApi, ProjectInfo};
pub use security_api::SecurityApi;
pub use state_api::StateApi;
use crate::git_layer::CommitInfo;
use crate::readiness::ReadinessGate;
use serde::Serialize;
use std::sync::Arc;
pub struct KernelHandle {
pub state: StateApi,
pub agents: AgentApi,
pub security: SecurityApi,
pub persona: PersonaApi,
pub extensions: ExtensionApi,
pub mcp: McpApi,
pub infra: InfraApi,
pub projects: Option<ProjectApi>,
pub mounts: Option<MountApi>,
pub exec: ExecApi,
pub a2a: A2aApi,
pub engine: EngineApi,
pub knowledge: Arc<oxios_markdown::KnowledgeBase>,
pub knowledge_lens: Arc<KnowledgeLens>,
pub marketplace_api: MarketplaceApi,
pub calendar: Option<CalendarApi>,
pub email: Option<EmailApi>,
pub readiness: Arc<ReadinessGate>,
}
impl KernelHandle {
#[allow(clippy::too_many_arguments)]
pub fn new(
state: StateApi,
agents: AgentApi,
security: SecurityApi,
persona: PersonaApi,
extensions: ExtensionApi,
mcp: McpApi,
infra: InfraApi,
projects: Option<ProjectApi>,
exec: ExecApi,
a2a: A2aApi,
engine: EngineApi,
knowledge: Arc<oxios_markdown::KnowledgeBase>,
knowledge_lens: Arc<KnowledgeLens>,
marketplace_api: MarketplaceApi,
calendar: Option<CalendarApi>,
email: Option<EmailApi>,
) -> Self {
Self {
state,
agents,
security,
persona,
extensions,
mcp,
infra,
projects,
mounts: None,
exec,
a2a,
engine,
knowledge,
knowledge_lens,
marketplace_api,
calendar,
email,
readiness: Arc::new(ReadinessGate::new(0)),
}
}
pub fn with_mounts(mut self, mounts: MountApi) -> Self {
self.mounts = Some(mounts);
self
}
pub fn set_mounts(&mut self, mounts: MountApi) {
self.mounts = Some(mounts);
}
pub async fn save_and_commit<T: Serialize>(
&self,
category: &str,
name: &str,
data: &T,
) -> anyhow::Result<()> {
self.state.save(category, name, data).await?;
let git = self.infra.git();
if git.is_enabled() {
let rel_path = format!("{category}/{name}.json");
let _ = git.commit_file(&rel_path, &format!("save {category}/{name}"));
}
Ok(())
}
pub async fn save_markdown_and_commit(
&self,
category: &str,
name: &str,
content: &str,
) -> anyhow::Result<()> {
self.state.save_markdown(category, name, content).await?;
let git = self.infra.git();
if git.is_enabled() {
let rel_path = format!("{category}/{name}.md");
let _ = git.commit_file(&rel_path, &format!("save {category}/{name}"));
}
Ok(())
}
pub async fn delete_and_commit(&self, category: &str, name: &str) -> anyhow::Result<bool> {
let deleted = self.state.delete(category, name).await?;
if deleted {
let git = self.infra.git();
if git.is_enabled() {
let rel_path = format!("{category}/{name}.json");
let _ = git.remove_file(&rel_path, &format!("delete {category}/{name}"));
}
}
Ok(deleted)
}
pub fn commit_all(&self, message: &str) -> anyhow::Result<Option<CommitInfo>> {
self.state.commit_all(self.infra.git(), message)
}
pub fn flush_audit(&self) -> anyhow::Result<()> {
self.security.flush(self.infra.git())
}
pub async fn schedule(
&self,
cron_expr: &str,
task: &str,
persona: Option<&str>,
) -> anyhow::Result<String> {
let _persona = persona.unwrap_or("default");
let job = crate::cron::CronJob::new(
format!("job_{}", uuid::Uuid::new_v4()),
cron_expr.to_string(),
task.to_string(),
);
let job_id = self.infra.add_cron(job).await?;
Ok(job_id.to_string())
}
pub async fn unschedule(&self, job_id: &str) -> anyhow::Result<bool> {
let uuid =
uuid::Uuid::parse_str(job_id).map_err(|e| anyhow::anyhow!("invalid job id: {e}"))?;
match self.infra.remove_cron(uuid).await {
Ok(()) => Ok(true),
Err(_) => Ok(false),
}
}
pub fn list_schedules(&self) -> Vec<crate::cron::CronJob> {
self.infra.list_crons()
}
pub async fn load_json<T: serde::de::DeserializeOwned>(
&self,
category: &str,
name: &str,
) -> anyhow::Result<Option<T>> {
self.state.load(category, name).await
}
pub fn start_time(&self) -> std::time::Instant {
self.infra.start_time
}
pub fn marketplace_api(&self) -> &MarketplaceApi {
&self.marketplace_api
}
pub fn memory(&self) -> MemoryApi {
let mm = self.agents.memory_manager().clone();
MemoryApi::new(mm)
}
}