contacts: extract into standalone skill, add himalaya wrapper for all email sends

Refactors the contacts system from being embedded in cal_tool.py into a
standalone contacts skill that serves as the single source of truth for
recipient validation across all outbound email paths.

- New skills/contacts/ skill: list, add, delete, resolve commands
- New skills/himalaya/scripts/himalaya.sh wrapper: validates To/Cc/Bcc
  recipients against contacts for message send, template send, and
  message write commands; passes everything else through unchanged
- cal_tool.py now delegates to contacts.py resolve instead of inline logic
- TOOLS.md updated: agent should use himalaya wrapper, not raw himalaya
This commit is contained in:
Yanxin Lu
2026-03-31 11:12:08 -07:00
parent cd1ee050ed
commit f05a84d8ca
10 changed files with 703 additions and 314 deletions

View File

@@ -9,6 +9,30 @@ metadata: {"clawdbot":{"emoji":"📧","requires":{"bins":["himalaya"]},"install"
Himalaya is a CLI email client that lets you manage emails from the terminal using IMAP, SMTP, Notmuch, or Sendmail backends.
## Recipient-Safe Wrapper
Use the wrapper script (`scripts/himalaya.sh`) instead of calling `himalaya` directly. It validates outbound email recipients against the contacts list (see `skills/contacts/`) before sending.
**Gated commands** (recipients validated before sending):
- `message send` — parses To/Cc/Bcc from MIME headers on stdin
- `template send` — parses To/Cc/Bcc from MML headers on stdin
- `message write` — parses `-H` header flags for To/Cc/Bcc
**Pass-through commands** (no validation needed):
- Everything else: `envelope list`, `message read`, `message delete`, `folder`, `flag`, `attachment`, `account`, etc.
```bash
HIMALAYA=~/.openclaw/workspace/skills/himalaya/scripts/himalaya.sh
# All commands work the same as `himalaya`
$HIMALAYA envelope list
$HIMALAYA message read 42
# Sending commands validate recipients first
cat message.txt | $HIMALAYA template send # validates To/Cc/Bcc
$HIMALAYA message write -H "To:小橘子:work" -H "Subject:Test" "body"
```
## References
- `references/configuration.md` (config file setup + IMAP/SMTP authentication)