Real IMAP connection via imapflow library: - Connects to IMAP server (IMAPFlow, TLS on port 993) - Fetches recent messages (configurable limit, default 20) - Extracts: from, fromEmail, subject, date, snippet (200 chars) - Thread-to-contact matching (PRD §6.1): 1. Match sender email against persons table 2. If no person match, extract domain and match against company.website 3. Returns matchedCompany + matchedPerson for each email - Audit-logged (action: crm.mailsync:imap) - Zod validated (host, port, user, password, folder, limit) - 502 on IMAP connection failure with detail - 400 on validation failure Tested: invalid creds → 502 'IMAP connection failed', missing host → 400
1.3 KiB
Executable File
1.3 KiB
Executable File
State Tracking Guidance
Reference for tracking multiple tasks or requests.
Request Tracking
Label each user request:
[R1] Build login page
[R2] Add dark mode
[R3] Fix header alignment
Track state for user visibility:
[R1] [DONE] Done
[R2] [WIP] In progress (awaiting user approval for step 2)
[R3] [Q] Queued
Managing Multiple Requests
When user sends a new request while another is in progress:
- Acknowledge: "Got it, I'll add this to the queue"
- Show updated queue to user
- Ask user if priority should change
Handling Interruptions
| Situation | Suggested Action |
|---|---|
| New unrelated request | Add to queue, ask user priority |
| Request affects current work | Pause, explain impact, ask user how to proceed |
| User says "stop" or "wait" | Stop immediately, await instructions |
| User changes requirements | Summarize impact, ask user to confirm changes |
User Decisions
Always ask user before:
- Starting work on queued items
- Changing priority order
- Rolling back completed work
- Modifying the plan
Progress File (Optional)
User may request a state file:
## In Progress
[R2] Dark mode - Step 2/4 (awaiting user approval)
## Queued
[R3] Header fix
## Done
[R1] Login page [DONE]
Update only when user requests or approves changes.