Documentation
¶
Index ¶
Constants ¶
const ( ConfigMissing = "missing" ConfigConfigured = "configured" ConfigInvalid = "invalid" )
Connection config states.
const ( AuthNotRequired = "not_required" AuthAuthenticated = "authenticated" AuthLoginRequired = "login_required" AuthRefreshRequired = "refresh_required" AuthLoginPending = "login_pending" )
Connection auth states. login_pending is reported while a device-code sign-in is in flight; the rest mirror the modelauth states.
const ( HealthUnknown = "unknown" HealthChecking = "checking" HealthAvailable = "available" )
Connection health states.
const ( ProviderTypeLocal = "local" ProviderTypeOllama = "ollama" ProviderTypeOpenAI = "openai" ProviderTypeAnthropic = "anthropic" ProviderTypeMistral = "mistral" ProviderTypeBedrock = "bedrock" ProviderTypeGemini = "gemini" ProviderTypeVLLM = "vllm" ProviderTypeVertexGoogle = "vertex-google" ProviderTypeDeepSeek = "deepseek" ProviderTypeOpenAICodex = "openai-codex" )
Variables ¶
var ErrInvalidProvider = errors.New("invalid provider")
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
ID string `json:"id"`
Name string `json:"name"`
ProviderType string `json:"providerType"`
BaseURL string `json:"baseUrl"`
ConfigState string `json:"configState"`
AuthState string `json:"authState"`
Health string `json:"health"`
ErrorCode string `json:"errorCode,omitempty"`
Error string `json:"error,omitempty"`
SecretSource string `json:"secretSource"`
SecretConfigured bool `json:"secretConfigured"`
SecretPresent bool `json:"secretPresent"`
APIKeyEnv string `json:"apiKeyEnv,omitempty"`
ModelCount int `json:"modelCount"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Connection is a configured instance of a provider: one runtime backend plus its credential and sign-in. Secrets are never part of it.
type CreateConnectionRequest ¶
type LoginStart ¶
type LoginStatus ¶
type Option ¶
type Option func(*service)
Option configures optional collaborators of the provider service.
func WithRuntimeState ¶
func WithRuntimeState(state *runtimestate.State) Option
WithRuntimeState lets connections report live health and model counts and lets a connection be re-checked on demand. Without it, health is "unknown".
type ProviderCapability ¶
type ProviderCapability struct {
Provider string `json:"provider"`
DefaultBaseURL string `json:"defaultBaseUrl,omitempty"`
RequiresBaseURL bool `json:"requiresBaseUrl"`
RequiresSecretConfig bool `json:"requiresSecretConfig"`
RequiresLogin bool `json:"requiresLogin,omitempty"`
RecommendedAPIKeyEnv string `json:"recommendedApiKeyEnv,omitempty"`
}
type ProviderStatus ¶
type ProviderStatus struct {
Provider string `json:"provider"`
Configured bool `json:"configured"`
BackendID string `json:"backendId,omitempty"`
BackendName string `json:"backendName,omitempty"`
BaseURL string `json:"baseUrl,omitempty"`
SecretSource string `json:"secretSource"`
SecretConfigured bool `json:"secretConfigured"`
SecretPresent bool `json:"secretPresent"`
APIKeyEnv string `json:"apiKeyEnv,omitempty"`
RecommendedAPIKeyEnv string `json:"recommendedApiKeyEnv,omitempty"`
DefaultProvider string `json:"defaultProvider,omitempty"`
DefaultModel string `json:"defaultModel,omitempty"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
AuthState string `json:"authState,omitempty"`
LoginRequired bool `json:"loginRequired,omitempty"`
}
type Service ¶
type Service interface {
Configure(ctx context.Context, providerType string, req ConfigureProviderRequest) (*ProviderStatus, error)
GetProviderConfig(ctx context.Context, providerType string) (*ProviderStatus, error)
DeleteProviderConfig(ctx context.Context, providerType string) error
ListProviderConfigs(ctx context.Context, createdAtCursor *time.Time, limit int) ([]*ProviderStatus, error)
ListSupportedProviders(ctx context.Context) ([]ProviderCapability, error)
StartLogin(ctx context.Context, providerType string) (*LoginStart, error)
LoginStatus(ctx context.Context, providerType string) (*LoginStatus, error)
Logout(ctx context.Context, providerType string) error
CancelLogin(ctx context.Context, providerType string) (*LoginStatus, error)
ListConnections(ctx context.Context) ([]*Connection, error)
GetConnection(ctx context.Context, id string) (*Connection, error)
CreateConnection(ctx context.Context, providerType string, req CreateConnectionRequest) (*Connection, error)
UpdateConnection(ctx context.Context, id string, req UpdateConnectionRequest) (*Connection, error)
DeleteConnection(ctx context.Context, id string) error
CheckConnection(ctx context.Context, id string) (*Connection, error)
StartConnectionLogin(ctx context.Context, id string) (*LoginStart, error)
ConnectionLoginStatus(ctx context.Context, id string) (*LoginStatus, error)
CancelConnectionLogin(ctx context.Context, id string) (*LoginStatus, error)
LogoutConnection(ctx context.Context, id string) error
}
type UpdateConnectionRequest ¶
type UpdateConnectionRequest struct {
Name *string
BaseURL *string
APIKey *string
APIKeyEnv *string
ClearSecret bool
}
UpdateConnectionRequest changes only the fields that are non-nil. Setting APIKey replaces the stored credential with a literal key, setting APIKeyEnv replaces it with an environment reference, ClearSecret removes it.