Documentation
¶
Index ¶
- func AutoImportEnvProviders(ctx context.Context, logger *slog.Logger, store Store, ...) error
- func WithActor(ctx context.Context, actor string) context.Context
- type AuditEvent
- type MemoryStore
- func (s *MemoryStore) Backend() string
- func (s *MemoryStore) DeletePolicyRule(ctx context.Context, id string) error
- func (s *MemoryStore) DeleteProvider(ctx context.Context, id string) error
- func (s *MemoryStore) DeleteProviderCredential(ctx context.Context, id string) (Provider, error)
- func (s *MemoryStore) Prune(_ context.Context, maxAge time.Duration, maxCount int) (int, error)
- func (s *MemoryStore) RotateProviderSecret(ctx context.Context, id string, secret ProviderSecret) (Provider, error)
- func (s *MemoryStore) Snapshot(_ context.Context) (State, error)
- func (s *MemoryStore) UpsertPolicyRule(ctx context.Context, rule config.PolicyRuleConfig) (config.PolicyRuleConfig, error)
- func (s *MemoryStore) UpsertProvider(ctx context.Context, provider Provider, secret *ProviderSecret) (Provider, error)
- type Provider
- type ProviderSecret
- type SQLiteStore
- func (s *SQLiteStore) Backend() string
- func (s *SQLiteStore) DeletePolicyRule(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteProvider(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteProviderCredential(ctx context.Context, id string) (Provider, error)
- func (s *SQLiteStore) Prune(ctx context.Context, maxAge time.Duration, maxCount int) (int, error)
- func (s *SQLiteStore) RotateProviderSecret(ctx context.Context, id string, secret ProviderSecret) (Provider, error)
- func (s *SQLiteStore) Snapshot(ctx context.Context) (State, error)
- func (s *SQLiteStore) UpsertPolicyRule(ctx context.Context, rule config.PolicyRuleConfig) (config.PolicyRuleConfig, error)
- func (s *SQLiteStore) UpsertProvider(ctx context.Context, provider Provider, secret *ProviderSecret) (Provider, error)
- type State
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoImportEnvProviders ¶
func AutoImportEnvProviders(ctx context.Context, logger *slog.Logger, store Store, configs []config.OpenAICompatibleProviderConfig, localProvidersAllowed bool) error
AutoImportEnvProviders mirrors each env-PRECONFIGURED provider config into the control-plane store as a Provider row, so the admin UI shows a single source of truth instead of a hidden env-only branch. CP store edits win on conflict: if a row already exists for the same id we leave it alone and let the operator's admin-panel changes stand.
Called once at startup from cmd/hecate/main.go after the provider runtime reload. Logs each upsert at info level and tolerates per-row failures (logs at warn) so a single bad config can't keep the gateway from booting.
Types ¶
type AuditEvent ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory control plane store. State is lost on restart. It is used as the default backend when no persistent store is configured, allowing provider toggling and other control-plane operations without requiring external storage.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) Backend ¶
func (s *MemoryStore) Backend() string
func (*MemoryStore) DeletePolicyRule ¶
func (s *MemoryStore) DeletePolicyRule(ctx context.Context, id string) error
func (*MemoryStore) DeleteProvider ¶
func (s *MemoryStore) DeleteProvider(ctx context.Context, id string) error
func (*MemoryStore) DeleteProviderCredential ¶
func (*MemoryStore) RotateProviderSecret ¶
func (s *MemoryStore) RotateProviderSecret(ctx context.Context, id string, secret ProviderSecret) (Provider, error)
func (*MemoryStore) UpsertPolicyRule ¶
func (s *MemoryStore) UpsertPolicyRule(ctx context.Context, rule config.PolicyRuleConfig) (config.PolicyRuleConfig, error)
func (*MemoryStore) UpsertProvider ¶
func (s *MemoryStore) UpsertProvider(ctx context.Context, provider Provider, secret *ProviderSecret) (Provider, error)
type Provider ¶
type Provider struct {
ID string `json:"id"`
Name string `json:"name"`
PresetID string `json:"preset_id,omitempty"`
// CustomName is an optional operator-supplied label that appears
// alongside Name in the providers table, used to tell two
// instances of the same preset apart ("Anthropic" + "Prod" vs
// "Anthropic" + "Dev"). Name itself stays fixed for preset-based
// providers; this is the disambiguator.
CustomName string `json:"custom_name,omitempty"`
AccountID string `json:"account_id,omitempty"`
Kind string `json:"kind"`
Protocol string `json:"protocol"`
BaseURL string `json:"base_url"`
APIVersion string `json:"api_version,omitempty"`
DefaultModel string `json:"default_model,omitempty"`
ExplicitFields []string `json:"explicit_fields,omitempty"`
Enabled bool `json:"enabled"`
CredentialID string `json:"credential_id,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
type ProviderSecret ¶
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore mirrors the memory Store-interface surface while keeping a single-row-per-key JSON payload shape for simple local persistence.
SQLite-specific choices that aren't accidental:
- state column is TEXT (SQLite has no JSONB; we marshal/unmarshal in Go regardless, so the on-disk type is moot).
- placeholders are `?` rather than `$N`.
- the upsert uses ON CONFLICT (store_key) DO UPDATE.
- updated_at is informational (we never read it back); it exists so operators can inspect the backing store directly.
func NewPostgresStore ¶
func NewPostgresStore(ctx context.Context, client *storage.PostgresClient, key string) (*SQLiteStore, error)
func NewSQLiteStore ¶
func NewSQLiteStore(ctx context.Context, client *storage.SQLiteClient, key string) (*SQLiteStore, error)
func (*SQLiteStore) Backend ¶
func (s *SQLiteStore) Backend() string
func (*SQLiteStore) DeletePolicyRule ¶
func (s *SQLiteStore) DeletePolicyRule(ctx context.Context, id string) error
func (*SQLiteStore) DeleteProvider ¶
func (s *SQLiteStore) DeleteProvider(ctx context.Context, id string) error
func (*SQLiteStore) DeleteProviderCredential ¶
func (*SQLiteStore) RotateProviderSecret ¶
func (s *SQLiteStore) RotateProviderSecret(ctx context.Context, id string, secret ProviderSecret) (Provider, error)
func (*SQLiteStore) UpsertPolicyRule ¶
func (s *SQLiteStore) UpsertPolicyRule(ctx context.Context, rule config.PolicyRuleConfig) (config.PolicyRuleConfig, error)
func (*SQLiteStore) UpsertProvider ¶
func (s *SQLiteStore) UpsertProvider(ctx context.Context, provider Provider, secret *ProviderSecret) (Provider, error)
type State ¶
type State struct {
Providers []Provider `json:"providers,omitempty"`
ProviderSecrets []ProviderSecret `json:"provider_secrets,omitempty"`
PolicyRules []config.PolicyRuleConfig `json:"policy_rules,omitempty"`
Events []AuditEvent `json:"events,omitempty"`
}
type Store ¶
type Store interface {
Backend() string
Snapshot(ctx context.Context) (State, error)
UpsertProvider(ctx context.Context, provider Provider, secret *ProviderSecret) (Provider, error)
RotateProviderSecret(ctx context.Context, id string, secret ProviderSecret) (Provider, error)
DeleteProviderCredential(ctx context.Context, id string) (Provider, error)
DeleteProvider(ctx context.Context, id string) error
UpsertPolicyRule(ctx context.Context, rule config.PolicyRuleConfig) (config.PolicyRuleConfig, error)
DeletePolicyRule(ctx context.Context, id string) error
Prune(ctx context.Context, maxAge time.Duration, maxCount int) (int, error)
}