Skip to main content

Oxicode

Struct Oxicode 

Source
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

Source

pub fn agent(&self, config: AgentConfig) -> AgentBuilder<'_>

Create an agent builder with the given config.

Source

pub fn providers(&self) -> &ProviderRegistry

Get the provider registry.

Source

pub fn models(&self) -> &ModelRegistry

Get the model registry.

Source

pub fn tools(&self) -> Arc<ToolRegistry>

Get the shared tool registry.

Source

pub fn ports(&self) -> &PortRegistry

Get the port registry (state, config, auth, event bus, …).

Source

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?;
Source

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.

Source

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:

  1. The catalog port (if wired) — reads the in-memory snapshot.
  2. 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.

Source

pub fn create_provider(&self, name: &str) -> SdkResult<Arc<dyn Provider>>

  1. Custom providers registered via OxicodeBuilder::provider()
  2. Provider factories registered via OxicodeBuilder::provider_factory()
  3. Built-in providers with credential injection (if with_builtins() was called): a. Explicit per-provider key from OxicodeBuilder::api_key(name, key) b. The wired AuthProvider port (sync fast-path). This is the primary credential source for products like the CLI, which never call OxicodeBuilder::api_key() and instead register FileAuthProvider via .with_auth(...). Consulted on every create_provider call, so auth-store updates (e.g. a key entered via the TUI overlay) are picked up without rebuilding the engine. c. Provider env var (the create_builtin_provider_with_options fallback inside oxicode-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.

Source

pub fn providers_arc(&self) -> Arc<ProviderRegistry>

Get the provider registry (Arc clone).

Source

pub fn models_arc(&self) -> Arc<ModelRegistry>

Get the model registry (Arc clone).

Source

pub fn has_builtins(&self) -> bool

Check whether built-in providers are enabled.

Source

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 Clone for Oxicode

Source§

fn clone(&self) -> Oxicode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ProviderResolver for Oxicode

Implement ProviderResolver so Oxicode can be used as Agent’s resolver.

Source§

fn resolve_provider(&self, name: &str) -> Option<Arc<dyn Provider>>

Resolve a provider by name, returning an Arc handle.
Source§

fn resolve_model(&self, model_id: &str) -> Option<Model>

Resolve a model ID (“provider/model” or bare “model”) to a Model.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more