123 Commits
Author SHA1 Message Date
TooonyChen 83927b8b2b test: add real-mail fixture evals 2026-07-09 16:22:12 +12:00
TooonyChen b6a1ad7d9d fix: keep anchor hrefs when stripping HTML and accept bare text/html fragments
Forwarded mails (e.g. Yandex webmail) arrive as a single text/html part
with no <html>/<body> wrapper and no text/plain alternative. Two bugs made
their codes unextractable:

- stripHtmlTags dropped href attributes, so button-only mails (Netflix
  'Get Code') reached the LLM with no URL at all → codeExist=0.
  Anchors now render as 'label [url]' with &amp; decoded.
- extractMailBodies only recognised single-part HTML wrapped in
  <html>/<body>, so htmlBody was null and the Rendered preview was empty.
  A bare fragment with Content-Type text/html now counts as the html body.

Verified against the real forwarded Netflix mail from production raw_mails:
content now carries the travel/verify link and classifies 5/5 as
login_code.
2026-07-09 15:43:18 +12:00
TooonyChen 5508c14663 feat(web): show sender address in mail detail + mobile master-detail view
- From line now renders the org name followed by <from_addr> when both exist.
- On mobile (<lg) the inbox is a master-detail flow: tapping a row opens
  the detail full-screen (scrolled to top) with a back button, instead of
  stacking both cards and forcing a scroll past 20 rows to reach the code.
  Desktop two-column layout is unchanged.
2026-07-09 15:29:30 +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 207cd0c789 fix: handle MIME decoding and deploy workflow 2026-07-08 00:25:26 +12:00
TooonyChen f031612996 feat: Hono rewrite, multi-user grants, remote MCP server 2026-07-07 23:47:08 +12:00
TooonyChen 1551de0868 feat: add mcp access and remove legacy frontend 2026-03-17 11:20:52 +13:00
TooonyChen 461dfad44a update screenshots 2026-03-15 04:27:01 +13:00
TooonyChen c80f470130 update readme diagram again 2026-03-15 04:13:19 +13:00
TooonyChen 78fea0cdbc update readme diagram 2026-03-15 04:09:13 +13:00
TooonyChen 6245cca27c Merge branch '2026-update' 2026-03-15 03:45:24 +13:00
TooonyChen c6cc3ab561 refactor: put "routes" to the top 2026-03-15 03:44:39 +13:00
Tony Chen 2f561fc168 Merge pull request #7 from TooonyChen/2026-update
feat: React dashboard, unified AI provider config, and email processing improvements
2026-03-15 03:34:23 +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
TooonyChen 749f1141bb update .gitignore 2026-03-15 03:09:42 +13:00
Tony Chen 365b553b7e Merge pull request #6 from TooonyChen/feat/openai_support
feat: adding OpenAI support and change the gemini model to geimini-2.0-flash
2025-09-29 19:25:56 +13:00
Tony Chen e6736b8201 feat: adding OpenAI support 2025-09-29 19:22:01 +13:00
Tony Chen 617fe9ca34 Merge pull request #3 from oneisall8955/main
trigger action manually & provide rpc interface
2025-01-08 00:44:55 +13:00
oneisall cbf553119c WorkerEntrypoint style & expose rpc interface 2025-01-07 18:05:06 +08:00
刘志聪 a8dd170913 trigger action manually 2025-01-06 12:12:12 +08:00
Tony Chen 552763d5fe Create LICENSE 2024-10-17 17:59:18 +13:00
Tony Chen c65f34d7a1 Update README.md 2024-10-17 06:13:09 +13:00
Tony Chen 585bd7b459 Update README.md 2024-10-17 06:11:40 +13:00
Tony Chen d6aa36b1af Update README_CN.md 2024-10-16 21:35:56 +13:00
Tony Chen 351b13b3b8 Update README.md 2024-10-16 21:35:22 +13:00
TooonyChen 170f968f38 modify readme 2024-10-08 21:14:20 +13:00
TooonyChen d1a512899d modify readme 2024-10-08 21:11:16 +13:00
TooonyChen a5980b293a modify readme 2024-10-08 21:09:59 +13:00
Tony Chen 1c0e3929cc Update README.md 2024-10-08 20:52:32 +13:00
TooonyChen 4a6f2cbf50 modify readme 2024-10-08 20:52:03 +13:00
TooonyChen a488bdf7b7 modify readme 2024-10-08 20:45:59 +13:00
TooonyChen cef8916d22 modify wrangler.toml 2024-10-08 20:42:31 +13:00
Tony Chen bb86879a13 Update wrangler.toml.example 2024-10-08 20:40:19 +13:00
TooonyChen 361a94a981 modify readme 2024-10-08 20:39:23 +13:00
TooonyChen 4cc046a0e6 modify readme 2024-10-08 20:36:08 +13:00
Tony Chen 57dd096a9a Update README.md 2024-10-08 20:31:04 +13:00
Tony Chen e24cca5b60 Update README_CN.md 2024-10-08 20:30:14 +13:00
TooonyChen 469f603b8b modify readme 2024-10-08 20:26:57 +13:00
TooonyChen 6c4b86644b modify readme 2024-10-08 20:24:37 +13:00
TooonyChen c44688fbcb modify readme 2024-10-08 20:21:36 +13:00
TooonyChen 3d4399efba modify wrangler.toml 2024-10-08 20:19:26 +13:00
TooonyChen 7c93abeb3f modify readme 2024-10-08 20:05:46 +13:00
TooonyChen 0902e0b317 modify readme 2024-10-08 20:01:06 +13:00
TooonyChen 0f3b11411e modify readme 2024-10-08 19:45:35 +13:00
TooonyChen 1a62496066 modify wrangler.toml.example 2024-10-08 19:39:42 +13:00
TooonyChen 9031f3a7c4 modify readme file 2024-10-08 19:29:08 +13:00