Skip to content

feat(email): add email client tools for agents#558

Merged
zbigniewsobiecki merged 1 commit intodevfrom
feature/email-client-tools
Feb 26, 2026
Merged

feat(email): add email client tools for agents#558
zbigniewsobiecki merged 1 commit intodevfrom
feature/email-client-tools

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

Implement comprehensive email integration for CASCADE agents, enabling them to interact with email via IMAP (read/search) and SMTP (send/reply).

Core Features

  • IMAP client for searching and reading emails using imapflow
  • SMTP client for sending emails and replying to threads using nodemailer
  • AsyncLocalStorage-based credential scoping via withEmailIntegration()
  • Database migration for email integration credentials

Gadgets (SearchEmails, ReadEmail, SendEmail, ReplyToEmail)

  • Full schema validation (RFC 2822 subject length, date formats, UID validation)
  • Error logging for all gadget operations
  • HTML body fallback when text body unavailable
  • Proper email threading support (In-Reply-To, References headers)

Agent Execution Integration

  • Email credential scoping in manual-runner, GitHub webhook handler, PM webhook handler
  • Integration role definitions for email provider credentials
  • canAccessEmail capability flag in agent definitions

Code Quality Improvements

  • IMAP connection timeouts (30s connect, 15s greeting, 60s socket)
  • Awaited transport.close() to prevent connection leaks
  • Credential resolution error logging
  • Reduced cognitive complexity via helper function extraction
  • Fixed pre-existing test failures in file gadget tests

Test plan

  • Email integration tests (credential resolution, withEmailIntegration)
  • Email client credential scoping tests
  • Gadget core function tests (27 tests total)
  • All existing tests pass (3313 tests)
  • TypeScript type check passes
  • Lint check passes (no warnings)

🤖 Generated with Claude Code

Implement comprehensive email integration for CASCADE agents:

Core features:
- IMAP client for searching, reading emails (imapflow)
- SMTP client for sending emails, replying to threads (nodemailer)
- AsyncLocalStorage-based credential scoping (withEmailIntegration)
- Database migration for email integration credentials

Gadgets (SearchEmails, ReadEmail, SendEmail, ReplyToEmail):
- Full schema validation (RFC 2822 subject length, date formats, UID validation)
- Error logging for all gadget operations
- HTML body fallback when text body unavailable
- Proper email threading support (In-Reply-To, References headers)

Agent execution integration:
- Email credential scoping in manual-runner, GitHub webhook handler, PM webhook handler
- Integration role definitions for email provider credentials
- canAccessEmail capability flag in agent definitions

Improvements from code review:
- IMAP connection timeouts (30s connect, 15s greeting, 60s socket)
- Awaited transport.close() to prevent connection leaks
- Credential resolution error logging
- Reduced cognitive complexity via helper function extraction

Tests:
- Email integration tests (credential resolution, withEmailIntegration)
- Email client credential scoping tests
- Gadget core function tests (27 tests total)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit d2a605f into dev Feb 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant