pub struct ProviderRegistry { /* private fields */ }Expand description
The --api-schema name space: ordered name → factory entries.
Ordered so help/error listings are stable; ProviderRegistry::register
replaces in place when the name already exists (letting a downstream binary
override a built-in, e.g. a scripted mock).
Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty registry (no names). Most callers want Self::builtin.
Sourcepub fn builtin() -> Self
pub fn builtin() -> Self
The built-in wires: anthropic, openai-responses, and the keyless
mock (one scripted no-tool text turn → completed, for CI).
The mock script is overridable via the LOCODE_MOCK_SCRIPT env var —
a JSON array of turns, each {"text": "…"} (a final text turn) or
{"tool": "<name>", "input": {…}} (a tool_use turn) — so keyless
integration tests can drive multi-turn/tool runs (e.g. the SIGTERM
test holds a run open with a slow shell command). A malformed script
fails pre-run.
Sourcepub fn register<F>(self, name: impl Into<String>, factory: F) -> Self
pub fn register<F>(self, name: impl Into<String>, factory: F) -> Self
Add a provider under name, replacing any existing entry of that name
(registration order is otherwise preserved for listings).
Sourcepub fn build(
&self,
name: &str,
init: &ProviderInit,
) -> Result<BuiltProvider, ProviderBuildError>
pub fn build( &self, name: &str, init: &ProviderInit, ) -> Result<BuiltProvider, ProviderBuildError>
Construct the provider registered under name.
§Errors
ProviderBuildError when name is unknown (the message lists the
available names) or when the factory itself fails (missing env, …).