Install
Install with PiG
pig install npm:@fenlyin/pi-notifyInstall with Pi
pi install npm:@fenlyin/pi-notifyPackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./src/index.ts"
]
}README
Written by the package's publisher, shown as published in version 0.3.0 (README.md). PiG does not review it.
@fenlyin/pi-notify
Pi package that plays a configurable sound when pi waits for you: a dialog opens, or a run finishes and the agent is waiting for your next prompt. It can also put a 🔔 in front of the terminal tab title, so the tab you left alone says what happened.
A dialog you just opened yourself — /mcp, /ask:replay, a keybinding — stays silent: the keypress
that ran the command proves you are at the terminal, so only a dialog pi raises while you are away
rings.
Install
pi install npm:@fenlyin/pi-notify
Or try it for one session: pi -e npm:@fenlyin/pi-notify.
What triggers a sound
| Event | pi event | When |
|---|---|---|
dialog | ui_prompt_start | A blocking extension dialog opens: ask_user, permission confirmations, project-trust prompts, extension select/confirm/input/editor/custom screens |
idle | agent_settled | A run has fully settled (no automatic retry, compaction, or queued continuation left) and pi is waiting for input |
Aborted runs (Esc) and every non-TUI mode are silent: outside the TUI stdout carries pi's JSON or
RPC stream, and an escape sequence there would corrupt it. pi's own slash-command pickers (/model,
/sessions, /settings) are not extension dialogs and emit no event, so they do not ring.
Extension commands that open their own screen (/mcp and friends) do emit ui_prompt_start, with
the same custom kind ask_user uses, so the event cannot say who opened the prompt. The keypress
can: a dialog that appears within typedWithinMs of the last keystroke belongs to someone who is at
the terminal and is not worth a sound. That is what keeps /mcp quiet while a tool's ask_user —
which only shows up while the agent runs, long after you pressed Enter — still rings.
Configure
Config path: ~/.pi/agent/extensions/fenlyin-pi-notify.json. The file is optional; without it the
platform default plays the bundled chime. Edits take effect on /reload or the next session.
{
"schemaVersion": 1,
"enabled": true,
"channels": [
"title",
{ "type": "command", "command": "powershell -NoProfile -c \"(New-Object Media.SoundPlayer 'C:\\snd\\ding.wav').PlaySync()\"" }
],
"events": {
"dialog": { "enabled": true, "typedWithinMs": 3000 },
"idle": { "enabled": true, "channels": ["bell"] }
}
}
enabled— master switch.channels— what every event plays unless it overrides them.events.<name>.enabled— per-event switch.events.<name>.channels— per-event override;dialogandidlecan sound different.events.<name>.typedWithinMs— stay silent when a key was pressed less than this many milliseconds ago, so a dialog you opened yourself does not ring.0turns the check off. Defaults to3000fordialogand is off foridle.- Invalid entries are dropped rather than failing pi; if no channel survives, the platform default is used.
Channels
| Channel | Effect |
|---|---|
"bell" | Writes BEL. The terminal or OS decides the sound. |
"osc9" | OSC 9 notification: message only. |
"osc777" | OSC 777 notification: title and message. |
"title" | Prefixes the terminal tab title with 🔔 while pi waits. Silent, and cleared as soon as you are back: the tab reports focus again, you type anything, the dialog closes, or a new session starts. |
{ "type": "command", "command": "..." } | Runs the command detached, via the shell. |
title is in the platform defaults, so a stock install already marks its tab. Setting channels
yourself replaces the defaults, so list "title" there as well if you want to keep it.
Command channels get the notification text in the environment, so no quoting is needed:
NOTIFY_EVENT=ui.prompt.waiting # or agent.settled
NOTIFY_TITLE="pi"
NOTIFY_MESSAGE="Waiting for input: Allow write?"
Custom sounds
Windows — a WAV through the system player, or a plain tone without a file:
{ "type": "command", "command": "powershell -NoProfile -c \"(New-Object Media.SoundPlayer 'D:\\snd\\ding.wav').PlaySync()\"" }
{ "type": "command", "command": "powershell -NoProfile -c \"[console]::beep(880,120)\"" }
{ "type": "command", "command": "powershell -NoProfile -c \"[System.Media.SystemSounds]::Asterisk.Play()\"" }
macOS and Linux:
{ "type": "command", "command": "afplay /System/Library/Sounds/Glass.aiff" }
{ "type": "command", "command": "paplay /usr/share/sounds/freedesktop/stereo/bell.oga" }
The bundled chime is assets/notify.wav inside the installed package; the platform default command
plays it with powershell on Windows, afplay on macOS, and BEL everywhere else.
Notes
- Sounds are best effort: a missing player, a closed stdout, or a broken config never interrupts pi.
commandchannels are detached, so a slow player does not delay the dialog.titlereplaces the whole tab title through OSC 0 with pi's own format (π - session - directory), which is why it is put back rather than appended to: a title cannot be read back.titleknows you are back from the terminal's focus report (DECSET 1004), which pi enables together with mouse tracking. pi's TUI consumes those sequences before extensions see them, so this package watches stdin directly, read-only, and only while a mark is showing. A terminal without focus reports still clears on the first keypress.- The typing window comes from
ctx.ui.onTerminalInput, the same keypresses that clear the mark. Mouse movement and focus reports are filtered out: with mouse tracking on, a mouse crossing the window would otherwise look like someone at the keyboard. - If pi-ask (or another extension) rings on its own, turn its notification off to avoid a double
sound; this package covers
ask_userthroughui_prompt_start.
Development
npm install
npm test # node --test over tests/*.test.ts
npm run typecheck
npm run generate-sound # rebuild assets/notify.wav
License
MIT