notify

package
v0.8.19 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeverityInfo     = "info"
	SeverityWarning  = "warning"
	SeverityCritical = "critical"
)
View Source
const (
	KindPendingDecision  = "pending_decision"
	KindGuardrailBlocked = "guardrail_blocked"
	KindSessionState     = "session_state"
)

Variables

This section is empty.

Functions

func SeverityMeetsThreshold added in v0.8.5

func SeverityMeetsThreshold(actual, minimum string) bool

SeverityMeetsThreshold reports whether the actual severity meets or exceeds the minimum threshold.

func Validate added in v0.3.0

func Validate(cfg Config) error

Validate checks whether the notification configuration is valid.

Types

type Config

type Config struct {
	// Enabled is the master switch for notifications and alerts.
	Enabled bool `yaml:"enabled"`
	// Bell enables emitting the ASCII BEL character (\a) to the terminal.
	Bell bool `yaml:"bell"`
	// Desktop enables native operating-system desktop notifications.
	Desktop bool `yaml:"desktop"`
	// MinSeverity specifies the minimum severity required to trigger alerts ("info", "warning", "critical").
	MinSeverity string `yaml:"min_severity,omitempty"`
	// Webhooks defines remote webhook endpoints.
	Webhooks []WebhookConfig `yaml:"webhooks,omitempty"`
}

Config controls operator alert and notification behavior.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default notification settings (local bell & desktop enabled, no webhooks).

func DisabledConfig

func DisabledConfig() Config

DisabledConfig returns settings with all notifications disabled.

type HTTPPoster added in v0.3.0

type HTTPPoster interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPPoster abstracts HTTP POST execution for testing.

type Notification

type Notification struct {
	Title     string    `json:"title"`
	Body      string    `json:"body"`
	SessionID string    `json:"session_id,omitempty"`
	AgentName string    `json:"agent_name,omitempty"`
	Reason    string    `json:"reason,omitempty"`
	EventID   string    `json:"event_id,omitempty"`
	Kind      string    `json:"kind,omitempty"`
	Severity  string    `json:"severity,omitempty"`
	Details   string    `json:"details,omitempty"`
	Timestamp time.Time `json:"timestamp"`
}

Notification carries display-safe information about an event needing operator attention.

type Notifier

type Notifier interface {
	Notify(Notification)
}

Notifier delivers operator notifications and alerts.

func New

func New(config Config, bellOutput io.Writer) Notifier

New constructs an active Notifier based on the given configuration.

func NewNoop

func NewNoop() Notifier

NewNoop returns a notifier that discards all notifications.

func NewWithDiagnostics added in v0.8.6

func NewWithDiagnostics(config Config, bellOutput, diagnostics io.Writer) Notifier

NewWithDiagnostics is New with a writer for webhook delivery failures. The lines name the webhook and the kind of failure only: never its URL, which for Slack and Discord is the credential, and never its headers.

type WebhookConfig added in v0.3.0

type WebhookConfig struct {
	Name        string            `yaml:"name,omitempty"`
	URL         string            `yaml:"url"`
	Format      string            `yaml:"format"`       // "generic", "slack", "discord" (default: "generic")
	MinSeverity string            `yaml:"min_severity"` // "info", "warning", "critical" (default: "warning")
	Timeout     string            `yaml:"timeout"`      // e.g. "5s" (default: "5s")
	Headers     map[string]string `yaml:"headers,omitempty"`
}

WebhookConfig specifies an HTTP webhook destination for notifications.

func MergeWebhookHeaders added in v0.8.6

func MergeWebhookHeaders(existing, edited []WebhookConfig) []WebhookConfig

MergeWebhookHeaders returns edited with each webhook's headers carried over from existing when the edit did not supply any.

A settings editor never receives header values — they are usually an Authorization credential — so every webhook it sends back has none. Saving the form used to replace the whole notifications block with that, erasing every header on every save; on the desktop the notifier was rebuilt at once, so the next alert went out unauthenticated.

Headers follow a webhook by its URL and name. Webhooks that share both are paired in order when there are as many of them before the save as after it, which covers unnamed webhooks; otherwise none of them is given any. A webhook is matched by its URL alone, as a rename, only when that URL has a single webhook both before and after the save. Anything else is ambiguous and carries nothing: a webhook added at an existing URL, or a sibling there without headers, never takes another's credential, and a webhook whose URL changed does not take the old endpoint's with it.

type WebhookFormat added in v0.3.0

type WebhookFormat string

WebhookFormat defines the target service serialization schema.

const (
	FormatGeneric WebhookFormat = "generic"
	FormatSlack   WebhookFormat = "slack"
	FormatDiscord WebhookFormat = "discord"
)

Jump to

Keyboard shortcuts

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