mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-09-05 01:45:43 +00:00
The provider controller repeated every provider type across five hand-written blocks (default-config wiring, key-gated instantiation, GetProvider fallback, NewProvider, buildProviderFromConfig) plus the API-layer Valid() whitelist. Introduce pkg/providers/registry.go: a providerRegistry table whose entries hold the per-type constructors and credential gating, with small adapter helpers (ignoreConfig/fromData) absorbing the signature variance (bedrock/ollama/custom take *config.Config; the rest don't). The controller now wires and looks up providers in loops over the table. Valid() validates against the new canonical provider.AllProviderTypes list (no heavyweight import, no cycle). Adding a provider's backend wiring drops from ~6 edits across these functions to one registry entry. providers.go shrinks ~300 lines; behavior is unchanged (same exported funcs, same gating) and all provider/server/graph tests stay green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>