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