import type { Signal, SignalAdapter } from '../types.ts' export const emailAdapter: SignalAdapter = { id: 'email', displayName: 'Email', normalize(raw, ctx) { const rec = (raw && typeof raw === 'object' ? raw : {}) as Record const id = String(rec.id ?? rec.messageId ?? 'unknown') const subject = String(rec.subject ?? 'Email') const signal: Signal = { id: `sig_${crypto.randomUUID().replace(/-/g, '').slice(0, 12)}`, projectId: ctx.projectId, source: 'email', externalId: id, fingerprint: `email:${id}`, title: subject.slice(0, 200), body: String(rec.text ?? rec.body ?? rec.snippet ?? ''), severity: 'info', labels: ['email'], links: [], repoRef: null, receivedAt: new Date().toISOString(), } return [signal] }, }