refactor(media): collapse attachment byte classification into media-core (#122168)

Attachment MIME gating and extraction dispatch used nine separate byte policies across five files; the allowlist could approve one MIME while dispatch observed another after a second sniff. @openclaw/media-core/attachment-classify now owns byte sniffing, text heuristics, extension mapping, and the seven attachment classes; the cache stores one classification that gates and dispatch share. Channel-declared MIME leads with the transport Content-Type as a byte-arbitrated hint, normalizeMimeType folds YAML/XML synonyms so existing configured allowlists keep matching, and input_file API callers keep declared-MIME precedence over cosmetic filenames. Net -135 production LOC.

Proof: 2,153 focused tests across media-core/media-understanding/media plus boundary-contract and deadcode-mirror suites; ClawSweeper local review clean (round 5, zero findings); live Telegram default-turn probe green.

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
This commit is contained in:
Ayaan Zaidi
2026-08-12 00:40:49 +05:30
committed by GitHub
parent 2e6c693177
commit 746a188c90
36 changed files with 466 additions and 395 deletions
+1
View File
@@ -602,6 +602,7 @@ const config = {
"packages/media-core": {
entry: [
"src/index.ts!",
"src/attachment-classify.ts!",
"src/base64.ts!",
"src/constants.ts!",
"src/content-length.ts!",