Documentation
¶
Overview ¶
Package sinks fans notifications out to web-push, a Discord webhook and ntfy, best-effort and never blocking the caller.
ntfy approval notifications carry real approve/deny HTTP action buttons, so a phone can decide without opening the app (and without VAPID setup).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Keys = []string{
"discord_webhook", "ntfy_server", "ntfy_topic", "summary_agent", "summary_model",
"alert_waiting_permission", "alert_waiting_input", "alert_idle", "alert_error", "alert_compacting",
"session_permission_mode",
"judge_agent", "judge_model", "eval_concurrency",
"awareness_briefing", "awareness_edit_warning",
"claims_briefing", "claims_edit_warning", "claims_auto_paths",
"claude_terminal_mouse",
}
Keys are the settings rows this package owns. Anything else is rejected by the settings endpoint so a typo cannot silently disable notifications.
The alert_* keys and session_permission_mode belong conceptually to internal/alerts and internal/sessions respectively (docs/agent-events.md section 3), but PUT/GET /api/settings only validates against this one list (internal/api/misc.go), so they are appended here rather than standing up a second settings registry for two features. Values are "0"/"1" strings for the toggles (missing or anything but "0" means ON — see internal/alerts.Enabled) and "bypass"/"ask" for the permission mode default (missing or anything but "ask" means "bypass").
Functions ¶
func ApprovalTag ¶ added in v2.6.0
ApprovalTag is the tag every device groups an approval's notification under (sw-actions.ts groupTag, the Android app's Notifications.tagOf).
func Subscribe ¶
func Subscribe(db *store.DB, sub push.Subscription) error
Subscribe records (or refreshes) a browser push subscription.
func Unsubscribe ¶ added in v2.4.0
Unsubscribe removes one browser's push subscription by endpoint — the same identity a 404/410 delivery failure prunes automatically (sendPush above). It never errors on an endpoint that is already gone: asking to unsubscribe a device that was never (or is no longer) subscribed is not a failure.
Types ¶
type Extra ¶
type Extra struct {
Kind string
ApprovalID int64
// SessionID, when set, is included in the web-push payload as
// session_id so the service worker (and anything else reading a push
// message) can act on the session directly rather than parsing it back
// out of the deep-link URL.
SessionID int64
// LimitID, when set, is the usage-limit hold (internal/limits) the push
// is about; the service worker's one-tap choices post to it.
LimitID int64
}
Extra carries the notification's context — which is what turns an ntfy message into one with decision buttons, and what a web-push payload's kind/session_id fields (docs/agent-events.md section 3) come from.
type Notifier ¶
type Notifier struct {
DB *store.DB
BaseURL string
Push *push.Sender
Log *slog.Logger
Client *http.Client
// Hook, when set, replaces real delivery. Tests assert on the built payloads
// without any network at all — the same seam the Python suite used.
Hook func([]Payload)
// PushHook, when set, receives each web-push message instead of the push
// service, whether or not VAPID keys are configured. Tests only.
PushHook func(raw []byte)
// contains filtered or unexported fields
}
Notifier owns the sink fan-out.
func (*Notifier) Dismiss ¶ added in v2.6.0
Dismiss tells every subscribed device that a notification no longer needs anyone, so an approval decided on one phone leaves the others' trays. Web push only: an ntfy or Discord message cannot be withdrawn.
func (*Notifier) Notify ¶
Notify sends to every configured sink. Delivery happens on a goroutine: a sink outage must never slow a dispatch down, let alone fail one.
type Payload ¶
type Payload struct {
Kind string `json:"kind"`
URL string `json:"url"`
Body map[string]any `json:"body"`
}
Payload is one outbound notification, already addressed and rendered.
type SubscriptionInfo ¶ added in v2.4.0
type SubscriptionInfo struct {
ID int64 `json:"id"`
Endpoint string `json:"endpoint"`
CreatedAt float64 `json:"created_at"`
}
SubscriptionInfo is one subscribed device, as listed for the settings UI. The endpoint is included so the UI can point out "this device" (it matches the endpoint the browser's own pushManager.getSubscription() returns) — it is not secret, unlike the p256dh/auth keys, which this never exposes.
func Subscriptions ¶ added in v2.4.0
func Subscriptions(db *store.DB) ([]SubscriptionInfo, error)
Subscriptions lists every subscribed device, newest first.