Documentation
¶
Index ¶
- func AgentHostname() string
- func AgentIP() string
- func AgentLabels() map[string]string
- func DetectHostname() string
- func DetectIP() string
- func ExpandWithBuiltins(raw string, builtins map[string]string) string
- func GetOutboundIP() (net.IP, error)
- func HostBuiltins() map[string]string
- func HostBuiltinsWithoutIP() map[string]string
- func InitConfig(configDir string, interval int64, plugins, loglevel string) error
- func LoadOrCreateAgentID() (uuid.UUID, error)
- type AIConfig
- type Alerting
- type ConfigType
- type ConsoleConfig
- type DiagnoseConfig
- type Duration
- type FlashdutyConfig
- type GatewayConfig
- type Global
- type HTTPConfig
- type InternalConfig
- type LogConfig
- type MCPConfig
- type MCPServerConfig
- type ModelConfig
- type NotifyConfig
- type PagerDutyConfig
- type ServerConfig
- type Size
- type WebAPIConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentHostname ¶
func AgentHostname() string
AgentHostname returns the hostname identity exposed to the server. It follows the resolved from_hostname label when present. For auto-detected values (no env var), results are cached for 1 minute.
func AgentIP ¶
func AgentIP() string
AgentIP returns the IP identity exposed to the server. For auto-detected values (no env var), results are cached for 1 minute.
func AgentLabels ¶
AgentLabels returns a snapshot of global labels with live from_hostip and from_hostname values (reflecting any auto-detected changes).
func DetectHostname ¶
func DetectHostname() string
DetectHostname returns the current system hostname via os.Hostname.
func DetectIP ¶
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 ¶
ExpandWithBuiltins expands ${VAR} references in raw, checking builtins first and falling back to environment variables.
func HostBuiltins ¶
HostBuiltins computes host-level built-in variables once. Callers should compute this early and pass it to expandWithBuiltins.
func HostBuiltinsWithoutIP ¶
HostBuiltinsWithoutIP returns built-in host variables that do not require network probing.
func LoadOrCreateAgentID ¶ added in v0.1.4
LoadOrCreateAgentID reads the agent_id from state.d/agent_id. If the file does not exist, a new UUIDv4 is generated and persisted.
Types ¶
type AIConfig ¶
type AIConfig struct {
Enabled bool `toml:"enabled"`
ModelPriority []string `toml:"model_priority"`
Models map[string]ModelConfig `toml:"models"`
Gateway GatewayConfig `toml:"gateway"`
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) ContextWindowLimit ¶
ContextWindowLimit returns 80% of the primary model's context window size, used as the safe upper bound for message token budgeting. Returns 0 if no models are configured.
func (*AIConfig) PrimaryModel ¶
func (c *AIConfig) PrimaryModel() ModelConfig
PrimaryModel returns the first configured local model in the priority list. Returns the zero value when no local model is configured.
func (*AIConfig) PrimaryModelName ¶
PrimaryModelName returns the name of the first model in the priority list.
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 ¶
type ConsoleConfig struct {
Enabled bool `toml:"enabled"`
}
type DiagnoseConfig ¶
type Duration ¶
Duration is a time.Duration
func (*Duration) HumanString ¶
func (*Duration) UnmarshalTOML ¶
UnmarshalTOML parses the duration from the TOML config file
func (*Duration) UnmarshalText ¶
type FlashdutyConfig ¶
type GatewayConfig ¶
type GatewayConfig struct {
Enabled bool `toml:"enabled"`
BaseURL string `toml:"base_url"`
AgentToken string `toml:"agent_token"`
RequestTimeout Duration `toml:"request_timeout"`
MaxRetries int `toml:"max_retries"`
FallbackToDirect bool `toml:"fallback_to_direct"`
}
GatewayConfig defines the server-backed AI gateway connection.
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 ¶
func (ic *InternalConfig) GetDiagnoseConfig() DiagnoseConfig
func (*InternalConfig) GetInterval ¶
func (ic *InternalConfig) GetInterval() Duration
func (*InternalConfig) GetLabels ¶
func (ic *InternalConfig) GetLabels() map[string]string
type MCPConfig ¶
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 ¶
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 ¶
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 ¶
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 ¶
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"`
MaxCompletionTokens int `toml:"max_completion_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 ¶
func (m ModelConfig) ExtraStr(key string) string
ExtraStr returns a string value from ExtraBody, or empty if missing.
type NotifyConfig ¶
type NotifyConfig struct {
Console *ConsoleConfig `toml:"console"`
Flashduty *FlashdutyConfig `toml:"flashduty"`
PagerDuty *PagerDutyConfig `toml:"pagerduty"`
WebAPI *WebAPIConfig `toml:"webapi"`
}
type PagerDutyConfig ¶
type ServerConfig ¶
type ServerConfig struct {
Enabled bool `toml:"enabled"`
Address string `toml:"address"`
AgentToken string `toml:"agent_token"`
CAFile string `toml:"ca_file"`
TLSSkipVerify bool `toml:"tls_skip_verify"`
AlertBufferSize int `toml:"alert_buffer_size"`
}
ServerConfig defines the optional catpaw-server connection. When Enabled is false (default), the Agent runs in pure local mode.
func (ServerConfig) GatewayBaseURL ¶
func (c ServerConfig) GatewayBaseURL() (string, error)
func (*ServerConfig) GetAlertBufferSize ¶
func (c *ServerConfig) GetAlertBufferSize() int
func (ServerConfig) HTTPBaseURL ¶
func (c ServerConfig) HTTPBaseURL() (string, error)
func (ServerConfig) WebSocketURL ¶
func (c ServerConfig) WebSocketURL() (string, error)
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.