notify

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package notify sends best-effort desktop/terminal notifications to external tools. Currently it integrates with cmux (manaflow-ai/cmux), a macOS terminal app that surfaces notifications for AI coding agents, mirroring how Claude Code's hooks forward alerts into cmux.

Index

Constants

View Source
const (
	FormatNtfy    = "ntfy"
	FormatSlack   = "slack"
	FormatDiscord = "discord"
)

Webhook formats.

Variables

This section is empty.

Functions

func CMuxAvailable

func CMuxAvailable() bool

CMuxAvailable reports whether a cmux instance is reachable. cmux is macOS-only, so this is always false on other platforms.

func Host added in v0.7.0

func Host(raw string) string

Host returns only the host of a webhook URL, for messages: the rest of the URL may hold a secret token. "" when the URL is empty, "invalid URL" when it cannot be used.

func Send added in v0.7.0

func Send(cfg config.NotifyConfig, n Note)

Send delivers n through the default sender. It never blocks on the network and never fails: every channel is best-effort. It does nothing under "go test", so tests never ring the bell of the developer's terminal.

func SendCMux

func SendCMux(title, subtitle, body string)

SendCMux fires a cmux notification via the `cmux notify` CLI. It is best-effort and silently no-ops when cmux is not running or the CLI is missing. subtitle may be empty.

func Wait added in v0.7.0

func Wait(d time.Duration)

Wait blocks until the default sender has finished its pending deliveries or d has passed. Call it before the process exits so the last note is not lost.

Types

type Deps added in v0.7.0

type Deps struct {
	CMux     func(title, subtitle, body string)
	Exec     func(ctx context.Context, name string, args ...string) error
	LookPath func(name string) (string, error)
	HTTP     Doer
	OpenTTY  func() (io.WriteCloser, error)
	GOOS     string
	Getenv   func(key string) string
	Now      func() time.Time
	Go       func(func()) // runs one channel; tests pass a synchronous runner
}

Deps are the side effects of a Sender. Zero fields get real implementations.

type Doer added in v0.7.0

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

Doer is the part of http.Client the webhook needs.

type Level added in v0.7.0

type Level int

Level says how much a note needs the user. It picks the ntfy priority and tags and the desktop urgency.

const (
	Info     Level = iota
	NeedsYou       // something is blocked until the user answers
	Failed         // something went wrong
	Done           // a piece of work finished
)

type Note added in v0.7.0

type Note struct {
	Title string
	Body  string
	Level Level
}

Note is one notification.

type Sender added in v0.7.0

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

Sender delivers notes to the enabled channels.

func NewSender added in v0.7.0

func NewSender(d Deps) *Sender

NewSender fills the missing deps with the real ones.

func (*Sender) Send added in v0.7.0

func (s *Sender) Send(cfg config.NotifyConfig, n Note)

Send delivers n to every enabled channel.

func (*Sender) Wait added in v0.7.0

func (s *Sender) Wait(d time.Duration)

Wait blocks until pending deliveries are done or d has passed.

Jump to

Keyboard shortcuts

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