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