Core Module¶
The core module contains the foundational abstractions shared across all OpenJarvis pillars: the decorator-based registry system for runtime discovery, canonical data types, configuration loading with hardware detection, and the pub/sub event bus for inter-pillar communication.
Registry System¶
The registry pattern is the primary extension mechanism. Each pillar has its
own typed registry subclass. New implementations are added by decorating a
class with @XRegistry.register("name").
RegistryBase¶
RegistryBase
¶
Bases: Generic[T]
Generic registry base class with class-specific entry isolation.
Functions¶
register
classmethod
¶
Decorator that registers entry under key.
Source code in src/openjarvis/core/registry.py
register_value
classmethod
¶
Imperatively register a value under key.
Source code in src/openjarvis/core/registry.py
get
classmethod
¶
Retrieve the entry for key, raising KeyError if missing.
Source code in src/openjarvis/core/registry.py
create
classmethod
¶
Look up key and instantiate it with the given arguments.
Source code in src/openjarvis/core/registry.py
items
classmethod
¶
keys
classmethod
¶
contains
classmethod
¶
ModelRegistry¶
ModelRegistry
¶
EngineRegistry¶
EngineRegistry
¶
MemoryRegistry¶
MemoryRegistry
¶
AgentRegistry¶
AgentRegistry
¶
ToolRegistry¶
ToolRegistry
¶
RouterPolicyRegistry¶
RouterPolicyRegistry
¶
BenchmarkRegistry¶
BenchmarkRegistry
¶
ChannelRegistry¶
ChannelRegistry
¶
LearningRegistry¶
LearningRegistry
¶
Types¶
Canonical data types shared across all OpenJarvis pillars, including message structures, model specifications, telemetry records, and trace objects.
Role¶
Role
¶
Bases: str, Enum
Chat message roles (OpenAI-compatible).
Quantization¶
Quantization
¶
Bases: str, Enum
Model quantization formats.
StepType¶
StepType
¶
Bases: str, Enum
Types of steps within an agent trace.
ToolCall¶
ToolCall
dataclass
¶
A single tool invocation request embedded in an assistant message.
Message¶
Message
dataclass
¶
Message(role: Role, content: str = '', name: Optional[str] = None, tool_calls: Optional[List[ToolCall]] = None, tool_call_id: Optional[str] = None, metadata: Dict[str, Any] = dict())
A single chat message (OpenAI-compatible structure).
Conversation¶
Conversation
dataclass
¶
Conversation(messages: List[Message] = list(), max_messages: Optional[int] = None)
ModelSpec¶
ModelSpec
dataclass
¶
ModelSpec(model_id: str, name: str, parameter_count_b: float, context_length: int, active_parameter_count_b: Optional[float] = None, quantization: Quantization = NONE, min_vram_gb: float = 0.0, supported_engines: Sequence[str] = (), provider: str = '', requires_api_key: bool = False, metadata: Dict[str, Any] = dict())
Metadata describing a language model.
ToolResult¶
ToolResult
dataclass
¶
ToolResult(tool_name: str, content: str, success: bool = True, usage: Dict[str, Any] = dict(), cost_usd: float = 0.0, latency_seconds: float = 0.0, metadata: Dict[str, Any] = dict())
Result returned by a tool invocation.
TelemetryRecord¶
TelemetryRecord
dataclass
¶
TelemetryRecord(timestamp: float, model_id: str, prompt_tokens: int = 0, completion_tokens: int = 0, total_tokens: int = 0, latency_seconds: float = 0.0, ttft: float = 0.0, cost_usd: float = 0.0, energy_joules: float = 0.0, power_watts: float = 0.0, gpu_utilization_pct: float = 0.0, gpu_memory_used_gb: float = 0.0, gpu_temperature_c: float = 0.0, throughput_tok_per_sec: float = 0.0, prefill_latency_seconds: float = 0.0, decode_latency_seconds: float = 0.0, engine: str = '', agent: str = '', metadata: Dict[str, Any] = dict())
Single telemetry observation recorded after an inference call.
TraceStep¶
TraceStep
dataclass
¶
TraceStep(step_type: StepType, timestamp: float, duration_seconds: float = 0.0, input: Dict[str, Any] = dict(), output: Dict[str, Any] = dict(), metadata: Dict[str, Any] = dict())
A single step within an agent trace.
Each step records what the agent did (route, retrieve, generate, tool_call, respond), its inputs and outputs, and timing.
Trace¶
Trace
dataclass
¶
Trace(trace_id: str = _trace_id(), query: str = '', agent: str = '', model: str = '', engine: str = '', steps: List[TraceStep] = list(), result: str = '', outcome: Optional[str] = None, feedback: Optional[float] = None, started_at: float = 0.0, ended_at: float = 0.0, total_tokens: int = 0, total_latency_seconds: float = 0.0, metadata: Dict[str, Any] = dict())
Complete trace of an agent handling a query.
A trace captures the full sequence of steps an agent took to handle a query — which model was selected, what memory was retrieved, which tools were called, and the final response. Traces are the primary input to the learning system: by analyzing which decisions led to good outcomes, the system can improve routing, tool selection, and memory strategies.
RoutingContext¶
RoutingContext
dataclass
¶
RoutingContext(query: str = '', query_length: int = 0, has_code: bool = False, has_math: bool = False, language: str = 'en', urgency: float = 0.5, metadata: Dict[str, Any] = dict())
Context describing a query for model routing decisions.
Configuration¶
Configuration loading, hardware detection, and engine recommendation. User
configuration lives at ~/.openjarvis/config.toml. The load_config()
function detects hardware, fills sensible defaults, then overlays any user
overrides from the TOML file.
JarvisConfig¶
JarvisConfig
dataclass
¶
JarvisConfig(hardware: HardwareInfo = HardwareInfo(), engine: EngineConfig = EngineConfig(), intelligence: IntelligenceConfig = IntelligenceConfig(), learning: LearningConfig = LearningConfig(), tools: ToolsConfig = ToolsConfig(), agent: AgentConfig = AgentConfig(), server: ServerConfig = ServerConfig(), telemetry: TelemetryConfig = TelemetryConfig(), traces: TracesConfig = TracesConfig(), channel: ChannelConfig = ChannelConfig(), security: SecurityConfig = SecurityConfig(), sandbox: SandboxConfig = SandboxConfig(), scheduler: SchedulerConfig = SchedulerConfig())
Top-level configuration for OpenJarvis.
Attributes¶
memory
property
writable
¶
memory: StorageConfig
Backward-compatible accessor — canonical location is tools.storage.
EngineConfig¶
EngineConfig
dataclass
¶
EngineConfig(default: str = 'ollama', ollama: OllamaEngineConfig = OllamaEngineConfig(), vllm: VLLMEngineConfig = VLLMEngineConfig(), sglang: SGLangEngineConfig = SGLangEngineConfig(), llamacpp: LlamaCppEngineConfig = LlamaCppEngineConfig())
Inference engine settings with nested per-engine configs.
Attributes¶
IntelligenceConfig¶
IntelligenceConfig
dataclass
¶
IntelligenceConfig(default_model: str = '', fallback_model: str = '', model_path: str = '', checkpoint_path: str = '', quantization: str = 'none', preferred_engine: str = '', provider: str = '', temperature: float = 0.7, max_tokens: int = 1024, top_p: float = 0.9, top_k: int = 40, repetition_penalty: float = 1.0, stop_sequences: str = '')
The model — identity, paths, quantization, and generation defaults.
LearningConfig¶
LearningConfig
dataclass
¶
LearningConfig(enabled: bool = False, update_interval: int = 100, auto_update: bool = False, routing: RoutingLearningConfig = RoutingLearningConfig(), intelligence: IntelligenceLearningConfig = IntelligenceLearningConfig(), agent: AgentLearningConfig = AgentLearningConfig(), metrics: MetricsConfig = MetricsConfig())
MemoryConfig¶
AgentConfig¶
AgentConfig
dataclass
¶
ServerConfig¶
ServerConfig
dataclass
¶
ServerConfig(host: str = '0.0.0.0', port: int = 8000, agent: str = 'orchestrator', model: str = '', workers: int = 1)
API server settings.
TelemetryConfig¶
TelemetryConfig
dataclass
¶
TelemetryConfig(enabled: bool = True, db_path: str = str(DEFAULT_CONFIG_DIR / 'telemetry.db'), gpu_metrics: bool = False, gpu_poll_interval_ms: int = 50)
Telemetry persistence settings.
TracesConfig¶
TracesConfig
dataclass
¶
Trace system settings.
StorageConfig¶
StorageConfig
dataclass
¶
StorageConfig(default_backend: str = 'sqlite', db_path: str = str(DEFAULT_CONFIG_DIR / 'memory.db'), context_top_k: int = 5, context_min_score: float = 0.1, context_max_tokens: int = 2048, chunk_size: int = 512, chunk_overlap: int = 64)
Storage (memory) backend settings.
MCPConfig¶
MCPConfig
dataclass
¶
MCP (Model Context Protocol) settings.
ToolsConfig¶
ToolsConfig
dataclass
¶
ToolsConfig(storage: StorageConfig = StorageConfig(), mcp: MCPConfig = MCPConfig(), enabled: str = '')
Tools pillar settings — wraps storage and MCP configuration.
HardwareInfo¶
HardwareInfo
dataclass
¶
HardwareInfo(platform: str = '', cpu_brand: str = '', cpu_count: int = 0, ram_gb: float = 0.0, gpu: Optional[GpuInfo] = None)
Detected system hardware.
GpuInfo¶
GpuInfo
dataclass
¶
GpuInfo(vendor: str = '', name: str = '', vram_gb: float = 0.0, compute_capability: str = '', count: int = 0)
Detected GPU metadata.
detect_hardware¶
detect_hardware
¶
detect_hardware() -> HardwareInfo
Auto-detect hardware capabilities with graceful fallbacks.
Source code in src/openjarvis/core/config.py
load_config¶
load_config
¶
load_config(path: Optional[Path] = None) -> JarvisConfig
Detect hardware, build defaults, overlay TOML overrides.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Explicit config file. Falls back to
TYPE:
|
Source code in src/openjarvis/core/config.py
recommend_engine¶
recommend_engine
¶
recommend_engine(hw: HardwareInfo) -> str
Suggest the best inference engine for the detected hardware.
Source code in src/openjarvis/core/config.py
Event Bus¶
Thread-safe pub/sub event bus for inter-pillar telemetry. Any pillar can emit
events (e.g. INFERENCE_END) and any other pillar can react without direct
coupling.
EventType¶
EventType
¶
Bases: str, Enum
Supported event categories.
Event¶
Event
dataclass
¶
Event(event_type: EventType, timestamp: float, data: Dict[str, Any] = dict())
A single event published on the bus.
EventBus¶
EventBus
¶
Thread-safe publish/subscribe event bus.
Subscribers are called synchronously in registration order within the publishing thread. An optional record_history flag retains all published events for later inspection (useful in tests/telemetry).
Source code in src/openjarvis/core/events.py
Attributes¶
history
property
¶
history: List[Event]
Return a copy of all recorded events (empty if recording is off).
Functions¶
subscribe
¶
subscribe(event_type: EventType, callback: Subscriber) -> None
Register callback to be called whenever event_type is published.
unsubscribe
¶
unsubscribe(event_type: EventType, callback: Subscriber) -> None
Remove callback from listeners for event_type.
Source code in src/openjarvis/core/events.py
publish
¶
Create and dispatch an event to all subscribers.
Returns the published Event instance.
Source code in src/openjarvis/core/events.py
get_event_bus¶
get_event_bus
¶
get_event_bus(*, record_history: bool = False) -> EventBus
Return the module-level EventBus singleton, creating it if needed.