omp packages

pi-lot-pack-notifier0.1.1

A desktop notification, a sound, the terminal bell or a command of yours when Pi finishes, fails or asks.

zephinel Published 2 days ago Apache-2.0 ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-notifier

Sends a desktop notification (Ghostty OSC 777, terminal-notifier, osascript), plays a sound, rings the terminal bell or runs a command of yours when Pi finishes, a subagent ends, an error stops Pi, Pi asks you something, or a permission question opens.

Events · Commands · Settings · Every setting · Debugging

pi-notifier is a separate extension of Pi-lot Pack and takes no part in permission decisions. Turning notifications off, or a failure to send one, changes no question, allow or refusal of the permission extension (extensions/permissions/).

Install

pi install npm:pi-lot-pack-notifier

Or every extension of Pi-lot Pack at once with pi install npm:pi-lot-pack. Install one or the other: with both, this extension loads twice.

Events and permission questions

Event When Default title Default message
complete Pi finished and waits for input Done{promptSuffix} {toolSummary}{modelSuffix}{timestampSuffix}
subagent_complete A subagent finished Subagent done{promptSuffix} {toolSummary}{modelSuffix}{timestampSuffix}
error An error stopped Pi Pi error{promptSuffix} {error}{modelSuffix}{timestampSuffix}
permission A permission question is about to open for the user Pi permission{toolNameSuffix} {toolSummary}{scopeSuffix}{timestampSuffix}
question Pi asks the user with ask_user_question Question{promptSuffix} {toolSummary}{modelSuffix}{timestampSuffix}

Permission notifications follow events by default (permissionRequestSource: "event"):

  1. The permission extension emits workflow-permission:prompt before it really opens a question the user sees.
  2. pi-notifier then sends the notification, by the focus rule, the shortest duration and the switches of the event.
  3. After the user or Approve for me decides, the permission extension emits workflow-permission:decision.

For older event sources it also listens to permissions:ui_prompt and permissions:decision. When a workflow-permission:* event and a legacy one have the same toolCallId / requestId, the first to arrive counts and the later one is dropped. What was seen is kept to the end of the Pi session (cleared at session_start / session_shutdown), with no fixed limit, so a session with many requests is not notified twice.

Commands and the settings page

The /pi-notifier settings page

  • /pi-notifier (with a UI): opens the settings page in the terminal (loaded only then). The first row, All notifications, switches everything; below it, Sound, Desktop notification and Terminal bell can be switched for each of the 5 events, and Sound to play chooses one of the 28 sounds that come with the notifier, each played as you choose it. Space or Enter saves at once and keeps the other fields; a channel that cannot be used shows not available and why.
  • /pi-notifier (without a UI) or /pi-notifier status: says whether notifications are on ("Notifications are enabled." / "Notifications are disabled.").
  • /pi-notifier enable (alias on), /pi-notifier disable (alias off), /pi-notifier toggle: change enabled at the top of the settings file, and nothing about single events and channels.

Settings file

The file (it may be a symbolic link, into a folder you sync for example; a save follows the link and updates its target):

~/.pi/agent/pi-lot-pack/pi-notifier.json

A usual file for Ghostty:

{
  "enabled": true,
  "sound": true,
  "notification": true,
  "bell": false,
  "notificationSystem": "ghostty",
  "suppressWhenFocused": true,
  "minDuration": 0,
  "permissionRequestSource": "event",
  "titles": {
    "complete": "Done{promptSuffix}",
    "subagent_complete": "Subagent done{promptSuffix}",
    "permission": "Pi permission{toolNameSuffix}",
    "question": "Question{promptSuffix}",
    "error": "Pi error{promptSuffix}"
  },
  "events": {
    "permission": { "playWhenFocused": true },
    "question": { "playWhenFocused": true }
  }
}

Every setting, the template variables of titles and messages, sounds and the command hook: settings.

Files

extensions/pi-notifier/
├── index.ts                 # entry: the /pi-notifier command and the event listeners
├── pages.ts                 # the /pi-notifier settings page
├── copy.ts                  # words of the page, default titles and fallback texts
├── command-surface.ts       # subcommand completion and usage
├── notifier-config.ts       # reads, checks and saves the settings; rotates the debug log
├── notifier-types.ts        # types of events, channels and settings
├── sounds.ts                # the names of the sounds, by event, and each event's default
├── notifier-utils.ts        # helpers, such as the local ISO time
├── template-config.ts       # template variables of titles and messages
├── event-adapters.ts        # workflow and legacy permission events, tool_call
├── permission-handler.ts    # permission decisions, the prediction fallback
├── dispatch-dedupe.ts       # no notification twice, across sources and in a session
├── dispatch.ts              # focus rule, shortest duration, channels
├── delivery-adapters.ts     # Ghostty OSC 777, terminal-notifier, osascript, sound, bell, command
├── package.json
├── README.md
├── test/                    # unit tests and walks of the settings page
├── images/                  # the picture on this page, drawn by scripts/readme-images.mjs
└── sounds/                  # the 28 sounds, made by scripts/notifier-sounds.mjs

Debug log and troubleshooting

With "debug": true, the log goes only to ~/.pi/agent/pi-lot-pack/pi-notifier.debug.log (at 5 MB it becomes .old-<timestamp>-<pid>; about 15 MB of old logs are kept in all):

tail -n 120 ~/.pi/agent/pi-lot-pack/pi-notifier.debug.log

Common cases:

  • The notification comes from macOS Script Editor: with "auto" or "osascript", macOS uses AppleScript. In Ghostty, set "notificationSystem": "ghostty".
  • A notification, but no permission question: look whether permissionRequestSource is "prediction". With "event", it notifies only before a real question.
  • A permission question, but no notification: look whether /pi-notifier status says enabled, and search the debug log for workflow-permission:prompt, skipped by duplicate prompt, skipped by focus suppression or skipped by minDuration.

Credits

pi-notifier started from opencode-notifier by Mohak S (MIT); its licence is in THIRD_PARTY_NOTICES.md. The sounds are not from there: they are made in this repository by scripts/notifier-sounds.mjs.

Development checks

From the repository root (with the Node.js of .node-version):

npm run bootstrap
npm --prefix extensions/pi-notifier test
npm --prefix extensions/pi-notifier run check
npm run check