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 ───────────────────────────────────────────────────────
34// 접근 제어, 인증, 권한, 감사.
35pub mod access_manager;
36pub mod auth;
37pub mod capability;
38pub mod credential;
39
40// ─── Audit Persistence ───────────────────────────────────────────────
41//
42// `audit_persistence` wires `oxi_sdk::observability::AuditPersistence`
43// to the kernel's filesystem-based `StateStore`. The trail itself
44// lives in `oxi_sdk::observability::AuditTrail` and is re-exported
45// below — RFC-014 Phase F.
46mod audit_persistence;
47
48// ─── Autonomous Persistence ─────────────────────────────────────────
49// RFC-016: Post-execution hook for auto-saving knowledge and memory.
50pub mod knowledge_dream;
51pub mod persistence_hook;
52
53// ─── Communication ──────────────────────────────────────────────────
54// 이벤트, 메시징, 외부 프로토콜, 멀티 에이전트 조정.
55pub mod a2a;
56pub mod coordination;
57pub mod email;
58pub mod event_bus;
59pub mod mcp;
60
61// ─── Intelligence ───────────────────────────────────────────────────
62// 메모리, 임베딩, 페르소나, 온보딩.
63pub mod embedding;
64pub mod memory;
65pub mod onboarding;
66pub mod persona;
67
68// ─── Tools & Skills ───────────────────────────────────────────────
69pub mod skill;
70pub mod token_maxing;
71pub mod tools;
72#[cfg(feature = "wasm-sandbox")]
73pub mod wasm_sandbox;
74pub mod workers;
75
76// ─── State & Config ─────────────────────────────────────────────────
77// 영속 상태, 설정, 백업, 리소스 모니터링.
78pub mod backup;
79pub mod config;
80pub mod git_layer;
81pub mod mount;
82pub mod project;
83pub mod resource_monitor;
84pub mod session_context;
85pub mod state_store;
86
87// ─── Infrastructure ─────────────────────────────────────────────────
88// 엔진, 에러, 타입, 메트릭, 텔레메트리, 옵저버빌리티.
89pub mod engine;
90pub mod error;
91pub mod metrics;
92pub mod observability;
93#[cfg(feature = "otel")]
94pub mod telemetry_otel;
95pub mod types;
96#[cfg(feature = "otel")]
97pub use telemetry_otel as telemetry;
98#[cfg(not(feature = "otel"))]
99pub mod telemetry_stub;
100#[cfg(not(feature = "otel"))]
101pub use telemetry_stub as telemetry;
102
103// ─── API Surface ────────────────────────────────────────────────────
104// 외부에 노출하는 typed facade.
105pub mod kernel_handle;
106
107// ─────────────────────────────────────────────────────────────────────
108// Re-exports (같은 섹션 순서)
109// ─────────────────────────────────────────────────────────────────────
110
111// ─── Lifecycle ──────────────────────────────────────────────────────
112pub use agent_group::{OxiosAgentGroup, OxiosAgentGroupStatus, OxiosGroupAgent};
113pub use agent_lifecycle::AgentLifecycleManager;
114pub use agent_runtime::AgentRuntime;
115pub use daemon::{DaemonManager, DaemonStatus};
116pub use persistence_hook::PersistenceHook;
117pub use readiness::{ReadinessGate, SubsystemState};
118pub use supervisor::{BasicSupervisor, Supervisor};
119
120// ─── Orchestration ──────────────────────────────────────────────────
121pub use budget::{
122    BudgetExceeded, BudgetInfo, BudgetKind, BudgetLimit, BudgetManager, FullBudgetInfo,
123};
124// Circuit breaker — delegates to oxi-sdk
125pub use cron::{CronJob, CronJobResult, CronJobUpdate, CronScheduler, JobSource};
126pub use orchestrator::{AgentRole, OrchestrationResult, Orchestrator, SubTask};
127// CircuitBreaker removed — use oxi_sdk::ProviderCircuitBreaker directly (#11).
128pub use types::Priority;
129
130// ─── Security ───────────────────────────────────────────────────────
131pub use access_manager::{
132    AccessManager, Action, AgentPermissions, ApprovalStatus, PendingApproval, RbacAuditEntry,
133    RbacManager, RbacPolicy, Role, Subject,
134};
135// AuditTrail types are re-exported from oxi-sdk (Phase F: removed
136// 1134-line duplicate). `AgentId as AuditAgentId` preserves the
137// historical kernel-level type alias.
138pub use auth::{AuthManager, KeyMeta};
139pub use capability::template::CapabilityTemplate;
140pub use capability::{CSpace, Capability, CapabilityId, Issuer, ResourceRef, Rights};
141pub use credential::CredentialStore;
142pub use oxi_sdk::observability::audit_trail::AgentId as AuditAgentId;
143pub use oxi_sdk::observability::{
144    AuditAction, AuditError, AuditPersistence, AuditTrail, HashDigest, TrailEntry,
145};
146
147// ─── Communication ──────────────────────────────────────────────────
148pub use a2a::{
149    A2ACircuitBreaker, A2AMessage, A2AProtocol, A2ARequest, A2AResponse, AgentCard,
150    AgentCardRegistry, CircuitState, DelegationHandler, TaskPriority, TaskSpec,
151};
152pub use email::{SendReceipt, SmtpClient};
153pub use event_bus::{EventBus, KernelEvent};
154pub use mcp::{
155    McpBridge, McpCapabilities, McpServer, McpTool, McpToolCallResult as CallToolResult,
156};
157
158// ─── Intelligence ───────────────────────────────────────────────────
159pub use embedding::{EmbeddingProvider, EmbeddingVector, TfIdfEmbeddingProvider};
160
161// ─── GGUF Embedding (RFC-012) ──────────────────────────────────────
162#[cfg(feature = "embedding-gguf")]
163pub use embedding::gguf::{EmbeddingDimension, GgufEmbeddingProvider, GgufModelLoader};
164
165pub use memory::auto_memory_bridge::{
166    AutoMemoryBridge, ExportResult, GuidancePattern, ImportResult, InsightCategory, MemoryInsight,
167    SyncDirection, SyncResult,
168};
169pub use memory::{
170    DreamCheckpoint, DreamConfig, DreamProcess, DreamReport, HnswIndex, HnswMemoryIndex,
171    MemoryManager, ProactiveRecall, RecallTiming, SemanticHit,
172};
173pub use memory::{MemoryEntry, MemoryTier, MemoryType, ProtectionLevel, TextVector, content_hash};
174pub use oxios_memory::memory::flash_attention::{
175    BenchmarkResult as AttentionBenchmarkResult, FlashAttention, FlashAttentionConfig,
176    MemoryEstimate,
177};
178pub use oxios_memory::memory::{
179    HyperbolicConfig, HyperbolicEmbedding, batch_euclidean_to_poincare, euclidean_to_poincare,
180    hyperbolic_distance, mobius_add, mobius_scalar_mul,
181};
182pub use oxios_memory::{
183    AutoClassifier, AutoProtector, CompactionTree, CurationCandidate, CurationReport, DecayEngine,
184    EmbeddingCache, HistoricalPeriod, MemoryBudget, MemoryGraph, MemoryMapEntry, MemoryNeighbor,
185    RootEntry, RootIndex, SonaEngine, TopicEntry,
186};
187
188// ─── Memory core types (extracted to oxios-memory, RFC-018 b.1) ───
189// Re-exported here for back-compat — existing `use oxios_kernel::chunk_fixed;`
190// and friends continue to work without code changes.
191pub use oxios_memory::{
192    ChunkConfig, TextChunk, chunk_fixed, chunk_paragraphs, cosine_similarity_f32, l2_normalize_f32,
193    l2_normalize_f64,
194};
195
196// ─── SQLite Memory (RFC-012) ────────────────────────────────────────
197#[cfg(feature = "sqlite-memory")]
198pub use oxios_memory::memory::sqlite::SqliteMemoryStore;
199#[cfg(feature = "sqlite-memory")]
200pub use oxios_memory::memory::sqlite::cache::{self as sqlite_cache};
201#[cfg(feature = "sqlite-memory")]
202pub use oxios_memory::memory::sqlite::migration::{self as sqlite_migration, MigrationReport};
203#[cfg(feature = "sqlite-memory")]
204pub use oxios_memory::memory::sqlite::search::{
205    Bm25Hit, RankedMemory, VectorHit, reciprocal_rank_fusion,
206};
207#[cfg(feature = "sqlite-memory")]
208pub use oxios_memory::memory::sqlite::{MemoryDatabase, bytes_to_f32_slice, f32_slice_to_bytes};
209pub use persona::{Persona, PersonaManager, PersonaStore, default_personas};
210
211// ─── Tools & Skills ────────────────────────────────────────────────
212pub use skill::clawhub::{
213    ClawHubClient, ClawHubInstaller, ClawHubLockEntry, ClawHubLockfile, ClawHubOrigin,
214    ClawHubSearchResult, ClawHubSkillDetail, ClawHubSkillMeta, ClawHubVersion, DownloadedArchive,
215    InstallResult, UpdateAvailable, UpdateResult,
216};
217pub use skill::skills_sh::{
218    SkillsShAuditEntry, SkillsShAuditResponse, SkillsShClient, SkillsShFile, SkillsShInstallResult,
219    SkillsShInstaller, SkillsShOrigin, SkillsShSearchResponse, SkillsShSkill, SkillsShSkillDetail,
220};
221pub use skill::{
222    InstallKind, Requirements, RequirementsCheck, Skill, SkillConfig, SkillEntry, SkillFormat,
223    SkillInstallSpec, SkillInvocationPolicy, SkillManager, SkillMeta, SkillMetadata, SkillRef,
224    SkillSnapshot, SkillSource, SkillState, SkillStatus,
225};
226pub use tools::ToolMeta;
227pub use tools::tool_types::{ArgumentDef, ToolDef};
228pub use tools::{ExecTool, KnowledgeTool};
229#[cfg(feature = "wasm-sandbox")]
230pub use wasm_sandbox::{ResourceKind, WasmConfig, WasmError, WasmSandbox};
231// Token-maxing (RFC-031): self-tracker + QuotaTracker + maxer/planner/session.
232pub use kernel_handle::TokenMaxingApi;
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 kernel_handle::KernelHandle;
283pub use kernel_handle::MarketplaceApi;
284pub use kernel_handle::{
285    A2aApi, AgentApi, CalendarApi, CopilotResponse, EmailApi, EngineApi, EngineConfigResponse,
286    ExecApi, ExtensionApi, FallbackEvent, InfraApi, InputModality as EngineInputModality,
287    KnowledgeContext, KnowledgeLens, KnowledgeNote, McpApi, MemoryNote, ModelInfo, MountApi,
288    MountInfo, PersonaApi, ProjectApi, ProjectInfo, ProviderCategory, ProviderInfo,
289    RoutingConfigSnapshot, RoutingStats, RoutingStatsSnapshot, RoutingUpdate, SecurityApi,
290    SharedExecConfig, StateApi, ValidateKeyResult,
291};
292pub use session_context::SessionContext;
293
294// ─── oxi-sdk re-exports ─────────────────────────────────────────────
295//
296// Removed: dead re-exports (#11). Consumers should depend on oxi-sdk
297// directly and use `oxi_sdk::` instead of going through oxios-kernel.