omp packages

pi-notify-smart1.3.0

pi-notify-smart: replyable email/SMS notifications for Pi with per-level routing, append threads, guided slash setup, and a per-session timeline (map view) for version/flow management.

dobriclilujun Published 3 hours ago MIT ~305 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-notify-smart — replyable notifications for Pi, with two-way email

Your Pi agent judges, at the end of a turn, whether a human is actually needed. If yes you get a readable email card containing the agent's raw output; you answer it — by email, or on a web page — and the answer is injected back into the session that asked. Answer a second time and you are appending a requirement to the same task, not starting a new one.

Pi turn ends ──▶ Pi's own model judges "human needed?" ──▶ email card (raw output + #pn:<id>)
        ▲                                                        │
        │ human reply injected as a new turn                     ▼
        └── IMAP poll (60 s) ◀── you hit Reply and type one sentence

a decision card

Three steps to the first card

pi install npm:pi-notify-smart        # or: pi install git:github.com/DobricLilujun/pi-notify-smart
pi-notify-smart serve &               # reply pages + settings + timeline + IMAP poll (docs/pi-notify-smart.service.example for systemd)

then, in any Pi or pi-web session:

/pi-notify-smart setup        # 3 questions: which mailbox sends · its SMTP/IMAP app password · who receives
/pi-notify-smart test         # a real card lands in your inbox

Reply to that email. The next thing your agent says starts with [pi-notify-smart] Human reply received …. Reply again and it says [pi-notify-smart APPEND #2 on card …] … extend, do not restart the task from scratch.

Everything about mailboxes, app passwords and where secrets live: docs/SETUP-GUIDE.md (3 minutes). Nothing else is required to start.

a card answered twice, i.e. a thread

What is in the box

piece role
cli.mjs (bin pi-notify-smart) one driver for everything: notify, pending, replies, thread, prefs, auto, remind, timeline, serve
server.mjs the MCP server: psmart_notify, psmart_ask, psmart_pending, psmart_get_reply, psmart_check_email, psmart_judge_only, psmart_channel_test
extensions/pi-notify-auto.mjs the /pi-notify-smart command, the end-of-turn auto notification, reply injection
extensions/pi-notify-timeline.mjs records each turn live, marks forks, feeds the timeline
web (same port 8790) /q/<id> card + thread · /settings levels, senders, accounts · /timeline the map of your sessions

The same settings, three doors

Routing (who is notified), the sender and the mailboxes have one store. Read or change them from whichever is convenient — they always agree:

  1. slash — /pi-notify-smart setup, status, set-sender, auto, test (works in pi-web too);
  2. settings page — http://<lan>:8790/settings: three levels, senders, accounts, live sessions;
  3. CLI / MCP env — pi-notify-smart prefs …, or the PI_NOTIFY_* environment of a pi-web Settings → MCP row (strict opt-in: PI_NOTIFY_DEFAULT_TO alone is only a suggestion, PI_NOTIFY_LEVEL=project|global is what enables a rule).

levels, senders and accounts on the settings page

Routing levels

session > project > global, most specific wins. No rule anywhere = nobody is notified (and no LLM call is spent). stop mutes a level explicitly instead of falling through.

/pi-notify-smart me@gmail.com             this session
/pi-notify-smart project me@gmail.com     this project
/pi-notify-smart global  me@gmail.com     everything else
/pi-notify-smart stop | unset             mute this session · remove its rule

Intensity is orthogonal (per level, same precedence): auto light (turns ≥ 3 min) · medium (≥ 90 s and ≥ 3 tool calls) · heavy (every completed turn) · off (never automatic, /pi-notify-smart test still works).

Sender rule (anti-spoofing): a level may use any sender, but only through an account whose authenticated smtp.user is that address. There is no silent fallback to another account's password.

Secrets: file: refs to 0600 files under secrets/, or env:VAR. Passwords never enter config.json, never argv (the CLI takes them on stdin), never logs, never the UI.

Frozen routing: a question remembers the routing that created it, so widening a project rule later does not let a new address answer an older card.

A card is a thread

  • reply #1 answers the question;
  • replies #2, #3, … append requirements to the same task (max 20, then the card closes);
  • the thread lives 2 h (web.ttlMinutes), refreshed by every reply;
  • close it with the Close button, by replying #close / #stop / #end, or pi-notify-smart thread close;
  • an unanswered card is reminded every 30 min (max 5 emails) — every reminder carries the close control, and an answered thread is never treated as unanswered.
pi-notify-smart thread list | thread show <qid> | thread close [--session <sid>] [--project <p>]

Timeline: the story of your sessions

/timeline (same service, same port) indexes every Pi session: one card per user turn — what you asked, what the agent did, tools, files, duration, tokens, branch lanes — plus the notification cards attached to the turn that produced them. Summaries are written by Pi's own model and cached forever by content hash; retention is permanent by default.

pi-notify-smart timeline status
pi-notify-smart timeline index [--summarize]      # backfill (kill switch: PI_NOTIFY_TL_LLM=0)
pi-notify-smart timeline show <sessionId>

the timeline map a session timeline with its cards

MCP tools

Register the server once in ~/.pi/agent/mcp.json (exposure direct):

{ "mcpServers": { "pi-notify-smart": { "command": "pi-notify-smart", "args": ["mcp"], "exposure": "direct" } } }
tool what it does
psmart_notify end of task: judgement + card (+ reply link)
psmart_ask blocking question, one-click reply + free text (waitSeconds ≤ 120)
psmart_pending open questions and unread replies
psmart_get_reply fetch an answer (can wait for it)
psmart_check_email run the IMAP poll now
psmart_judge_only judge, send nothing
psmart_channel_test test email/SMS delivery

Pi package

pi.extensions declares both extensions, so pi install loads them from the package:

pi install npm:pi-notify-smart
pi install git:github.com/DobricLilujun/pi-notify-smart
pi list · pi remove npm:pi-notify-smart · pi -e npm:pi-notify-smart   # one invocation only

/notify still works as a deprecated alias for one release (PI_NOTIFY_ALIAS=0 removes it).

Testing

npm test                       # 8 suites, 210 assertions, all in sandboxes (~40 s)
node docker/e2e/run.mjs        # Docker laboratory: real SMTP+IMAP, isolated Pi + pi-web, 30 checks

The laboratory also drives pi-web through a browser (10 more checks). Full recipe, the requirement → check map, and the bugs it caught: docs/TESTING.md.

Publishing guard: npm run audit:publish (runs on prepack) refuses any tarball containing config.json, secrets/, inbox*.json, state.json, logs, or real-secret / personal-data signatures. The screenshots above are rendered from synthetic data for exactly that reason.

Ad-hoc checks without Pi:

pi-notify-smart judge  '{"project":"x","task_goal":"…","result":"…"}'
pi-notify-smart notify '{"project":"x","task_goal":"…","result":"…","force":true}'
pi-notify-smart prefs status --project x

Decision threshold

Pi's own model answers needs_human + a card kind (decision / done / failed / …) + urgency. A notification is only sent when: a routing level has receivers, the intensity tier for that level allows it, and the judge says a human is required. force: true (or /pi-notify-smart test) bypasses the threshold — never the routing.

License

MIT