pub struct Oxicode { /* private fields */ }Expand description
Oxicode AI engine instance — holds isolated provider and model registries.
Created via OxicodeBuilder. Provides access to providers, models,
provider creation, and agent building.
Implements ProviderResolver so it can be passed directly to
oxicode_agent::Agent::new_with_resolver for fully isolated operation.
Implementations§
Source§impl Oxicode
impl Oxicode
Sourcepub fn agent(&self, config: AgentConfig) -> AgentBuilder<'_>
pub fn agent(&self, config: AgentConfig) -> AgentBuilder<'_>
Create an agent builder with the given config.
Sourcepub fn providers(&self) -> &ProviderRegistry
pub fn providers(&self) -> &ProviderRegistry
Get the provider registry.
Sourcepub fn models(&self) -> &ModelRegistry
pub fn models(&self) -> &ModelRegistry
Get the model registry.
Sourcepub fn tools(&self) -> Arc<ToolRegistry> ⓘ
pub fn tools(&self) -> Arc<ToolRegistry> ⓘ
Get the shared tool registry.
Sourcepub fn ports(&self) -> &PortRegistry
pub fn ports(&self) -> &PortRegistry
Get the port registry (state, config, auth, event bus, …).
Sourcepub fn catalog(&self) -> &Arc<dyn ModelCatalog> ⓘ
pub fn catalog(&self) -> &Arc<dyn ModelCatalog> ⓘ
Catalog port accessor. Use this for all catalog queries.
Returns a reference to the Arc<dyn ModelCatalog>. The default
(when OxicodeBuilder::with_catalog() is not called) is a
NoopModelCatalog —
all lookups return empty/None.
§Example
let providers = oxicode.catalog().list_providers().await?;
let model = oxicode.catalog().get_model("anthropic", "claude-sonnet-4-20250514").await?;Sourcepub fn mcp(&self) -> Option<Arc<McpManager>>
pub fn mcp(&self) -> Option<Arc<McpManager>>
Get the MCP manager, if MCP is enabled.
This is the entry point for SDK consumers who want to use MCP from outside the agent loop — e.g. the TUI dashboard, RPC handlers, or custom agent integrations.
Returns None if MCP was disabled via OxicodeBuilder::with_mcp with
false.
Sourcepub fn resolve_model(&self, model_id: &str) -> SdkResult<Model>
pub fn resolve_model(&self, model_id: &str) -> SdkResult<Model>
Resolve a model ID to a Model.
Accepts "provider/model" or bare "model" (defaults to “anthropic”).
Resolution order:
- The catalog port (if wired) — reads the in-memory snapshot.
- The static model registry (
with_builtins).
The routing.excluded_models list is consulted before the
catalog/static lookups — set_enabled(false) / exclude_model
/ unexclude_model on the shared RoutingControl instance
take effect on the next resolution.
Sourcepub fn create_provider(&self, name: &str) -> SdkResult<Arc<dyn Provider>>
pub fn create_provider(&self, name: &str) -> SdkResult<Arc<dyn Provider>>
- Custom providers registered via
OxicodeBuilder::provider() - Provider factories registered via
OxicodeBuilder::provider_factory() - Built-in providers with credential injection (if
with_builtins()was called): a. Explicit per-provider key fromOxicodeBuilder::api_key(name, key)b. The wiredAuthProviderport (sync fast-path). This is the primary credential source for products like the CLI, which never callOxicodeBuilder::api_key()and instead registerFileAuthProvidervia.with_auth(...). Consulted on everycreate_providercall, so auth-store updates (e.g. a key entered via the TUI overlay) are picked up without rebuilding the engine. c. Provider env var (thecreate_builtin_provider_with_optionsfallback insideoxicode-ai).
This is the single credential authority for the agent loop: the
AgentConfig.api_key field and the api_key params on
Agent::switch_model / Agent::refresh_api_key are vestigial after
this wiring and are removed in a follow-up. See issues #39 and #40.
Sourcepub fn providers_arc(&self) -> Arc<ProviderRegistry> ⓘ
pub fn providers_arc(&self) -> Arc<ProviderRegistry> ⓘ
Get the provider registry (Arc clone).
Sourcepub fn models_arc(&self) -> Arc<ModelRegistry> ⓘ
pub fn models_arc(&self) -> Arc<ModelRegistry> ⓘ
Get the model registry (Arc clone).
Sourcepub fn has_builtins(&self) -> bool
pub fn has_builtins(&self) -> bool
Check whether built-in providers are enabled.
Sourcepub fn routing(&self) -> &Arc<RoutingControl> ⓘ
pub fn routing(&self) -> &Arc<RoutingControl> ⓘ
Borrow the shared crate::routing::RoutingControl instance. Use this to
call set_enabled, exclude_model, set_fallback_models, etc.
Mutations are observed by the next model/provider resolution.
Trait Implementations§
Source§impl ProviderResolver for Oxicode
Implement ProviderResolver so Oxicode can be used as Agent’s resolver.
impl ProviderResolver for Oxicode
Implement ProviderResolver so Oxicode can be used as Agent’s resolver.