feat: IMAP mail sync with thread-to-contact matching (PRD §6.1)
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
This commit is contained in:
1 parent
7acc0c5451
commit
e45b68bb8b
1089 files changed
+260614
No files matched your search
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# Lightweight environment check for PDF skill.
|
||||
# Exit 0 = all OK, exit 1 = missing dependencies.
|
||||
# Also resolves and exports PDF_SKILL_DIR and FONT_DIR.
|
||||
# Usage: source env_check.sh (preferred, exports vars to caller)
|
||||
# or: bash env_check.sh [--quiet]
|
||||
QUIET=false; [ "${1:-}" = "--quiet" ] && QUIET=true
|
||||
FAIL=0
|
||||
check() { local desc="$1"; shift; if ! "$@" &>/dev/null; then $QUIET || echo "MISSING: $desc"; FAIL=1; fi; }
|
||||
|
||||
# ── Resolve PDF_SKILL_DIR & FONT_DIR ──
|
||||
_ENV_CHECK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
||||
PDF_SKILL_DIR="$(cd "$_ENV_CHECK_DIR/.." && pwd)"
|
||||
export PDF_SKILL_DIR
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
FONT_DIR="${HOME}/Library/Fonts"
|
||||
else
|
||||
FONT_DIR="/usr/share/fonts"
|
||||
fi
|
||||
export FONT_DIR
|
||||
|
||||
check "python3" command -v python3
|
||||
check "node" command -v node
|
||||
check "pikepdf" python3 -c "import pikepdf"
|
||||
check "pdfplumber" python3 -c "import pdfplumber"
|
||||
check "pypdf" python3 -c "import pypdf"
|
||||
check "reportlab" python3 -c "import reportlab"
|
||||
check "PyMuPDF" python3 -c "import fitz"
|
||||
check "playwright" node -e "require('playwright')"
|
||||
|
||||
# LaTeX engine (tectonic) — needed for Academic pipeline
|
||||
if [ -x "$PDF_SKILL_DIR/scripts/tectonic" ]; then
|
||||
: # bundled binary OK
|
||||
elif command -v tectonic &>/dev/null; then
|
||||
: # system tectonic OK
|
||||
else
|
||||
$QUIET || echo "MISSING: tectonic (needed for LaTeX/Academic PDFs)"
|
||||
FAIL=1
|
||||
fi
|
||||
|
||||
# Font check: verify CJK fonts are available
|
||||
if command -v fc-list &>/dev/null; then
|
||||
fc-list :lang=zh 2>/dev/null | grep -qi "noto\|simhei\|wenquanyi" || { $QUIET || echo "MISSING: CJK fonts"; FAIL=1; }
|
||||
fi
|
||||
|
||||
$QUIET || echo "PDF_SKILL_DIR=$PDF_SKILL_DIR"
|
||||
$QUIET || echo "FONT_DIR=$FONT_DIR"
|
||||
return $FAIL 2>/dev/null || exit $FAIL
|
||||
Reference in new issue
Block a user