config

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.9.0"

Functions

func DetectIP added in v0.10.0

func DetectIP() string

DetectIP returns the preferred outbound IPv4 address. It first tries gateway-based detection via GetOutboundIP, then falls back to scanning network interfaces.

func ExpandWithBuiltins added in v0.10.0

func ExpandWithBuiltins(raw string, builtins map[string]string) string

ExpandWithBuiltins expands ${VAR} references in raw, checking builtins first and falling back to environment variables.

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

Get preferred outbound ip of this machine

func HostBuiltins added in v0.10.0

func HostBuiltins() map[string]string

HostBuiltins computes host-level built-in variables once. Callers should compute this early and pass it to expandWithBuiltins.

func InitConfig

func InitConfig(configDir string, interval int64, plugins, loglevel string) error

Types

type AIConfig added in v0.10.0

type AIConfig struct {
	Enabled       bool                   `toml:"enabled"`
	ModelPriority []string               `toml:"model_priority"`
	Models        map[string]ModelConfig `toml:"models"`

	MaxRounds      int      `toml:"max_rounds"`
	RequestTimeout Duration `toml:"request_timeout"`

	MaxRetries   int      `toml:"max_retries"`
	RetryBackoff Duration `toml:"retry_backoff"`

	MaxConcurrentDiagnoses int    `toml:"max_concurrent_diagnoses"`
	QueueFullPolicy        string `toml:"queue_full_policy"`
	DailyTokenLimit        int    `toml:"daily_token_limit"`

	ToolTimeout     Duration `toml:"tool_timeout"`
	AggregateWindow Duration `toml:"aggregate_window"`

	DiagnoseRetention Duration `toml:"diagnose_retention"`
	DiagnoseMaxCount  int      `toml:"diagnose_max_count"`

	Language string `toml:"language"`

	MCP MCPConfig `toml:"mcp"`
}

AIConfig holds the full AI subsystem configuration. ModelPriority defines the failover order; Models maps profile names to ModelConfig.

func (*AIConfig) PrimaryModel added in v0.10.0

func (c *AIConfig) PrimaryModel() ModelConfig

PrimaryModel returns the first model in the priority list. Panics if ModelPriority is empty or references a missing model — Validate should always be called before this.

func (*AIConfig) PrimaryModelName added in v0.10.0

func (c *AIConfig) PrimaryModelName() string

PrimaryModelName returns the name of the first model in the priority list.

func (*AIConfig) Validate added in v0.10.0

func (c *AIConfig) Validate() error

type Alerting

type Alerting struct {
	Disabled bool `toml:"disabled"`

	// like prometheus `for`
	ForDuration Duration `toml:"for_duration"`

	// repeat interval
	RepeatInterval Duration `toml:"repeat_interval"`

	// maximum number of notifications
	RepeatNumber int `toml:"repeat_number"`

	// set to true to suppress recovery notifications
	DisableRecoveryNotification bool `toml:"disable_recovery_notification"`
}

type ConfigType

type ConfigType struct {
	ConfigDir string `toml:"-"`
	StateDir  string `toml:"-"`
	Plugins   string `toml:"-"`
	Loglevel  string `toml:"-"`

	Global    Global       `toml:"global"`
	LogConfig LogConfig    `toml:"log"`
	Notify    NotifyConfig `toml:"notify"`
	AI        AIConfig     `toml:"ai"`
	Server    ServerConfig `toml:"server"`
}
var Config *ConfigType

type ConsoleConfig added in v0.10.0

type ConsoleConfig struct {
	Enabled bool `toml:"enabled"`
}

type DiagnoseConfig added in v0.10.0

type DiagnoseConfig struct {
	Enabled     bool     `toml:"enabled"`
	MinSeverity string   `toml:"min_severity"`
	Timeout     Duration `toml:"timeout"`
	Cooldown    Duration `toml:"cooldown"`
}

type Duration

type Duration time.Duration

Duration is a time.Duration

func (*Duration) HumanString

func (d *Duration) HumanString() string

func (*Duration) UnmarshalTOML

func (d *Duration) UnmarshalTOML(b []byte) error

UnmarshalTOML parses the duration from the TOML config file

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type FlashdutyConfig added in v0.10.0

type FlashdutyConfig struct {
	IntegrationKey string   `toml:"integration_key"`
	BaseUrl        string   `toml:"base_url"`
	Timeout        Duration `toml:"timeout"`
	MaxRetries     int      `toml:"max_retries"`
}

type Global

type Global struct {
	Interval Duration          `toml:"interval"`
	Labels   map[string]string `toml:"labels"`
}

type HTTPConfig

type HTTPConfig struct {
	Interface       string   `toml:"interface"`
	Method          string   `toml:"method"`
	Timeout         Duration `toml:"timeout"`
	FollowRedirects *bool    `toml:"follow_redirects"`
	BasicAuthUser   string   `toml:"basic_auth_user"`
	BasicAuthPass   string   `toml:"basic_auth_pass"`
	Headers         []string `toml:"headers"`
	Payload         string   `toml:"payload"`
	HTTPProxy       string   `toml:"http_proxy"`
	tls.ClientConfig
}

func (*HTTPConfig) GetMethod

func (hc *HTTPConfig) GetMethod() string

func (*HTTPConfig) GetProxy

func (hc *HTTPConfig) GetProxy() (proxyFunc, error)

func (*HTTPConfig) GetTimeout

func (hc *HTTPConfig) GetTimeout() Duration

