Documentation
¶
Overview ¶
Package config loads daemon settings from environment variables and flags.
Index ¶
- Constants
- Variables
- func MissingModel(role, provider string) error
- func SplitComposerModel(spec string) (provider, model string, err error)
- func ValidWorkspaceID(id string) bool
- type Config
- func (c *Config) ComposerReady() error
- func (c *Config) DeciderReady() error
- func (c *Config) DeciderSpec() string
- func (c *Config) ListensLocally() bool
- func (c *Config) SMTPAddr() string
- func (c *Config) SMTPMissing() []string
- func (c *Config) SMTPSecret() (string, error)
- func (c *Config) SecureCookies() bool
- func (c *Config) Validate() error
Constants ¶
const ( SMTPStartTLS = "starttls" // plain connection upgraded with STARTTLS, which the server must offer SMTPImplicit = "implicit" // TLS from the first byte (SMTPS) SMTPNoTLS = "none" // no encryption: only for a mail server on this machine )
SMTP TLS modes, as MAILRULES_SMTP_TLS takes them.
Variables ¶
var ComposerProviders = []string{"anthropic", "openai", "ollama"}
ComposerProviders are the providers the rule composer can write with.
Functions ¶
func MissingModel ¶
MissingModel is the error for a provider spec that names a provider with no default model and no model: role is what the spec is for ("decider", "composer").
func SplitComposerModel ¶
SplitComposerModel reads MAILRULES_COMPOSER_MODEL (the composer_model setting): a bare model name is a Claude model on Anthropic, as it always was; provider:model names the provider (anthropic, openai or ollama), and everything after the first colon is the model, so ollama:llama3.2:3b is the model llama3.2:3b. On error provider and model are still what was written, so a caller can tell a missing model from an unknown provider.
func ValidWorkspaceID ¶
ValidWorkspaceID reports whether id can name an Anthropic workspace: empty (none), or wrkspc_ followed by letters and digits, as the Claude Console shows them. Nothing else may reach the anthropic-workspace-id header.
Types ¶
type Config ¶
type Config struct {
DataDir string
Listen string
Mode string
MasterKey string
MasterKeyFile string
DryRun bool
Decider string
DeciderModel string
FallbackModel string
ComposerModel string
EscalateBelow float64
MinConfidence float64
BodyChars int
ModelConcurrency int
OpenRouterAPIKey string
CloudflareAccountID string
CloudflareAPIToken string
AnthropicAPIKey string
// AnthropicWorkspaceID names the workspace every Claude request runs in (the
// anthropic-workspace-id header). Only a key that covers a whole organisation needs it;
// empty = none sent.
AnthropicWorkspaceID string
OpenAIBaseURL string
OpenAIAPIKey string
OllamaURL string
PricesFile string
LogLevel string
// CookieSecure is auto, true or false; see SecureCookies.
CookieSecure string
// The outgoing mail server the summary email is sent through. SMTPPort 0 means the
// usual port for SMTPTLS; SMTPPasswordFile names a file holding the password, like
// MasterKeyFile. Never logged.
SMTPHost string
SMTPPort int
SMTPUser string
SMTPPassword string
SMTPPasswordFile string
SMTPFrom string
SMTPTLS string // starttls | implicit | none (none: localhost only)
// PublicURL is where the web app is reached from the user's mail program: links in the
// summary email start with it.
PublicURL string
}
Config holds every setting from the backend plan's Configuration table.
func Load ¶
Load reads settings from the environment, then lets flags in args override them. It does not validate; call Validate before serving.
func (*Config) ComposerReady ¶
ComposerReady is DeciderReady for the rule composer's model.
func (*Config) DeciderReady ¶
DeciderReady reports what the chosen decider still needs before it can run. It is not part of Validate: a fresh install starts without a key so the first-run wizard can collect one, and mail waits for review until then.
func (*Config) DeciderSpec ¶
DeciderSpec is the decider as models.NewRouter takes it: "name" or "name:model".
func (*Config) ListensLocally ¶
ListensLocally reports whether the HTTP address is loopback-only.
func (*Config) SMTPAddr ¶
SMTPAddr is the mail server's host:port, with the usual port for the TLS mode when none is set.
func (*Config) SMTPMissing ¶
SMTPMissing lists the environment variables still to set before the summary email can be sent, in the order to set them; empty when it can be. A user name needs a password and a password a user name.
func (*Config) SMTPSecret ¶
SMTPSecret returns the mail server's password: MAILRULES_SMTP_PASSWORD, or the contents of MAILRULES_SMTP_PASSWORD_FILE without its line ending.
func (*Config) SecureCookies ¶
SecureCookies reports whether login cookies are marked HTTPS-only. "auto" means yes unless the daemon listens on loopback only. Set "false" when the daemon listens on every interface but is only published to this machine over plain HTTP (the Docker Compose setup); set "true" behind a TLS proxy.