8 Commits
Author SHA1 Message Date
TooonyChen 83927b8b2b test: add real-mail fixture evals 2026-07-09 16:22:12 +12:00
TooonyChen bc76275d04 fix: stop treating List-Unsubscribe alone as promotional for transactional mail
Gmail/Yahoo bulk-sender rules (2024) force large senders (Netflix via SES,
etc.) to add List-Unsubscribe to verification emails too, so it can no
longer be an unconditional bulk signal — real access-code mail was being
filtered before the LLM and never reached code_mails.

List-ID/List-Post, Precedence bulk/list, and ESP campaign X-headers remain
unconditional. List-Unsubscribe alone is now exempted when the decoded
subject looks transactional (code/verify/OTP/sign-in/reset/验证码/…);
genuine ads that slip through still get codeExist=0 from the classifier.
2026-07-08 18:12:21 +12:00
TooonyChen d6731f8180 feat: optional OAuth on /mcp for claude.ai remote connectors
- Wrap the Worker with @cloudflare/workers-oauth-provider: /oauth/token,
  /oauth/register (dynamic client registration), and /.well-known/* are
  implemented by the library; tokens/grants/clients live in OAUTH_KV.
- New consent page at /oauth/authorize reuses the session cookie;
  unauthenticated visitors bounce through the SPA login via returnTo.
- Grant props store only userId; oauthPropsAuth re-fetches the user from
  D1 on every MCP request, so deleting a user revokes access instantly.
  Permissions still flow exclusively through visibleMails().
- OAuth is optional: without the OAUTH_KV binding the provider is skipped
  entirely and /mcp keeps working with aik_ API keys only. With it, both
  credentials coexist (Bearer aik_ requests pre-route around the provider).
- Docs and wrangler examples updated; KV block commented out by default.
2026-07-08 17:44:05 +12:00
TooonyChen 5b6e8b0efc chore: remove dead v1 MCP code and legacy schema dump
- src/mcp.ts: unused v1 JSON-RPC MCP implementation (claimed Basic Auth,
  old tool names); the live server is src/mcp/server.ts
- test/mcp.test.ts: only tested the dead file
- db/schema.sql: superseded by migrations/
2026-07-08 00:48:13 +12:00
TooonyChen b71375bfa7 docs: update all docs for v2 (Hono, multi-user grants, MCP server) 2026-07-08 00:42:12 +12:00
TooonyChen 1551de0868 feat: add mcp access and remove legacy frontend 2026-03-17 11:20:52 +13:00
TooonyChen c0e838b780 feat: replace provider-specific AI clients with unified callProvider()
- Remove callGemini() / callOpenAI() and all Gemini/OpenAI-specific env
    vars (GoogleAPIKey, GeminiModel, OpenAIAPIKey, OpenAIBaseUrl, OpenAIModel)
  - Add callProvider() supporting three API formats:
      openai      → POST /v1/chat/completions
      responses   → POST /v1/responses
      anthropic   → POST /v1/messages (x-api-key, anthropic-version header)
  - New env vars: AI_BASE_URL, AI_API_KEY, AI_API_FORMAT, AI_MODEL
  - Optional fallback provider via AI_FALLBACK_* (all four or none);
    primary retries 3×, fallback attempts 1×
  - Update wrangler.toml.example* to new var schema (default: Gemini OpenAI-compat)
  - Update README, README_CN, AGENTS.md, CLAUDE.md accordingly
2026-03-15 03:29:29 +13:00
TooonyChen 4835e758a4 feat: add React frontend, migrate to pnpm, and harden email processing
- Replace server-rendered HTML with React 18 + Vite + shadcn/ui dashboard
    (mail list, detail panel, Extracted/Raw/Rendered tabs, sonner toasts)
  - Add REST API endpoints: GET /api/mails, GET /api/mails/:id
  - Fix MIME base64 body extraction (rewrite extractMailBodies with proper
    multipart boundary parsing and atob decoding)
  - Add isPromotionalEmail() pre-LLM filter (List-Unsubscribe, List-ID,
    Precedence: bulk, ESP X-headers) to avoid wasting AI tokens on ads
  - Fix codeAndLink() to use regex URL extraction instead of comma-split,
    preventing layout break on URLs containing commas
  - Add ASSETS binding to wrangler.toml.example for static frontend serving
- Migrate from npm to pnpm; add pnpm-workspace.yaml
  - Add CLAUDE.md and update AGENTS.md with current architecture
2026-03-15 03:11:08 +13:00