LlmCore.CLIProvider.Registry (llm_core v0.3.0)

Copy Markdown View Source

Query surface for CLI-based LLM providers.

Merges built-in CLI providers (shipped in priv/config/llm_core.toml) with TOML-configured ones (project/global overrides). TOML definitions win on conflict.

Usage

# All known CLI providers with structured metadata
LlmCore.CLIProvider.Registry.list()

# Only those with binary in PATH
LlmCore.CLIProvider.Registry.available()

# Fetch by atom ID or string alias
{:ok, entry} = LlmCore.CLIProvider.Registry.fetch(:droid)
{:ok, entry} = LlmCore.CLIProvider.Registry.fetch("pi")

# Get a ready-to-use provider struct
{:ok, provider} = LlmCore.CLIProvider.Registry.resolve(:claude_code)

# Inspect capabilities
{:ok, caps} = LlmCore.CLIProvider.Registry.capabilities(:codex_cli)

Each entry includes: id, aliases, binary, available?, install_hint, default_model, capabilities, supports_auto_approve?, supports_sandbox_bypass?, supports_system_prompt_file?, supports_cwd?, supports_add_dir?, metadata.

Resolution Order

  1. TOML-configured CLI providers (from Config.Store) — override builtins
  2. Built-in providers (from CLIProvider.@builtins)

Usage

# List all known CLI providers
CLIProvider.Registry.list()

# Only those with the binary in PATH
CLIProvider.Registry.available()

# Fetch by id or alias
{:ok, entry} = CLIProvider.Registry.fetch(:droid)
{:ok, entry} = CLIProvider.Registry.fetch("pi")

# Get a ready-to-use struct
{:ok, provider} = CLIProvider.Registry.resolve(:droid)

# Inspect capabilities
caps = CLIProvider.Registry.capabilities(:droid)

Summary

Functions

Returns only CLI providers whose binary is found in PATH.

Returns the capability map for a CLI provider.

Fetches a CLI provider entry by id (atom or string) or alias.

Returns all known CLI providers with metadata. Runtime-configured providers override builtins with the same name.

Resolves a CLI provider into a ready-to-use %CLIProvider{} struct.

Types

entry()

@type entry() :: %{
  id: atom(),
  aliases: [String.t()],
  binary: String.t(),
  available?: boolean(),
  install_hint: String.t() | nil,
  default_model: String.t() | nil,
  model_resolution: :gc_default | :provider_runtime | :explicit_only,
  capabilities: map(),
  supports_auto_approve?: boolean(),
  supports_sandbox_bypass?: boolean(),
  supports_system_prompt_file?: boolean(),
  supports_cwd?: boolean(),
  supports_add_dir?: boolean(),
  metadata: map()
}

Functions

available()

@spec available() :: [entry()]

Returns only CLI providers whose binary is found in PATH.

capabilities(name)

@spec capabilities(atom() | String.t()) :: {:ok, map()} | {:error, :not_found}

Returns the capability map for a CLI provider.

fetch(name)

@spec fetch(atom() | String.t()) :: {:ok, entry()} | {:error, :not_found}

Fetches a CLI provider entry by id (atom or string) or alias.

list()

@spec list() :: [entry()]

Returns all known CLI providers with metadata. Runtime-configured providers override builtins with the same name.

resolve(name)

@spec resolve(atom() | String.t()) ::
  {:ok, LlmCore.LLM.CLIProvider.t()} | {:error, :not_found}

Resolves a CLI provider into a ready-to-use %CLIProvider{} struct.