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