type InternalConfig

type InternalConfig struct {
	// append labels to every event
	Labels map[string]string `toml:"labels"`

	// gather interval
	Interval Duration `toml:"interval"`

	// alerting rule
	Alerting Alerting `toml:"alerting"`

	// AI diagnose config
	Diagnose DiagnoseConfig `toml:"diagnose"`
}

func (*InternalConfig) GetAlerting

func (ic *InternalConfig) GetAlerting() Alerting

func (*InternalConfig) GetDiagnoseConfig added in v0.10.0

func (ic *InternalConfig) GetDiagnoseConfig() DiagnoseConfig

func (*InternalConfig) GetInterval

func (ic *InternalConfig) GetInterval() Duration

func (*InternalConfig) GetLabels

func (ic *InternalConfig) GetLabels() map[string]string

type LogConfig

type LogConfig struct {
	Level  string                 `toml:"level"`
	Format string                 `toml:"format"`
	Output string                 `toml:"output"`
	Fields map[string]interface{} `toml:"fields"`
}

type MCPConfig added in v0.10.0

type MCPConfig struct {
	Enabled         bool              `toml:"enabled"`
	DefaultIdentity string            `toml:"default_identity"`
	Servers         []MCPServerConfig `toml:"servers"`
}

MCPConfig holds configuration for MCP (Model Context Protocol) server connections.

type MCPServerConfig added in v0.10.0

type MCPServerConfig struct {
	Name       string            `toml:"name"`
	Command    string            `toml:"command"`
	Args       []string          `toml:"args"`
	Env        map[string]string `toml:"env"`
	Identity   string            `toml:"identity"`
	ToolsAllow []string          `toml:"tools_allow"`
}

MCPServerConfig defines one MCP server connection.

func (*MCPServerConfig) IsToolAllowed added in v0.10.0

func (s *MCPServerConfig) IsToolAllowed(toolName string) bool

IsToolAllowed checks whether a tool name passes the whitelist filter. If ToolsAllow is empty, all tools are allowed.

func (*MCPServerConfig) ResolvedIdentity added in v0.10.0

func (s *MCPServerConfig) ResolvedIdentity(defaultIdentity string, builtins map[string]string) string

ResolvedIdentity returns the identity string for this server, falling back to defaultIdentity, then auto-detected host info. Variables ${HOSTNAME}, ${SHORT_HOSTNAME}, ${IP}, and ${ENV_VAR} are expanded. builtins should be obtained from HostBuiltins().

type ModelConfig added in v0.10.0

type ModelConfig struct {
	// Provider selects the backend: "" or "openai" for OpenAI-compatible,
	// "bedrock" for AWS Bedrock Converse API with SigV4 auth.
	Provider string `toml:"provider"`

	BaseURL       string                 `toml:"base_url"`
	APIKey        string                 `toml:"api_key"`
	Model         string                 `toml:"model"`
	MaxTokens     int                    `toml:"max_tokens"`
	ContextWindow int                    `toml:"context_window"`
	InputPrice    float64                `toml:"input_price"`
	OutputPrice   float64                `toml:"output_price"`
	ExtraBody     map[string]interface{} `toml:"extra_body"`
}

ModelConfig defines connection and model-specific parameters for one AI model.

func (ModelConfig) ExtraStr added in v0.11.0

func (m ModelConfig) ExtraStr(key string) string

ExtraStr returns a string value from ExtraBody, or empty if missing.

type NotifyConfig added in v0.10.0

type NotifyConfig struct {
	Console   *ConsoleConfig   `toml:"console"`
	Flashduty *FlashdutyConfig `toml:"flashduty"`
	PagerDuty *PagerDutyConfig `toml:"pagerduty"`
	WebAPI    *WebAPIConfig    `toml:"webapi"`
}

type PagerDutyConfig added in v0.10.0

type PagerDutyConfig struct {
	RoutingKey  string            `toml:"routing_key"`
	BaseUrl     string            `toml:"base_url"`
	SeverityMap map[string]string `toml:"severity_map"`
	Timeout     Duration          `toml:"timeout"`
	MaxRetries  int               `toml:"max_retries"`
}

type ServerConfig added in v0.11.0

type ServerConfig struct {
	Enabled       bool   `toml:"enabled"`
	URL           string `toml:"url"`
	TenantToken   string `toml:"tenant_token"`
	CAFile        string `toml:"ca_file"`
	TLSSkipVerify bool   `toml:"tls_skip_verify"`
}

ServerConfig defines the optional catpaw-server connection. When Enabled is false (default), the Agent runs in pure local mode.

type Size

type Size int64

Size represents a byte size with human-readable TOML parsing. Supports: "50MB", "1GB", "512KB", "1024" (bytes), etc. Case-insensitive units: B, KB, MB, GB, TB.

const (
	KB Size = 1 << (10 * iota)
	MB
	GB
	TB
)

func (Size) String

func (s Size) String() string

func (*Size) UnmarshalTOML

func (s *Size) UnmarshalTOML(b []byte) error

func (*Size) UnmarshalText

func (s *Size) UnmarshalText(text []byte) error

type WebAPIConfig added in v0.10.0

type WebAPIConfig struct {
	URL        string            `toml:"url"`
	Method     string            `toml:"method"`
	Headers    map[string]string `toml:"headers"`
	Timeout    Duration          `toml:"timeout"`
	MaxRetries int               `toml:"max_retries"`
}

Jump to

Keyboard shortcuts

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