feat: add email triage wakeAgent gate — full poller pattern with silent delivery
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user