feat: full Cloudflare email SDK surface (@mvrx/mail 1.0.0) - #1
Merged
Conversation
Builds out @mvrx/mail from a thin @mvrx/aecs re-export into the complete AECS-SDK-1 surface. All modules implement against the interfaces already defined in adapters.ts. Core (package root): - storage: d1Init, d1Store, getThread, getMessage, listMessages (fixed §3.7 DDL, cursor-based §3.8 pagination, raw D1 prepared stmts) - send: sendEmail - rules: evaluateRules + Rule/Condition/Action types + D1 rule storage (§15) Subpath entry points: - /transports: cfTransport, smtpTransport, r2BlobStore (§3.5) - /providers: 8 AI connectors — cf, openai, anthropic, gemini, mistral, azure, ollama, openai-compat (§6) - /tools: deterministic analysis — extractAddresses, detectIntent, requiresReply, extractDates, extractLinks (§7.1) - /ai-tools: summarize, classify, sentiment, extractEntities, extractAction, ask (§7.2) - /compose: draft, reply, improve, tone, translate, suggestSubjects, send, createCompose (§8) - /attachments: attachmentsForAI, AttachmentProcessor, processors (chain, storeToR2, pdfToText, ocr, transcribe, cfPdfExtractor, runOcr, runTranscribe) (§9) - /hub: UserHub Durable Object + publishEvent/hubRouter/hubBus, typed MailEvent union, SSE fan-out, fire-and-forget (§16) Tests: 111 passing via @cloudflare/vitest-pool-workers with real D1/R2/DO bindings in workerd (not mocks). Example worker demonstrates the full receive -> store -> rules -> events -> classify -> reply loop and typechecks against the built package. Version 0.1.0 -> 1.0.0 (Appendix C: full surface stable). Signed-off-by: owenob1 <me@oweninnes.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds
@mvrx/mailout from a thin@mvrx/aecsre-export into the complete AECS-SDK-1 surface. Every module implements against the interfaces already declared inadapters.ts.Modules
Core (
@mvrx/mail)d1Init,d1Store,getThread,getMessage,listMessages(fixed §3.7 DDL, cursor-based §3.8 pagination, raw D1 prepared statements)sendEmailevaluateRules+Rule/Condition/Action+ D1 rule storage (§15)Subpaths
/transports—cfTransport,smtpTransport,r2BlobStore(§3.5)/providers— 8 AI connectors: cf, openai, anthropic, gemini, mistral, azure, ollama, openai-compat (§6)/tools— deterministic analysis (§7.1)/ai-tools— summarize, classify, sentiment, extractEntities, extractAction, ask (§7.2)/compose— draft, reply, improve, tone, translate, suggestSubjects, send, createCompose (§8)/attachments—attachmentsForAI,AttachmentProcessor,processors(chain, storeToR2, pdfToText, ocr, transcribe, cfPdfExtractor, runOcr, runTranscribe) (§9)/hub—UserHubDurable Object +publishEvent/hubRouter/hubBus, typedMailEventunion, SSE fan-out (§16)Verification
@cloudflare/vitest-pool-workers— real D1/R2/Durable Object bindings in workerd, not mocks.pnpm -r typecheck+pnpm -r buildclean.examples/basic-worker) runs the full receive → store → rules → events → classify → reply loop and typechecks against the built package.Notes / judgment calls
smtpTransportthrows a clear "inject your own client" error rather than fake a send (no bundled SMTP socket).ocr/transcribe/cfPdfExtractor) take the rawAibinding, not the text-onlyAiChatProvider; real Workers-AI extraction is exercised on deploy (unit tests assert model + input shape via a mocked binding).hubis SSE / fire-and-forget with no replay (§16.5) — events are "go refetch" signals; D1 is the source of truth.Related
Depends conceptually on mvrxapp/aecs#1 (§9.7
attachmentsInForAI), but this PR does not require it —@mvrx/mail/attachmentsships its ownattachmentsForAI().