# v365 — CORI Mail provider, draft, and work-conversion foundation

## Purpose

v365 deepens CORI Mail after the first interface foundation. The goal is to move the page closer to a real AI email operating surface while keeping it simple for dispatch users.

CORI Mail should not feel like a normal inbox. It should feel like an assistant that reads the email, explains what matters, drafts the answer, and helps turn the email into dispatch work.

## What changed

- Expanded `/cori/mail` with provider connection planning for Gmail and Outlook.
- Added visible provider cards that explain inbox read, draft create, and user-approved send capability.
- Added browser draft memory so edited draft replies can be saved and restored during the CORI Mail session foundation.
- Added a new staged provider-draft action so CORI Mail distinguishes between local draft review and future real mailbox draft creation.
- Added an email-to-work conversion panel that can prepare:
  - load notes
  - follow-up tasks
  - billing notes
  - driver updates
  - detention notes
  - sales leads
- Added a CORI work-card preview so the user sees exactly what will be saved before live persistence is wired.
- Added a provider readiness service at `src/modules/cori-mail/cori-mail-provider-readiness.service.ts`.
- Added an authenticated readiness endpoint at `/api/cori-mail/provider-readiness`.
- Added CORI Mail provider environment placeholders to `.env.example`.

## User-facing principle

The user should see plain next steps, not email technology details.

Good wording:

- “Needs answer now”
- “Draft saved”
- “Turn email into work”
- “Review first”
- “Connect email to send”

Avoid wording like:

- OAuth scope negotiation
- provider authorization grant
- immutable message ID mapping
- token refresh lifecycle

Those details can exist behind the scenes, but the page should keep the operator calm and clear.

## Guardrail

CORI may prepare, draft, stage, and suggest. CORI must not send a real email until the user approves the final message.

## Provider readiness

The new provider readiness service checks configuration shape for:

- Gmail client ID
- Gmail client secret
- Gmail redirect URI
- Outlook/Microsoft client ID
- Outlook/Microsoft client secret
- Outlook/Microsoft redirect URI
- CORI Mail draft sync setting
- CORI Mail send enable setting

Live send remains locked by default.

## Prisma schema impact

No Prisma schema changes were made in v365.
