registry

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = NewProviderRegistry()

DefaultRegistry is the global default provider registry, populated at init.

Functions

func CredentialPresent

func CredentialPresent(spec ProviderSpec, env map[string]string) bool

CredentialPresent reports whether env satisfies this provider's discovery requirements.

func DeploymentEnvFallbacks

func DeploymentEnvFallbacks() map[string][]EnvFallback

DeploymentEnvFallbacks derives seed env_fallbacks for registered deployments.

func DisplayName

func DisplayName(providerID string) string

DisplayName returns the UI label for a provider id.

func LiveCatalogKeyForFetcher

func LiveCatalogKeyForFetcher(fetcherKey string) string

LiveCatalogKeyForFetcher maps fetcher registry key to legacy catalog Providers map key.

func LiveFetcherKeys

func LiveFetcherKeys() []string

LiveFetcherKeys returns live catalog provider keys that have fetchers.

Types

type CredentialSpec

type CredentialSpec struct {
	ProviderID   string
	DisplayName  string
	DeploymentID string
	EnvVar       string
	ProbeKind    string
	ProbeBaseURL string
	RequiresKey  bool
	SortOrder    int
}

CredentialSpec is paste-key / local setup metadata derived from ProviderSpec.

func CredentialRegistry

func CredentialRegistry() []CredentialSpec

CredentialRegistry derives credential rows from provider specs.

type EnvFallback

type EnvFallback struct {
	Field string
	Env   []string
}

EnvFallback describes one deployment env_fallback row.

type ProbeKind

type ProbeKind string

ProbeKind identifies HTTP credential validation.

const (
	ProbeAnthropic    ProbeKind = "probe_anthropic"
	ProbeOpenAIModels ProbeKind = "probe_openai_models"
	ProbeGemini       ProbeKind = "probe_gemini"
	ProbeOllama       ProbeKind = "probe_ollama"
	ProbeNone         ProbeKind = "probe_none"
)

type ProviderRegistry

type ProviderRegistry struct {
	// contains filtered or unexported fields
}

ProviderRegistry is the single source of truth for all provider specs.

func NewProviderRegistry

func NewProviderRegistry() *ProviderRegistry

NewProviderRegistry creates a new empty registry.

func (*ProviderRegistry) All

func (r *ProviderRegistry) All() []ProviderSpec

All returns a copy of all registered provider specs.

func (*ProviderRegistry) CredentialProviders

func (r *ProviderRegistry) CredentialProviders() []ProviderSpec

CredentialProviders returns all registered provider specs (every spec carries credential metadata; callers filter by RequiresKey as needed).

func (*ProviderRegistry) DeploymentEnvFallbacks

func (r *ProviderRegistry) DeploymentEnvFallbacks() map[string][]EnvFallback

DeploymentEnvFallbacks derives seed env_fallbacks for registered deployments.

func (*ProviderRegistry) Get

func (r *ProviderRegistry) Get(id string) (ProviderSpec, bool)

Get returns the provider spec for the given provider ID or catalog alias.

func (*ProviderRegistry) GetByEnv

func (r *ProviderRegistry) GetByEnv(env string) (ProviderSpec, bool)

GetByEnv returns the provider spec for the given credential env var name.

func (*ProviderRegistry) GetForLiveFetcher

func (r *ProviderRegistry) GetForLiveFetcher(fetcherKey string) (ProviderSpec, bool)

GetForLiveFetcher returns the provider spec for the given live fetcher key.

func (*ProviderRegistry) LiveDiscoverable

func (r *ProviderRegistry) LiveDiscoverable() []ProviderSpec

LiveDiscoverable returns specs that have a live model-list fetcher registered.

func (*ProviderRegistry) LiveFetcherKeys

func (r *ProviderRegistry) LiveFetcherKeys() []string

LiveFetcherKeys returns sorted live catalog provider keys that have fetchers.

func (*ProviderRegistry) Register

func (r *ProviderRegistry) Register(spec ProviderSpec)

Register adds a spec to the registry. If a spec with the same ProviderID already exists, it is replaced.

type ProviderSpec

type ProviderSpec struct {
	ProviderID             string
	DisplayName            string
	DeploymentID           string
	SortOrder              int
	RequiresKey            bool
	CredentialEnv          string
	CredentialEnvFallbacks []string // additional env var names for the same credential
	BaseURLEnv             []string
	ProbeKind              ProbeKind
	ProbeBaseURL           string
	LiveFetcherKey         string // key in catalog/live registry
	LiveCatalogKey         string // legacy provider key in ModelCatalog.Providers map
	APIProtocolID          string
	AdapterID              string
	RetryConfig            *RetryConfig
	IsLocal                bool
}

ProviderSpec is the single source of truth for setup providers. Every registered provider discovers models via its live list API only (no remote bootstrap).

func All

func All() []ProviderSpec

All returns every registered provider spec (sorted by SortOrder at use sites).

func SpecByEnvVar

func SpecByEnvVar(env string) (ProviderSpec, bool)

SpecByEnvVar finds spec by primary credential env var.

func SpecByProviderID

func SpecByProviderID(id string) (ProviderSpec, bool)

SpecByProviderID finds a provider spec by id (accepts registry ids and catalog aliases like google→gemini).

func SpecForLiveFetcher

func SpecForLiveFetcher(fetcherKey string) (ProviderSpec, bool)

SpecForLiveFetcher returns the provider spec for a live fetcher key.

type RetryConfig

type RetryConfig struct {
	BaseDelayMs       int     `json:"base_delay_ms,omitempty"`
	MaxDelayMs        int     `json:"max_delay_ms,omitempty"`
	MaxRetries        int     `json:"max_retries,omitempty"`
	BackoffMultiplier float64 `json:"backoff_multiplier,omitempty"`
	JitterPct         int     `json:"jitter_pct,omitempty"`
	RetryOnCodes      []int   `json:"retry_on_codes,omitempty"`
	AbortOnCodes      []int   `json:"abort_on_codes,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL