Documentation
¶
Index ¶
- func SaveConfig(cfg *Config, filePath string) error
- type AdminConfig
- type AgentsConfig
- type AuthConfig
- type CORSConfig
- type Config
- type ContentConfig
- type I18nConfig
- type LLMConfig
- type MediaConfig
- type MediaLocalConfig
- type MediaS3Config
- type OpenAPIConfig
- type RateLimitConfig
- type RedisConfig
- type WebhooksConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveConfig ¶
SaveConfig writes the provided Config struct to a YAML file.
Types ¶
type AdminConfig ¶ added in v0.5.0
type AdminConfig struct {
Username string `mapstructure:"username" yaml:"username"`
Email string `mapstructure:"email" yaml:"email"`
Password string `mapstructure:"password" yaml:"password"`
}
AdminConfig is the administrator created on an empty instance.
type AgentsConfig ¶ added in v0.5.0
type AgentsConfig struct {
// RunsKept is how many runs (with their steps) are kept per agent.
RunsKept int `mapstructure:"runs_kept" yaml:"runs_kept"`
}
AgentsConfig controls agent run history.
type AuthConfig ¶ added in v0.5.0
type AuthConfig struct {
// Registration is "disabled" (default: accounts are created by admins)
// or "open" (anyone can create a viewer account at /auth/register).
Registration string `mapstructure:"registration" yaml:"registration"`
}
AuthConfig controls account creation.
type CORSConfig ¶
type CORSConfig struct {
AllowedOrigins []string `mapstructure:"allowed_origins" yaml:"allowed_origins"`
AllowedMethods []string `mapstructure:"allowed_methods" yaml:"allowed_methods"`
AllowedHeaders []string `mapstructure:"allowed_headers" yaml:"allowed_headers"`
AllowCredentials bool `mapstructure:"allow_credentials" yaml:"allow_credentials"`
MaxAge int `mapstructure:"max_age" yaml:"max_age"`
}
type Config ¶
type Config struct {
LogLevel string `mapstructure:"log_level"`
Mode string `mapstructure:"mode" yaml:"mode"` // Gin mode: development | production | test
TelemetryEnabled bool `mapstructure:"telemetry_enabled"`
JWTSecret string `mapstructure:"jwt_secret"`
DatabaseURL string `mapstructure:"database_url"`
ServerPort string `mapstructure:"server_port"`
MinPasswordLength int `json:"min_password_length" yaml:"min_password_length"`
// Redis settings
Redis RedisConfig `mapstructure:"redis"`
// CORS settings
CORS CORSConfig `mapstructure:"cors"`
// LLM settings
LLM LLMConfig `mapstructure:"llm" yaml:"llm"`
// Rate limiting for /auth/* (shared across replicas through Redis)
RateLimit RateLimitConfig `mapstructure:"rate_limit" yaml:"rate_limit"`
// TrustedProxies lists the proxies (IPs or CIDRs) whose X-Forwarded-For
// header is trusted to find the client IP. Empty: use the TCP peer.
TrustedProxies []string `mapstructure:"trusted_proxies" yaml:"trusted_proxies"`
// Media uploads and storage
Media MediaConfig `mapstructure:"media" yaml:"media"`
// Outbound webhooks
Webhooks WebhooksConfig `mapstructure:"webhooks" yaml:"webhooks"`
// OpenAPI description and Swagger UI
OpenAPI OpenAPIConfig `mapstructure:"openapi" yaml:"openapi"`
// Agents
Agents AgentsConfig `mapstructure:"agents" yaml:"agents"`
// Content controls content history.
Content ContentConfig `mapstructure:"content" yaml:"content"`
// I18n sets the default content locale.
I18n I18nConfig `mapstructure:"i18n" yaml:"i18n"`
// AutoMigrate applies pending database migrations when the API starts.
// When false, the API refuses to start on an outdated schema: run
// `gohead migrate` first (the Helm chart does, in an init container).
AutoMigrate bool `mapstructure:"auto_migrate" yaml:"auto_migrate"`
// Auth controls self-registration.
Auth AuthConfig `mapstructure:"auth" yaml:"auth"`
// Admin is the first administrator, created at startup when the
// instance has no users.
Admin AdminConfig `mapstructure:"admin" yaml:"admin"`
}
Config holds all application settings.
func LoadConfig ¶
LoadConfig loads the configuration from file and environment variables.
func LoadTestConfig ¶
LoadTestConfig loads a test configuration file.
func (Config) RedisClientOpt ¶
func (c Config) RedisClientOpt() asynq.RedisClientOpt
RedisClientOpt returns the asynq connection options for the configured Redis, including password and database index.
func (Config) RedisOptions ¶
RedisOptions returns go-redis options for the configured Redis.
type ContentConfig ¶ added in v0.5.0
type ContentConfig struct {
// RevisionsKept is how many revisions are kept per entry (0: all).
RevisionsKept int `mapstructure:"revisions_kept" yaml:"revisions_kept"`
}
ContentConfig controls content history.
type I18nConfig ¶ added in v0.5.0
type I18nConfig struct {
// DefaultLocale is the locale of existing and new content when the
// database has no locale yet (first start, or upgrade). Later changes
// go through the locales API.
DefaultLocale string `mapstructure:"default_locale" yaml:"default_locale"`
}
I18nConfig sets up content locales.
type LLMConfig ¶
type LLMConfig struct {
Provider string `mapstructure:"provider" yaml:"provider"`
Model string `mapstructure:"model" yaml:"model"`
APIKey string `mapstructure:"api_key" yaml:"api_key"`
APISecret string `mapstructure:"api_secret" yaml:"api_secret"`
BaseURL string `mapstructure:"base_url" yaml:"base_url"` // optional API endpoint override
// Prices in USD per million tokens, used to estimate run costs and
// enforce cost limits. Zero: cost is not tracked.
InputCostPerMillion float64 `mapstructure:"input_cost_per_million" yaml:"input_cost_per_million" json:"input_cost_per_million,omitempty"`
OutputCostPerMillion float64 `mapstructure:"output_cost_per_million" yaml:"output_cost_per_million" json:"output_cost_per_million,omitempty"`
}
LLMConfig holds settings for Large Language Model providers.
type MediaConfig ¶ added in v0.4.0
type MediaConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Driver string `mapstructure:"driver" yaml:"driver"` // local | s3
MaxSizeMB int `mapstructure:"max_size_mb" yaml:"max_size_mb"`
AllowedTypes []string `mapstructure:"allowed_types" yaml:"allowed_types"` // MIME patterns; empty = built-in list
// PublicURL is the base URL files are downloaded from (CDN, public
// bucket, or the API's /uploads). Empty: /uploads on the API for local
// files, presigned URLs for S3.
PublicURL string `mapstructure:"public_url" yaml:"public_url"`
Local MediaLocalConfig `mapstructure:"local" yaml:"local"`
S3 MediaS3Config `mapstructure:"s3" yaml:"s3"`
}
MediaConfig configures uploads (POST /api/media) and where files are stored.
type MediaLocalConfig ¶ added in v0.4.0
type MediaLocalConfig struct {
Path string `mapstructure:"path" yaml:"path"`
}
MediaLocalConfig configures the filesystem media driver.
type MediaS3Config ¶ added in v0.4.0
type MediaS3Config struct {
Endpoint string `mapstructure:"endpoint" yaml:"endpoint"`
Region string `mapstructure:"region" yaml:"region"`
Bucket string `mapstructure:"bucket" yaml:"bucket"`
AccessKey string `mapstructure:"access_key" yaml:"access_key"`
SecretKey string `mapstructure:"secret_key" yaml:"secret_key"`
UseSSL bool `mapstructure:"use_ssl" yaml:"use_ssl"`
PathStyle bool `mapstructure:"path_style" yaml:"path_style"`
Prefix string `mapstructure:"prefix" yaml:"prefix"`
PresignExpiry time.Duration `mapstructure:"presign_expiry" yaml:"presign_expiry"`
}
MediaS3Config configures the S3-compatible media driver.
type OpenAPIConfig ¶ added in v0.5.0
type OpenAPIConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
// Public serves /api/openapi.json without a token. Off by default: the
// spec describes your content model.
Public bool `mapstructure:"public" yaml:"public"`
}
OpenAPIConfig controls the generated API description.
type RateLimitConfig ¶
type RateLimitConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
// AuthPerMinute is the number of /auth/* requests allowed per client IP
// per minute (0 disables it).
AuthPerMinute int `mapstructure:"auth_per_minute" yaml:"auth_per_minute"`
// LoginFailures is the number of failed logins allowed per username and
// client IP within LoginWindow before further attempts get 429.
LoginFailures int `mapstructure:"login_failures" yaml:"login_failures"`
LoginWindow time.Duration `mapstructure:"login_window" yaml:"login_window"`
}
RateLimitConfig protects the authentication endpoints.
type RedisConfig ¶
type RedisConfig struct {
Address string `mapstructure:"address" yaml:"address"`
Password string `mapstructure:"password" yaml:"password"`
DB int `mapstructure:"db" yaml:"db"`
}
RedisConfig holds settings for the Redis connection.
type WebhooksConfig ¶ added in v0.5.0
type WebhooksConfig struct {
// AllowPrivateNetworks lets webhooks reach private and loopback
// addresses. Link-local (cloud metadata) addresses are always refused.
AllowPrivateNetworks bool `mapstructure:"allow_private_networks" yaml:"allow_private_networks"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
MaxRetries int `mapstructure:"max_retries" yaml:"max_retries"`
}
WebhooksConfig controls outbound webhook deliveries.