Commit Graph
35 Commits
Author SHA1 Message Date
MythEclipse 649283a3bc feat(moderation): enhance media analysis handling and integrate image evidence 2026-05-29 17:43:34 +07:00
MythEclipse 2b1c436b3e feat(moderation): enhance media evidence handling and deferral analysis rejection 2026-05-29 17:32:04 +07:00
MythEclipse 441ff5a0ed feat(moderation): fetch and analyze URLs (images and web text) from messages
- Added  to safely extract and fetch up to 3 URLs per message (with SSRF protection, 5MB limit, and 8s timeout).
- Implemented recursive  extraction to resolve Tenor/Giphy links from their HTML viewers to raw GIF binaries.
- In , fetched images are automatically injected as  into the vision LLM context, and truncated webpage text is appended to the message string.
2026-05-28 01:29:31 +07:00
MythEclipse c6af313c33 fix(moderation): immediately abort retries on 429 Too Many Requests
- In llmModerationClient.ts (inner retry), if OpenAI throws a 429 (or 401/403), throw p-retry's AbortError to immediately exit the 3-attempt inner retry loop.
- In aiAnalyzer.ts (outer retry), propagate the AbortError from runModerationAnalysis so the 2-attempt outer retry loop also aborts immediately.
- This ensures that a burst of 20 concurrent tasks hitting rate limits immediately returns the messages to the DB queue (as 'analysis_incomplete') and rapidly increments the individual circuit breaker, pausing processing and preventing a thundering herd instead of making 12 API calls per stuck message.
2026-05-28 01:09:57 +07:00
MythEclipse 7126959548 fix: bypass Cloudflare WAF 403 blocks by spoofing User-Agent and removing X-Stainless headers 2026-05-26 00:03:01 +07:00
MythEclipse cc61e2576b refactor: optimize AI moderation pipeline, fix OOM risks, token duplication, and add Zod validation 2026-05-25 23:23:12 +07:00
MythEclipse cc2ee84c3b refactor(ai-analyzer): fix resource leaks, OOM risk, and strict structured outputs 2026-05-25 22:14:05 +07:00
MythEclipse 4ec9b50f33 fix(moderation): interleave images with owning messages, Indonesian-first prompt
- Replace flat imageParts prologue with per-message image map (messageImageMap)
  keyed by message_id. Images are now inserted immediately after their owning
  message's text part in the multimodal content array, giving the vision model
  proper text+image co-context instead of a disconnected image dump before the
  entire prompt.

- Rewrite moderationPrompt as Indonesian-first bilingual system prompt:
  * Primary language: Bahasa Indonesia; English secondary
  * Explicit Discord community context with Indonesian slang awareness
    (anjay, wkwk, santuy, gw/lo abbreviations, etc.)
  * SARA, hoaks, ujaran kebencian cultural context
  * Charitable intent for ambiguous Indonesian phrasing
  * Expanded flag taxonomy: sara, hoaks, nsfw_image, gore_image, doxxing, scam
  * analysis field instructed in Bahasa Indonesia (maks 2 kalimat)
  * Retry/correction messages also in Bahasa Indonesia

- Image instruction block conditionally injected into prompt only when
  hasImages=true, explicitly telling model to treat image + preceding text
  as one semantic unit and to OCR meme/screenshot text as message content.
2026-05-22 01:04:00 +07:00
MythEclipse d0e906763e fix(moderation): fix image attachment pipeline causing PIL BadRequestError on NVIDIA inference
Three-layer defect chain causing 'cannot identify image file <_io.BytesIO object>':

1. attachmentUploader: hardcoded 'application/octet-stream' on Tele CDN upload
   regardless of actual file MIME type — CDN stored images under wrong type.

2. messageCapture: processAttachmentUpload call site never forwarded
   attachment.contentType into the options bag, so the fix in (1) would
   have received undefined and fallen back to octet-stream anyway.

3. llmModerationClient: blindly trusted att.type from the DB record
   (Discord-provided MIME) when constructing data: URLs, but validated
   neither the HTTP status of the CDN re-fetch nor the actual byte content.
   Stale/expired CDN URLs returning HTML error pages were base64-encoded
   and sent to the model as 'image/jpeg', causing PIL to reject the stream.

Fixes:
- uploadAttachmentToTele now accepts contentType param (defaults to
  application/octet-stream for non-image files)
- processAttachmentUpload options bag gains optional contentType field
- messageCapture forwards attachment.contentType at the call site
- Added sniffImageMimeType() using magic-byte probes for JPEG, PNG, GIF,
  WebP, AVIF/HEIF — runs on every downloaded attachment buffer before
  base64 encoding; skips the attachment (logs headerHex for diagnosis)
  if bytes don't match a known image format
