providerservice

package
v1.0.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ConfigMissing    = "missing"
	ConfigConfigured = "configured"
	ConfigInvalid    = "invalid"
)

Connection config states.

View Source
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.

View Source
const (
	HealthUnknown     = "unknown"
	HealthChecking    = "checking"
	HealthAvailable   = "available"
	HealthUnavailable = "unavailable"
)

Connection health states.

View Source
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

View Source
var ErrInvalidProvider = errors.New("invalid provider")

Functions

This section is empty.

Types

type ConfigureProviderRequest

type ConfigureProviderRequest struct {
	APIKey       string
	APIKeyEnv    string
	BaseURL      string
	DefaultModel string
	Upsert       bool
	SetDefault   bool
}

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 CreateConnectionRequest struct {
	Name      string
	APIKey    string
	APIKeyEnv string
	BaseURL   string
}

type LoginStart

type LoginStart struct {
	Provider     string    `json:"provider"`
	ConnectionID string    `json:"connectionId,omitempty"`
	State        string    `json:"state"`
	URL          string    `json:"url,omitempty"`
	Code         string    `json:"code,omitempty"`
	ExpiresAt    time.Time `json:"expiresAt,omitempty"`
}

type LoginStatus

type LoginStatus struct {
	Provider     string    `json:"provider"`
	ConnectionID string    `json:"connectionId,omitempty"`
	State        string    `json:"state"`
	URL          string    `json:"url,omitempty"`
	Code         string    `json:"code,omitempty"`
	ExpiresAt    time.Time `json:"expiresAt,omitempty"`
	Error        string    `json:"error,omitempty"`
}

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
}

func New

func New(dbInstance libdb.DBManager, workspaceID string, opts ...Option) Service

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.

Jump to

Keyboard shortcuts

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