Something went wrong. Try again.
Notifications for pi.dev
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253/** * pi-notify — Simplified native notification extension for Pi. * * Sends desktop notifications on hooks you care about: * - agent_end → agent finished responding * - permissions:prompt → permission system needs your input * * Config: ~/.pi/agent/extensions/notify/config.json */
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";import { loadConfig } from "./config.js";import { sendNative } from "./notify.js";
export default function (pi: ExtensionAPI) { const config = loadConfig();
if (!config.native.enabled) return;
// ── agent_end ─────────────────────────────────────────────────────────── const agentEndCfg = config.hooks.agent_end; if (agentEndCfg?.enabled) { pi.on("agent_end", async () => { const title = agentEndCfg.title ?? "Pi — Agent Complete"; const message = agentEndCfg.message ?? (pi.getSessionName() ? `${pi.getSessionName()} — Agent is done` : "Agent is done responding");
sendNative(title, message, config).catch(() => {}); }); }
// ── permissions:prompt ────────────────────────────────────────────────── const permCfg = config.hooks["permissions:prompt"]; if (permCfg?.enabled) { pi.events.on("permissions:prompt", (payload: unknown) => { const p = payload as { message?: string; surface?: string; value?: string; };
const title = permCfg.title ?? "Pi — Permission Required"; const message = permCfg.message ?? p.message ?? `${p.surface}: ${p.value ?? "unknown"}`;
sendNative(title, message, config).catch(() => {}); }); }}