- data: URL now uses the sniffed MIME type, not the DB record
2026-05-21 23:44:18 +07:00
Asep Haryana Saputra 41197fd2c2 feat(build): optimize Dockerfile to build vendor packages during image build and streamline package.json scripts 2026-05-21 12:27:07 +00:00
Asep Haryana Saputra 0ef6fc8d31 refactor: update import statements to use .js extensions
- Changed all import statements across the project to include the .js extension for consistency and to comply with ES module standards.
- Updated imports in various files including bootstrap.ts, shutdown.ts, config.ts, and many others.
- Ensured that all related modules and types are correctly imported with the new extension.
2026-05-21 12:03:31 +00:00
MythEclipse 834b19b1ae feat(moderation): enhance JSON extraction and validation in moderation analysis 2026-05-21 04:23:01 +07:00
MythEclipse f851ea0fa9 fix(moderation): improve error handling for malformed JSON responses and ensure proper response headers 2026-05-21 04:00:36 +07:00
MythEclipse 5588ece6c7 feat(moderation): normalize JSON response handling and enhance test coverage for moderation analysis 2026-05-21 03:52:51 +07:00
MythEclipse c1c3c99686 feat(moderation): improve message analysis scheduling and update moderation prompt structure 2026-05-21 02:56:41 +07:00
MythEclipse 7eb01606b7 feat(moderation): enhance attachment handling and AI analysis integration 2026-05-21 02:39:28 +07:00
MythEclipse 3d64228d6a feat(config): add AI analysis tuning parameters and update related logic 2026-05-21 01:55:50 +07:00
MythEclipse 7f5db953fa chore: update dependencies and improve code formatting
- Added `vendor/discord-video-stream` to pnpm workspace.
- Refactored `llmModerationClient.ts` for better readability and consistency.
- Adjusted imports in `recordingsRoutes.ts` for clarity.
- Updated `webserver.ts` to correctly import `createRecordingsRoutes`.
- Enhanced test cases in `llmModerationClient.test.ts` for improved readability.
- Updated submodule references for `better-sqlite3`, `discord-video-stream`, `discord.js-selfbot-v13`, `drizzle-orm`, and `node-datachannel`.
- Created documentation for deprecated dependency removal plan and design.
2026-05-19 02:49:55 +07:00
MythEclipse 520da01be7 fix: handle message_id with extra wrapping quotes and request strict JSON output without reasoning 2026-05-19 00:24:13 +07:00
MythEclipse 069cf105f3 fix: enhance error logging with additional context in analysis and moderation processes 2026-05-18 23:48:02 +07:00
MythEclipse 6339d741a9 refactor: streamline error handling and attachment processing in message capture 2026-05-18 23:46:51 +07:00
MythEclipse 9d5559a45b fix: wrap parsed moderation response in results object for LLM variations 2026-05-18 07:12:41 +07:00
MythEclipse 5411f8ea3d fix: enhance message ID handling and error resilience in moderation response parsing 2026-05-18 07:07:27 +07:00
MythEclipse f3c915eacd feat: add searchMessages function and corresponding API endpoint for message queries 2026-05-18 06:39:12 +07:00
MythEclipseandClaude Opus 4.7 1085d7909c fix: address LLM square bracket mapping format and resolve Biome import formatting
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 04:40:54 +07:00
MythEclipseandClaude Opus 4.7 dde8358736 feat: implement robust JSON parsing and multimodal image capping
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 04:38:30 +07:00
MythEclipse 51dc1f8869 feat: add multimodal analysis support to LLM moderation client by processing image attachments 2026-05-17 23:56:04 +07:00
MythEclipse 7a2b8420d1 fix: make all recursive local relative imports explicit with .ts extensions to resolve ESM worker thread module failures 2026-05-17 23:03:35 +07:00
MythEclipse b8a6f40b1b feat: enhance database initialization for test isolation and add transcoder metrics 2026-05-17 18:24:10 +07:00
MythEclipse 518577d79d feat: enhance screen share controller with Streamer integration and voice channel management 2026-05-17 01:01:40 +07:00
MythEclipse a5b5ccf5b0 refactor: enhance message ID handling in parseModerationResponse for precision loss and duplicates 2026-05-16 23:47:50 +07:00
MythEclipse 99ec528a03 refactor: remove unused getThreads function and related code from voice API and controller 2026-05-16 23:34:07 +07:00
MythEclipse 203aa9a589 style: organize imports after dashboard rebuild 2026-05-14 21:19:43 +07:00
MythEclipse 65ab5ecb32 fix: harden llm moderation parsing 2026-05-14 19:26:54 +07:00
MythEclipse 81253e4ffe feat: add strict llm moderation client 2026-05-14 19:21:15 +07:00