Skip to content

builder

builder

Config-driven fluent builder that wires up a JarvisSystem.

Classes

SystemBuilder

SystemBuilder(config: Optional[JarvisConfig] = None, *, config_path: Optional[Any] = None)

Config-driven fluent builder for JarvisSystem.

Source code in src/openjarvis/system/builder.py
def __init__(
    self,
    config: Optional[JarvisConfig] = None,
    *,
    config_path: Optional[Any] = None,
) -> None:
    if config is not None:
        self._config = config
    elif config_path is not None:
        from pathlib import Path

        self._config = load_config(Path(config_path))
    else:
        self._config = load_config()

    self._engine_key: Optional[str] = None
    self._engine_instance: Optional[InferenceEngine] = None
    self._engine_instance_key: Optional[str] = None
    self._model: Optional[str] = None
    self._agent_name: Optional[str] = None
    self._tool_names: Optional[List[str]] = None
    self._telemetry: Optional[bool] = None
    self._traces: Optional[bool] = None
    self._bus: Optional[EventBus] = None
    self._sandbox: Optional[bool] = None
    self._scheduler: Optional[bool] = None
    self._workflow: Optional[bool] = None
    self._sessions: Optional[bool] = None
    self._speech: Optional[bool] = None
    self._mcp_clients: List = []
    self._mcp_tools: List[BaseTool] = []
Functions
engine_instance
engine_instance(engine: InferenceEngine, key: str = 'openai-compat') -> SystemBuilder

Inject a pre-built engine instance, bypassing engine discovery.

Used by callers that must target one exact endpoint (e.g. jarvis eval --base-url). build() health-checks the instance and raises a loud error if it is unreachable — it never silently substitutes a different discovered engine.

Source code in src/openjarvis/system/builder.py
def engine_instance(
    self, engine: InferenceEngine, key: str = "openai-compat"
) -> SystemBuilder:
    """Inject a pre-built engine instance, bypassing engine discovery.

    Used by callers that must target one exact endpoint (e.g.
    ``jarvis eval --base-url``). ``build()`` health-checks the instance
    and raises a loud error if it is unreachable — it never silently
    substitutes a different discovered engine.
    """
    self._engine_instance = engine
    self._engine_instance_key = key
    return self
build
build() -> JarvisSystem

Construct a fully wired JarvisSystem.

Source code in src/openjarvis/system/builder.py
def build(self) -> JarvisSystem:
    """Construct a fully wired JarvisSystem."""
    # Discovery state belongs to one build only.  Once a system is
    # returned, that system owns the clients and adapters captured below;
    # retaining them here would make a reused builder hand closed clients
    # from an earlier system to the next one.
    self._clear_mcp_discovery_state(close_clients=True)
    try:
        system = self._build()
    except BaseException:
        # No system took ownership, so release any clients opened before
        # the build failed.
        self._clear_mcp_discovery_state(close_clients=True)
        raise
    self._clear_mcp_discovery_state(close_clients=False)
    return system

Functions