Skip to main content

Crate oino_models

Crate oino_models 

Source
Expand description

oino-models: the model registry, models.json, model resolution, auth.json storage and virtual models for Oino.

Providers are WASM components: this crate never streams. It stores provider registrations (extension-api §4.4) and their models, merges models.json and config overrides in a fixed order, resolves credentials per request (core passes them to the component as StreamOptions.apiKey/headers) and resolves --model/--models/defaults. It has no async runtime; OAuth refresh is an injected OAuthRefresher future.

§API map

ItemPurpose
ModelRegistryshared catalog + auth (Arc<RwLock>)
ProviderRegistration, ProviderConfigOverrideprovider data
ModelsJsonmodels.json load with diagnostics
AuthStorage, AuthCredentialauth.json with locking, runtime keys
auth::oauthOAuth expiry + locked refresh
config_valueliteral | $ENV | ${ENV} | !command
resolver--model, scopes, initial model, restore, cycling
virtual_modelsdefinitions, route wire types, validation, branch state
auth_checkoino auth check (exit 0/1/2)
ModelCache<agent>/cache/models/<provider>.json
auth::guidance“No API key found …” texts

§Behaviour notes

  • No built-in catalog: models come from registrations (static or list-models) and models.json. A model is available only when its provider has credentials and a loaded component implements its API (ModelRegistry::diagnostics lists the others).
  • Config overrides keep the provider component’s registration.
  • Registration authHeader is informational; Authorization: Bearer is injected only for models.json/override authHeader: true.
  • Credential order: --api-key > auth.json > models.json/override apiKey > registration authEnv (runtime.md §13 lists env before apiKey).
  • models.json compat is only checked for being an object; JSON syntax errors use serde_json wording; oauth: "radius" validates but has no flow in core.
  • Virtual router state equal to the current state is not re-stored (no object identity across WASM).

Re-exports§

pub use auth::credential::ApiKeyCredential;
pub use auth::credential::AuthCredential;
pub use auth::credential::CredentialInfo;
pub use auth::credential::CredentialType;
pub use auth::credential::OAuthCredential;
pub use auth::oauth::OAuthError;
pub use auth::oauth::OAuthRefresher;
pub use auth::storage::AuthStorage;
pub use auth::storage::AuthStorageError;
pub use config_value::ConfigValueError;
pub use config_value::resolve_config_value;
pub use env::EnvSource;
pub use env::MapEnv;
pub use env::ProcessEnv;
pub use virtual_models::RouteReason;
pub use virtual_models::RouteRequest;
pub use virtual_models::RouteResult;
pub use virtual_models::VIRTUAL_MODEL_API;
pub use virtual_models::VirtualModelDefinition;
pub use virtual_models::VirtualModelRegistry;

Modules§

auth
Credentials: auth.json storage, OAuth refresh, user guidance texts.
auth_check
oino auth check: provider readiness with exit codes 0 (ready), 1 (not ready), 2 (invalid).
config_value
Config-value resolution: API keys and header values that are literals, $ENV / ${ENV} templates, or !command output.
env
Environment lookup used by credential and config-value resolution.
resolver
Model resolution and cycling: --model, --models / enabledModels, initial selection, session restore.
virtual_models
Catalog entries that route each request to a physical model.

Structs§

AuthCheck
A provider has usable credentials.
AuthOverrides
Per-request auth inputs.
AuthStatus
Auth status (for /login and status displays).
CachedModels
A cached model list.
ModelCache
Directory of per-provider cache files.
ModelRegistry
The shared model registry (see module docs).
ModelRegistryOptions
Registry construction options.
ModelsJson
One load of models.json.
ModelsJsonModel
A models[] entry.
ModelsJsonModelOverride
A modelOverrides entry: every field merges over the existing model.
ModelsJsonProvider
A providers.<id> entry.
PartialCost
Partial cost in a model override.
ProviderConfigOverride
Config-only overrides an extension sets for an existing provider id. Re-registration merges defined fields over the previous override.
ProviderModelConfig
A model in a registration or override.
ProviderRegistration
A provider component’s registration (extension-api §4.4).
RegistryDiagnostic
A non-fatal catalog problem outside getError().
RequestAuth
Credentials for one request (the resolved-auth record with ok: true).
RequestAuthError
getApiKeyAndHeaders failure; the message is the resolution text.
ResolvedAuth
Credentials resolved for one provider.

Enums§

ApiKeyError
Causes of AuthResolveError::ApiKey.
AuthHeaderMode
How a registration sends the API key (authHeader).
AuthResolveError
Credential resolution failures.
AuthStatusSource
The auth status.source record.
CacheError
Cache read/write failures.
ProviderModels
Model list of a registration: "dynamic" (host calls the component’s list-models) or a static list.
RegistryError
Registry mutation failures.

Type Aliases§

SamplingByLevel
samplingParamsByThinkingLevel: known levels only (unknown keys are ignored).