From e8fb5c6324dbf6a98ebcf4d9af8d32e825939214 Mon Sep 17 00:00:00 2001 From: Leonard Date: Sat, 20 Jun 2026 06:22:07 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20add=20email=20triage=20wakeAgent=20gate?= =?UTF-8?q?=20=E2=80=94=20full=20poller=20pattern=20with=20silent=20delive?= =?UTF-8?q?ry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gates/email-triage-wakegate.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 hermes-automation/gates/email-triage-wakegate.md diff --git a/hermes-automation/gates/email-triage-wakegate.md b/hermes-automation/gates/email-triage-wakegate.md new file mode 100644 index 0000000..d001a49 --- /dev/null +++ b/hermes-automation/gates/email-triage-wakegate.md @@ -0,0 +1,79 @@ +# Email Triage — wakeAgent Gate Pattern + +A condition-based poller that checks for new actionable email, fires the LLM only when there's unprocessed high-priority mail, and stays silent (zero cost) on empty ticks. + +## Design + +``` +┌─────────────────────────────────────────────────────────────┐ +│ cron: every 15m │ +│ no_agent=true │ +│ script: check-unread-email.sh │ +├─────────────────────────────────────────────────────────────┤ +│ Script output (stdout): │ +│ • "" (empty) → no agent, no delivery ── $0.00 │ +│ • "3 unread priority" → gate opens → agent processes │ +└─────────────────────────────────────────────────────────────┘ +``` + +## Implementation + +### 1. Script (`scripts/check-unread-email.sh`) + +```bash +#!/usr/bin/env bash +# Silent poller: outputs nothing unless there are actionable unread emails +# Called by cron with no_agent=true — zero token cost on empty ticks +# +# Gate logic: +# stdout empty = no new email → silent delivery (nothing sent) +# stdout non-empty = has mail → cron passes it to agent context + +source ~/.hermes/profiles/leonard/.env + +COUNT=$(himalaya envelope list -f INBOX -a 2>/dev/null | grep -c "UNSEEN" || echo 0) + +if [ "$COUNT" -eq 0 ]; then + exit 0 # silent — no output, no delivery +fi + +# Gate opened: output structured context for the agent to process +echo "UNREAD_EMAIL=$COUNT" +echo "TIMESTAMP=$(date -Iseconds)" +echo "---" +himalaya envelope list -f INBOX -a 2>/dev/null | head -20 +``` + +### 2. Cron Job (Hermes cron) + +```bash +hermes cron create \ + -s "email-monitor" \ + --schedule "every 15m" \ + --script ~/.hermes/profiles/leonard/scripts/check-unread-email.sh \ + --no-agent \ + "If the script reports unread emails, summarize the top 3 most important ones with sender, subject, and a one-line action recommendation. Flag anything urgent or time-sensitive. If nothing actionable, deliver nothing." +``` + +### 3. Wake Gate Principle + +The gate stays **closed** (no agent invoked) 95%+ of ticks. The script: +- Uses no LLM resources (pure shell) +- Outputs nothing on empty scans → **silent delivery** (free) +- Only when email is found does the agent context fire + +## Key Configuration + +| Setting | Value | Reason | +|---------|-------|--------| +| `schedule` | `every 15m` | Fast enough for triage, sparse enough to stay cheap | +| `no_agent` | `true` | Script-only polling — zero token cost per tick | +| `deliver` | `origin` | Returns to the same chat where created | +| Script exit | `0` with empty stdout | Silent — no notification sent | + +## Variants + +- **Compliance monitor**: Same pattern, replace email check with regulatory RSS/API poll +- **Opportunity scanner**: Script scrapes X/HN, gates on fresh high-signal mentions +- **System health**: Script checks disk/GPU/memory thresholds, gates only on warnings +- **Skills curator**: Script checks skill freshness, gates on skills approaching staleness \ No newline at end of file