notify

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package notify sends notifications to Microsoft Teams via incoming webhooks.

Notifications are formatted as Adaptive Cards (schema v1.4) for rich display in Teams channels. Each event type has a dedicated card template.

Disabled by default — configure notifications.teams_webhook_url in forge.yaml.

Index

Constants

View Source
const (
	// AdaptiveCardSchema is the schema URL for adaptive cards.
	AdaptiveCardSchema = "http://adaptivecards.io/schemas/adaptive-card.json"

	// CardVersion is the adaptive card version.
	CardVersion = "1.4"
)

Variables

This section is empty.

Functions

func FormatWebhookURL

func FormatWebhookURL(url string) (string, error)

FormatWebhookURL validates and normalises a Teams webhook URL.

Types

type Config

type Config struct {
	WebhookURL string
	Enabled    bool
	Events     []string // Filter to these events only; empty = all
}

Config holds notifier settings.

type EventType

type EventType string

EventType identifies a notification event.

const (
	EventPRCreated      EventType = "pr_created"
	EventBeadFailed     EventType = "bead_failed"
	EventDailyCost      EventType = "daily_cost"
	EventWorkerDone     EventType = "worker_done"
	EventBeadDecomposed EventType = "bead_decomposed"
)

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier sends notifications to Teams.

func NewNotifier

func NewNotifier(cfg Config, logger *slog.Logger) *Notifier

NewNotifier creates a Teams notifier. Returns nil if disabled or no URL.

func (*Notifier) BeadDecomposed

func (n *Notifier) BeadDecomposed(ctx context.Context, anvil, beadID, beadTitle string, subBeads []SubBead)

BeadDecomposed sends a notification when Schematic decomposes a bead into sub-beads. This is significant because it changes the work queue.

func (*Notifier) BeadFailed

func (n *Notifier) BeadFailed(ctx context.Context, anvil, beadID string, retries int, lastError string)

BeadFailed sends a notification when a bead fails after retries.

func (*Notifier) DailyCost

func (n *Notifier) DailyCost(ctx context.Context, date string, totalCost float64, limit float64, inputTokens, outputTokens int64)

DailyCost sends a daily cost summary.

func (*Notifier) PRCreated

func (n *Notifier) PRCreated(ctx context.Context, anvil, beadID string, prNumber int, prURL, title string)

PRCreated sends a notification when a PR is created.

func (*Notifier) ShouldNotify

func (n *Notifier) ShouldNotify(event EventType) bool

ShouldNotify checks if an event type should trigger a notification.

func (*Notifier) WorkerDone

func (n *Notifier) WorkerDone(ctx context.Context, anvil, beadID, workerID string, duration time.Duration)

WorkerDone sends a notification when a worker successfully completes.

type SubBead

type SubBead struct {
	ID    string
	Title string
}

SubBead holds the ID and title of a sub-bead for decomposition notifications.

Jump to

Keyboard shortcuts

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