Skip to main content

Module notifications

Module notifications 

Source
Expand description

Best-effort per-turn completion notifier.

Fires after each agent turn completes via two independent channels:

  • macOS nativeosascript banner via stdin (no argument-injection risk)
  • ntfy webhook — JSON POST to an ntfy-compatible endpoint

All notifications are fire-and-forget: failures are logged at warn level and never propagated to the caller. Secrets are redacted before any payload leaves the process.

§Gating

Notifier::should_fire applies all gate conditions in order:

  1. Master enabled switch must be true
  2. llm_requests == 0 → skip (slash commands, cache-only, security-blocked turns)
  3. only_on_error && !is_error → skip
  4. Duration gate (min_turn_duration_ms) applies only to successful turns; error turns always fire regardless of duration

§Examples

use zeph_core::notifications::{Notifier, TurnSummary, TurnExitStatus};
use zeph_config::NotificationsConfig;

let cfg = NotificationsConfig {
    enabled: true,
    macos_native: true,
    ..Default::default()
};
let notifier = Notifier::new(cfg);
let summary = TurnSummary {
    duration_ms: 5000,
    preview: "Done. Files updated.".to_owned(),
    tool_calls: 2,
    llm_requests: 1,
    exit_status: TurnExitStatus::Success,
};
// Fire and forget — errors are logged, never propagated.
notifier.fire(&summary);

Structs§

Notifier
Per-turn completion notifier.
TurnSummary
Lightweight summary of a completed agent turn used as notification input.

Enums§

NotifyTestError
Error returned by Notifier::fire_test.
TurnExitStatus
Whether a turn completed successfully or with an error.

Functions§

sanitize_applescript_payload
Sanitize a string for safe inclusion inside an AppleScript "..." literal.