Repository navigation
The receive side grows up: six new tools close out the archive, analyze, and clean segments of the mail lifecycle. The toolkit is now 14 tools covering all six segments — write, send, receive, archive, analyze, clean.
Added
office_archive_search— search the local JSONL index by sender, subject keyword, time window, attachment presence, or triage category. Works fully offline.office_archive_export— export matched messages as.eml+index.csv(the org-handover scenario: package a term of committee mail for the next committee). Sources are re-fetched read-only with BODY.PEEK; output is confined to workDir with deduped, sanitized filenames.office_archive_attach— batch-download attachments (the sign-up scenario: collect every résumé PDF from a public inbox). Per-attachment size cap (maxAttachmentMb), optional extension filter, path-escape blocked, skips always reported.office_stats_overview— monthly trend, top senders and recipients, category mix, and subscription share, computed locally from the index + send audit log. Zero network.office_stats_track— job-application ledger (求职台账): deterministic keyword signals auto-merge forward-only (applied → written-test → interview → offer; a rejected signal never overrides a recorded offer), freemail recruiting mail is returned asunattributedfor the agent to assign, manualupdateentries take precedence, andexportwrites a CSV thatoffice_sheetcan aggregate.office_inbox_clean— subscription cleanup advisor: a per-sender frequency table ranked by mail volume, the List-Unsubscribe URL surfaced when the sender provided one, and actionable advice per sender. Output-only — it never unsubscribes, deletes, moves, or sends anything.
Changed
office_inbox_fetchnow records the List-Unsubscribe URL in the index metadata (headers.listUnsubscribeUrl), feeding the advisor without re-fetching.- Config grows
maxArchiveMessages(default 200) andmaxAttachmentMb(default 25). - SECURITY.md documents the archive / stats / clean principles: write confinement, explicit caps, full-text-on-disk only by explicit export request, forward-only auto-merging, advice-only cleanup.
Under the hood
New modules lib/archive.js, lib/stats.js, lib/clean.js (all pure where possible: filter / aggregate / advise functions are exported and unit-tested). Tests grew from 71 to 100 — archive filters and guards, overview aggregation, ledger scan / dedup / forward-only / export, advisor thresholds and URL surfacing. DSH web-boot verified with all 14 tools loaded.
Full scenario map: docs/MAIL-SCENARIOS.zh-CN.md. Security model: SECURITY.md.