Commit Graph
44 Commits
Author SHA1 Message Date
MythEclipse b19529f135 feat: enhance logging and moderation response handling with improved serialization and error management 2026-05-30 20:13:44 +07:00
MythEclipseandClaude Opus 4.8 4fa7875b80 feat: add sticker context to LLM prompts + sticker image cache
- New sticker-specific vision prompt that tells LLM stickers are cartoon/meme art, not real photos
- New text-only warning for stickers that fail to download — prevents flagging based on name alone
- Updated system prompt with dedicated sticker guidance section (looser standards for cartoon content)
- Filesystem-backed sticker cache (keyed by name, 7-day TTL, 100MB max with LRU eviction)
- Config: STICKER_CACHE_DIR and STICKER_CACHE_MAX_SIZE_MB with defaults
- Updated .env.example with auto-delete + sticker config docs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 15:54:37 +07:00
MythEclipse 8f6a35f591 feat: integrate NVIDIA Nemotron-3 Content Safety API for Indonesian badword detection
- Added configuration options for NVIDIA Nemotron API key, model, and base URL.
- Refactored badword detection to utilize NVIDIA API, with a fallback to a local badword list.
- Updated moderation functions to handle asynchronous operations for text evidence generation.
- Removed dependency on the `indonesian-badwords` package and implemented custom detection logic.
- Enhanced tests to accommodate asynchronous behavior and validate new detection methods.
2026-05-30 14:48:50 +07:00
MythEclipseandClaude Opus 4.6 c894e5cd75 feat: expand AI moderation with structured analysis, review workflow, and guardrails
- Add structured AI moderation fields (categories, severity, confidence,
  recommended_action, policy_version, evidence) to messages table
- Add moderation_reviews, moderation_actions, and retention_policies tables
- Upgrade LLM response parsing to support structured metadata with backwards
  compatibility for legacy responses
- Implement public AI evaluation review UI with decision controls
  (approve, false positive + reanalyze, escalate)
- Add auto-delete guardrails requiring high confidence, severity, and
  allowed categories; log all attempts to moderation_actions
- Add retention manager scaffolding for messages/attachments/voice
- Add action executor for moderation actions (mute, warn, kick, ban)
- Add review routes: GET/POST/PATCH /api/reviews, GET/POST/PATCH /api/actions
- Preserve auth separation: voice/media/recordings gated, review public

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-30 01:02:51 +07:00
MythEclipse b938420eb3 feat(moderation): enhance Indonesian slang lexicon with additional profanity normalization and expand badword detection logic 2026-05-30 00:14:28 +07:00
MythEclipse d03244a0ae feat(moderation): update lexicon to include sexual deviation topics and clarify analysis guidelines 2026-05-30 00:01:09 +07:00
MythEclipse 81606f49a5 feat(moderation): enhance Indonesian slang lexicon with profanity normalization 2026-05-29 23:59:38 +07:00
MythEclipse 8c3bb77984 feat: add analytics hooks and routes for moderation statistics
- Implemented `useAnalytics` hook for fetching and managing analytics data.
- Created `analyticsStore.ts` to handle database queries for hourly stats, topic trends, user leaderboard, and moderation stats.
- Added Express routes for analytics endpoints including overview, hourly stats, topic trends, user leaderboard, moderation stats, and top violators.
- Introduced a utility function `filterHits` for filtering specific terms in text.
2026-05-29 19:37:08 +07:00
MythEclipseandClaude Opus 4.8 fb09ac81c5 feat(moderation): Indonesian slang normalizer and false-positive prevention
- Add indonesian-badwords dependency for local lexical signal
- Add Indonesian slang lexicon with woy/woi/hadeh as safe casual terms
- Normalize Discord custom emoji <:name:id> to [emoji:name] in prompts
- Wire normalization evidence into both conversationContext and llmModerationClient prompts
- Harden system prompt: woy/woi are casual greetings, not SARA/hate
- Add tests for emoji normalization, slang mapping, badword detection

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 18:39:10 +07:00
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