Skip to main content

oxios_kernel/
lib.rs

1//! Oxios kernel: supervisor, event bus, state store.
2//!
3//! The kernel is the core of the Oxios Agent OS. Everything passes
4//! through here: agent lifecycle, inter-agent communication, and
5//! persistent state management.
6
7#![allow(missing_docs)]
8
9// ─── Lifecycle ──────────────────────────────────────────────────────
10// Agent 생성, 실행, 종료. OS의 init + process management.
11pub mod agent_group;
12pub mod agent_lifecycle;
13pub mod agent_runtime;
14pub mod daemon;
15pub mod readiness;
16pub mod streaming_sink;
17pub mod subagent_runner;
18pub mod supervisor;
19
20// ─── Agent History Log ──────────────────────────────────────────────
21// 에이전트 실행 기록 — SQLite + JSON dual storage.
22pub mod agent_log_db;
23
24// ─── Orchestration ──────────────────────────────────────────────────
25// 작업 조율, 스케줄링, 예산 관리.
26pub mod budget;
27pub mod cron;
28pub mod orchestrator;
29// ─── Resilience (RFC-029) ──────────────────────────────────────────────
30// Failure classification + (P2) recovery coordination.
31pub mod resilience;
32
33// ─── Security ───────────────────────────────────────────────────────
34pub mod approval;
35// 접근 제어, 인증, 권한, 감사.
36pub mod access_manager;
37pub mod auth;
38pub mod capability;
39pub mod credential;
40
41// ─── Audit Persistence ───────────────────────────────────────────────
42//
43// `audit_persistence` wires `oxi_sdk::observability::AuditPersistence`
44// to the kernel's filesystem-based `StateStore`. The trail itself
45// lives in `oxi_sdk::observability::AuditTrail` and is re-exported
46// below — RFC-014 Phase F.
47mod audit_persistence;
48
49// ─── Autonomous Persistence ─────────────────────────────────────────
50// RFC-016: Post-execution hook for auto-saving knowledge and memory.
51pub mod knowledge_dream;
52pub mod persistence_hook;
53
54// ─── Communication ──────────────────────────────────────────────────
55// 이벤트, 메시징, 외부 프로토콜, 멀티 에이전트 조정.
56pub mod a2a;
57pub mod coordination;
58pub mod email;
59pub mod event_bus;
60pub mod mcp;
61
62// ─── Intelligence ───────────────────────────────────────────────────
63// 메모리, 임베딩, 페르소나, 온보딩.
64pub mod embedding;
65pub mod memory;
66pub mod onboarding;
67pub mod persona;
68
69// ─── Tools & Skills ───────────────────────────────────────────────
70pub mod host_tools;
71pub mod skill;
72pub mod token_maxing;
73pub mod tools;
74#[cfg(feature = "wasm-sandbox")]
75pub mod wasm_sandbox;
76pub mod workers;
77
78// ─── State & Config ─────────────────────────────────────────────────
79// 영속 상태, 설정, 백업, 리소스 모니터링.
80pub mod backup;
81pub mod compression;
82pub mod config;
83pub mod git_layer;
84pub mod mount;
85pub mod project;
86pub mod resource_monitor;
87pub mod session_context;
88pub mod state_store;
89pub mod task;
90
91// ─── Infrastructure ─────────────────────────────────────────────────
92// 엔진, 에러, 타입, 메트릭, 텔레메트리, 옵저버빌리티.
93pub mod engine;
94pub mod error;
95pub mod image_gen;
96pub mod metrics;
97pub mod observability;
98pub mod types;
99
100// ─── API Surface ────────────────────────────────────────────────────
101// 외부에 노출하는 typed facade.
102pub mod kernel_handle;
103
104// ─────────────────────────────────────────────────────────────────────
105// Re-exports (같은 섹션 순서)
106// ─────────────────────────────────────────────────────────────────────
107
108// ─── Lifecycle ──────────────────────────────────────────────────────
109pub use agent_group::{OxiosAgentGroup, OxiosAgentGroupStatus, OxiosGroupAgent};
110pub use agent_lifecycle::AgentLifecycleManager;
111pub use agent_runtime::AgentRuntime;
112pub use daemon::{DaemonManager, DaemonStatus};
113pub use persistence_hook::PersistenceHook;
114pub use readiness::{ReadinessGate, SubsystemState};
115pub use supervisor::{BasicSupervisor, Supervisor};
116
117// ─── Orchestration ──────────────────────────────────────────────────
118pub use budget::{
119    BudgetExceeded, BudgetInfo, BudgetKind, BudgetLimit, BudgetManager, FullBudgetInfo,
120};
121// Circuit breaker — delegates to oxi-sdk
122pub use cron::{CronJob, CronJobResult, CronJobUpdate, CronScheduler, JobSource};
123pub use orchestrator::{AgentRole, OrchestrationResult, Orchestrator, SubTask};
124// CircuitBreaker removed — use oxi_sdk::ProviderCircuitBreaker directly (#11).
125pub use types::Priority;
126
127// ─── Security ───────────────────────────────────────────────────────
128pub use access_manager::{
129    AccessManager, Action, AgentPermissions, ApprovalStatus, PendingApproval, RbacAuditEntry,
130    RbacManager, RbacPolicy, Role, Subject,
131};
132// AuditTrail types are re-exported from oxi-sdk (Phase F: removed
133// 1134-line duplicate). `AgentId as AuditAgentId` preserves the
134// historical kernel-level type alias.
135pub use auth::{AuthManager, KeyMeta};
136pub use capability::template::CapabilityTemplate;
137pub use capability::{CSpace, Capability, CapabilityId, Issuer, ResourceRef, Rights};
138pub use credential::CredentialStore;
139pub use oxi_sdk::observability::audit_trail::AgentId as AuditAgentId;
140pub use oxi_sdk::observability::{
141    AuditAction, AuditError, AuditPersistence, AuditTrail, HashDigest, TrailEntry,
142};
143
144// ─── Communication ──────────────────────────────────────────────────
145pub use a2a::{
146    A2ACircuitBreaker, A2AMessage, A2AProtocol, A2ARequest, A2AResponse, AgentCard,
147    AgentCardRegistry, CircuitState, DelegationHandler, TaskPriority, TaskSpec,
148};
149pub use email::{SendReceipt, SmtpClient};
150pub use event_bus::{EventBus, KernelEvent};
151pub use mcp::{
152    McpBridge, McpCapabilities, McpServer, McpTool, McpToolCallResult as CallToolResult,
153};
154
155// ─── Intelligence ───────────────────────────────────────────────────
156pub use embedding::{EmbeddingProvider, EmbeddingVector, TfIdfEmbeddingProvider};
157
158// ─── GGUF Embedding (RFC-012) ──────────────────────────────────────
159#[cfg(feature = "embedding-gguf")]
160pub use embedding::gguf::{EmbeddingDimension, GgufEmbeddingProvider, GgufModelLoader};
161
162pub use memory::auto_memory_bridge::{
163    AutoMemoryBridge, ExportResult, GuidancePattern, ImportResult, InsightCategory, MemoryInsight,
164    SyncDirection, SyncResult,
165};
166pub use memory::{
167    DreamCheckpoint, DreamConfig, DreamProcess, DreamReport, HnswIndex, HnswMemoryIndex,
168    MemoryManager, ProactiveRecall, RecallTiming, SemanticHit,
169};
170pub use memory::{MemoryEntry, MemoryTier, MemoryType, ProtectionLevel, TextVector, content_hash};
171pub use oxios_memory::memory::flash_attention::{
172    BenchmarkResult as AttentionBenchmarkResult, FlashAttention, FlashAttentionConfig,
173    MemoryEstimate,
174};
175pub use oxios_memory::memory::{
176    HyperbolicConfig, HyperbolicEmbedding, batch_euclidean_to_poincare, euclidean_to_poincare,
177    hyperbolic_distance, mobius_add, mobius_scalar_mul,
178};
179pub use oxios_memory::{
180    AutoClassifier, AutoProtector, CompactionTree, CurationCandidate, CurationReport, DecayEngine,
181    EmbeddingCache, HistoricalPeriod, MemoryBudget, MemoryGraph, MemoryMapEntry, MemoryNeighbor,
182    RootEntry, RootIndex, SonaEngine, TopicEntry,
183};
184
185// ─── Memory core types (extracted to oxios-memory, RFC-018 b.1) ───
186// Re-exported here for back-compat — existing `use oxios_kernel::chunk_fixed;`
187// and friends continue to work without code changes.
188pub use oxios_memory::{
189    ChunkConfig, TextChunk, chunk_fixed, chunk_paragraphs, cosine_similarity_f32, l2_normalize_f32,
190    l2_normalize_f64,
191};
192
193// ─── SQLite Memory (RFC-012) ────────────────────────────────────────
194#[cfg(feature = "sqlite-memory")]
195pub use oxios_memory::memory::sqlite::SqliteMemoryStore;
196#[cfg(feature = "sqlite-memory")]
197pub use oxios_memory::memory::sqlite::cache::{self as sqlite_cache};
198#[cfg(feature = "sqlite-memory")]
199pub use oxios_memory::memory::sqlite::migration::{self as sqlite_migration, MigrationReport};
200#[cfg(feature = "sqlite-memory")]
201pub use oxios_memory::memory::sqlite::search::{
202    Bm25Hit, RankedMemory, VectorHit, reciprocal_rank_fusion,
203};
204#[cfg(feature = "sqlite-memory")]
205pub use oxios_memory::memory::sqlite::{MemoryDatabase, bytes_to_f32_slice, f32_slice_to_bytes};
206pub use persona::{Persona, PersonaManager, PersonaStore, default_personas};
207
208// ─── Tools & Skills ────────────────────────────────────────────────
209pub use skill::clawhub::{
210    ClawHubClient, ClawHubInstaller, ClawHubLockEntry, ClawHubLockfile, ClawHubOrigin,
211    ClawHubSearchResult, ClawHubSkillDetail, ClawHubSkillMeta, ClawHubVersion, DownloadedArchive,
212    InstallResult, UpdateAvailable, UpdateResult,
213};
214pub use skill::skills_sh::{
215    SkillsShAuditEntry, SkillsShAuditResponse, SkillsShClient, SkillsShFile, SkillsShInstallResult,
216    SkillsShInstaller, SkillsShOrigin, SkillsShSearchResponse, SkillsShSkill, SkillsShSkillDetail,
217};
218pub use skill::{
219    InstallKind, Requirements, RequirementsCheck, Skill, SkillConfig, SkillEntry, SkillFormat,
220    SkillInstallSpec, SkillInvocationPolicy, SkillManager, SkillMeta, SkillMetadata, SkillRef,
221    SkillSnapshot, SkillSource, SkillState, SkillStatus,
222};
223pub use tools::ToolMeta;
224pub use tools::tool_types::{ArgumentDef, ToolDef};
225pub use tools::{ExecTool, KnowledgeTool};
226#[cfg(feature = "wasm-sandbox")]
227pub use wasm_sandbox::{ResourceKind, WasmConfig, WasmError, WasmSandbox};
228// Token-maxing (RFC-031): self-tracker + QuotaTracker + maxer/planner/session.
229pub use kernel_handle::TokenMaxingApi;
230// Compression — LLM session summaries (LobeHub port).
231pub use compression::CompressionService;
232pub use kernel_handle::CompressionApi;
233pub use token_maxing::{
234    Availability, CooldownRecord, ProviderBudget, ProviderSnapshot, ProviderState, QuotaTracker,
235    QuotaTrackerSnapshot, RecalibrationOutcome, RecalibrationRecord, ReserveError,
236    SUBSCRIPTION_BILLING_MODEL, TokenMaxingConfig, TokenMaxingProviderConfig,
237};
238pub use token_maxing::{
239    MaxerStatus, MaxingStart, MaxingWindow, PlannedTask, TokenMaxer, TokenMaxingSession,
240    WorkPlanner,
241};
242
243// ─── State & Config ─────────────────────────────────────────────────
244pub use backup::{BackupManifest, BackupSection};
245pub use config::{
246    BrowserConfig, ChannelsConfig, CronConfig, DaemonConfig, EmailConfig, EmbeddingConfig,
247    EngineConfig, ExecConfig, ExecMode, GitConfig, InlineCronJob, LoggingConfig, MarketplaceConfig,
248    McpConfig, McpServerDef, MemoryConfig, MountsConfig, OrchestratorConfig, OxiosConfig,
249    PersonaConfig, SkillsShConfig, SqliteMemoryConfig,
250};
251pub use git_layer::{
252    CommitContext, CommitDiff, CommitInfo, DiffKind, DiffStats, FileDiff, GitLayer, LogEntry,
253};
254pub use mount::{
255    DetectionResult as MountDetectionResult, Mount, MountId, MountMeta, MountSource,
256    PromotionConfig, detect_mounts,
257};
258#[cfg(feature = "sqlite-memory")]
259pub use mount::{MountManager, MountManagerError};
260pub use project::{
261    ConversationBuffer, ConversationTurn, DetectionResult, Project, ProjectId, ProjectSource,
262    detect_project, extract_path, find_by_id, find_by_name,
263};
264#[cfg(feature = "sqlite-memory")]
265pub use project::{ProjectManager, ProjectManagerError};
266pub use resource_monitor::{OverloadThreshold, ResourceMonitor, ResourceSnapshot};
267pub use state_store::{
268    AgentResponse, PruneConfig, PruneThrottle, Session, SessionId, SessionSummary, StateStore,
269};
270
271// ─── Infrastructure ─────────────────────────────────────────────────
272pub use engine::{EngineHandle, EngineProvider, OxiosEngine};
273pub use error::{HttpStatus, KernelError, KernelResult};
274pub use metrics::{get_metrics, register_builtin_metrics, registry};
275pub use observability::{
276    AuditEntry as SdkAuditEntry, AuditFilter, CostSnapshot, CostTracker, Span, SpanGuard, SpanKind,
277    TokenUsage, Tracer as SdkTracer, audit_log, cost_tracker, tracer,
278};
279pub use types::{AgentId, AgentInfo, AgentStatus, ToolCallRecord};
280
281// ─── API Surface ────────────────────────────────────────────────────
282pub use host_tools::{CredentialStatus, DetectedTool, ToolSource};
283pub use kernel_handle::KernelHandle;
284pub use kernel_handle::MarketplaceApi;
285pub use kernel_handle::{
286    A2aApi, AgentApi, BrowserApi, CalendarApi, CopilotResponse, EmailApi, EngineApi,
287    EngineConfigResponse, ExecApi, ExtensionApi, FallbackEvent, HostToolsApi, InfraApi,
288    InputModality as EngineInputModality, KnowledgeContext, KnowledgeLens, KnowledgeNote, McpApi,
289    MemoryNote, ModelInfo, MountApi, MountInfo, PersonaApi, ProjectApi, ProjectInfo,
290    ProviderCategory, ProviderInfo, RoutingConfigSnapshot, RoutingStats, RoutingStatsSnapshot,
291    RoutingUpdate, SecurityApi, SharedExecConfig, StateApi, ValidateKeyResult,
292};
293pub use session_context::SessionContext;
294
295// ─── oxi-sdk re-exports ─────────────────────────────────────────────
296//
297// Removed: dead re-exports (#11). Consumers should depend on oxi-sdk
298// directly and use `oxi_sdk::` instead of going through oxios-kernel.