registry

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 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 ChatProviderPreferenceOrder added in v0.1.2

func ChatProviderPreferenceOrder() []string

ChatProviderPreferenceOrder returns provider ids ordered by chat/runtime preference.

func CredentialAliases added in v0.1.2

func CredentialAliases(providerID string) []string

CredentialAliases returns compatibility env var names for providerID.

func CredentialEnvPreparedProviders added in v0.1.2

func CredentialEnvPreparedProviders() []string

CredentialEnvPreparedProviders returns providers that need config-derived env before discovery.

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.

func RuntimeProfileKey added in v0.1.2

func RuntimeProfileKey(providerID string) string

RuntimeProfileKey returns the config runtime-profile key for a provider.

func ScopedProviderEnv added in v0.2.2

func ScopedProviderEnv(spec ProviderSpec, env map[string]string) map[string]string

ScopedProviderEnv returns only credential aliases and routing metadata used by one provider. Provider-specific fetchers must never receive unrelated credentials from the host's full secret snapshot.

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
	ChatPreference         int
	RequiresKey            bool
	CredentialEnv          string
	CredentialEnvFallbacks []string // additional env var names for the same credential
	CredentialAliases      []string // compatibility env var names accepted by host UIs
	BaseURLEnv             []string
	ProbeKind              ProbeKind
	ProbeBaseURL           string
	LiveFetcherKey         string // key in catalog/live registry
	LiveCatalogKey         string // legacy provider key in ModelCatalog.Providers map
	PublicModelCatalog     bool   // live model listing is available without provider credentials
	ProtocolID             string
	AdapterID              string
	RuntimeProfileKey      string
	PrepareCredentialEnv   bool
	RetryConfig            *RetryConfig
	IsLocal                bool
	// TransportKind selects the runtime client implementation. Empty means
	// OpenAI-compatible; dedicated transports declare their kind explicitly.
	TransportKind string
	// RuntimeBaseURL overrides ProbeBaseURL when chat and model-list endpoints
	// differ. RuntimeCredentialEnv overrides CredentialEnv when setup metadata
	// describes a non-secret value, as with Ollama's base URL.
	RuntimeBaseURL       string
	RuntimeCredentialEnv string
	// RegionOptions lists selectable regions for regional gateways.
	// Populated at registration time; nil for non-regional providers.
	RegionOptions []RegionOption
	// DNSHost is the primary DNS hostname for connectivity preflight checks.
	DNSHost string
	// ThinkingToggleSupported indicates the provider's wire protocol honors
	// the ThinkingEnabled toggle parameter.
	ThinkingToggleSupported bool
	// DefaultThinkingDisabled means the provider defaults thinking OFF when
	// no explicit preference is set (e.g. longcat, kimi, deepseek).
	DefaultThinkingDisabled 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 SpecByDeploymentID added in v0.2.2

func SpecByDeploymentID(deploymentID string) (ProviderSpec, bool)

SpecByDeploymentID finds a provider spec by its deployment id.

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 RegionOption added in v0.2.2

type RegionOption struct {
	Value       string
	DisplayName string
	Endpoint    string
}

RegionOption describes one selectable region for a regional gateway.

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