Documentation
¶
Overview ¶
Package selectadapter is the adapter-selection composition layer (ADR-0005, T-014). It maps the neutral model string's "<provider>/" prefix to the concrete Provider adapter, wiring resolved config.Provider options into the adapter. This is the only place that knows both config and the adapter packages; everything downstream sees ports.Provider.
The registry is open for extension: Register(prefix, factory) adds a new adapter. anthropic is registered by default; the OpenAI-compatible adapter (openai, local, custom, …) is registered when T-013 lands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadModel means the model string is missing or has no "/" separator. ErrBadModel = errors.New("selectadapter: bad model string (want <provider>/<model>)") // ErrNoProvider means the prefix parsed fine but no provider is configured // under it in opencode.json. ErrNoProvider = errors.New("selectadapter: provider not configured") // ErrNoAdapter means the provider is configured but no adapter factory is // registered for its prefix (e.g. the openaicompat adapter before T-013). ErrNoAdapter = errors.New("selectadapter: no adapter registered for prefix") )
Sentinel errors returned by Select. Wrap with errors.Is to distinguish "no provider configured" from "no adapter for that provider".
Functions ¶
func Register ¶
Register installs (or replaces) the Factory for a provider prefix. Safe to call concurrently and from init() blocks. T-013 will Register the openaicompat factory for openai/local/custom prefixes.
func Select ¶
Select resolves which adapter serves the model string and returns it, wired with the matching provider's options. model must be "<provider>/<model>". providers is the table from config (cfg.Providers).
Returns a wrapped ErrBadModel / ErrNoProvider / ErrNoAdapter on the corresponding failures.
func Unregister ¶
func Unregister(prefix string)
Unregister removes a prefix's factory. Primarily for tests.