#!/bin/sh # falcode agent-completion notifier. # # Spawned by the falcode pi extension (falcode.ts -> fireNotification) when an # agent's turn finishes (working -> waiting_user_input) with: # --agent --pane-name --status idle # --session --pane-id # # Sends a desktop popup (notify-send) and an ntfy push so Sam knows the agent # finished. Must never exit non-zero in a way that could disturb the caller. agent="" pane_name="" status="" session="" pane_id="" while [ $# -gt 0 ]; do case "$1" in --agent) agent="$2"; shift 2 ;; --pane-name) pane_name="$2"; shift 2 ;; --status) status="$2"; shift 2 ;; --session) session="$2"; shift 2 ;; --pane-id) pane_id="$2"; shift 2 ;; *) shift ;; esac done # Only notify on agent-finish transitions. [ "$status" = "idle" ] || exit 0 [ -z "$pane_name" ] && pane_name="$agent" [ -z "$pane_name" ] && pane_name="pi" title="✓ $pane_name finished" body="$agent agent done" [ -n "$session" ] && body="$body · $session" # 1) Desktop popup if command -v notify-send >/dev/null 2>&1; then notify-send -a "Pi" "$title" "$body" >/dev/null 2>&1 || true fi # 2) ntfy push (phone/desktop clients). PI_NTFY_TOPIC comes from # ~/.config/environment.d/10-secrets.conf; fall back to the lab topic. topic="${PI_NTFY_TOPIC:-http://192.168.20.35:8099/PI_NTFY_TOPIC}" if command -v curl >/dev/null 2>&1; then curl -s -o /dev/null \ -H "Title: $title" \ -H "Tags: white_check_mark" \ -d "$body" \ "$topic" >/dev/null 2>&1 || true fi exit 0