Image & Media Support

WhatsApp channel Baileys Web के माध्यम से चलता है। यह document send, gateway और agent replies के लिए वर्तमान media handling नियमों को capture करता है।

लक्ष्य

  • mayros message send --media के माध्यम से वैकल्पिक captions के साथ media भेजें।
  • Web inbox से auto-replies को text के साथ media शामिल करने की अनुमति दें।
  • Per-type limits को sane और predictable रखें।

CLI Surface

  • mayros message send --media <path-or-url> [--message <caption>]
    • --media वैकल्पिक; media-only sends के लिए caption empty हो सकता है।
    • --dry-run resolved payload print करता है; --json { channel, to, messageId, mediaUrl, caption } emit करता है।

WhatsApp Web channel व्यवहार

  • Input: local file path या HTTP(S) URL।
  • Flow: Buffer में load करें, media kind detect करें और सही payload बनाएं:
    • Images: JPEG में resize और recompress करें (max side 2048px) agents.defaults.mediaMaxMb (डिफ़ॉल्ट 5 MB) को target करते हुए, 6 MB पर capped।
    • Audio/Voice/Video: 16 MB तक pass-through; audio को voice note (ptt: true) के रूप में भेजा जाता है।
    • Documents: कुछ और, 100 MB तक, filename preserved जब उपलब्ध हो।
  • WhatsApp GIF-style playback: gifPlayback: true (CLI: --gif-playback) के साथ MP4 भेजें ताकि mobile clients inline loop करें।
  • MIME detection magic bytes को prefer करता है, फिर headers, फिर file extension।
  • Caption --message या reply.text से आता है; empty caption की अनुमति है।

Auto-Reply Pipeline

  • getReplyFromConfig { text?, mediaUrl?, mediaUrls? } return करता है।
  • जब media मौजूद हो, तो web sender mayros message send के समान pipeline का उपयोग करके local paths या URLs को resolve करता है।
  • Multiple media entries provided होने पर sequentially भेजी जाती हैं।

Inbound Media to Commands (Pi)

  • जब inbound web messages में media शामिल हो, तो Mayros temp file में download करता है और templating variables expose करता है:
    • {{MediaUrl}} inbound media के लिए pseudo-URL।
    • {{MediaPath}} command चलाने से पहले लिखा गया local temp path।
  • जब per-session Docker sandbox enabled हो, तो inbound media को sandbox workspace में copy किया जाता है और MediaPath/MediaUrl को relative path जैसे media/inbound/<filename> में rewrite किया जाता है।
  • Media understanding (यदि tools.media.* या shared tools.media.models के माध्यम से configured हो) templating से पहले चलता है और [Image], [Audio] और [Video] blocks को Body में insert कर सकता है।
    • Audio {{Transcript}} set करता है और slash commands अभी भी काम करने के लिए command parsing के लिए transcript का उपयोग करता है।
    • Video और image descriptions command parsing के लिए किसी भी caption text को preserve करते हैं।
  • डिफ़ॉल्ट रूप से केवल पहला matching image/audio/video attachment processed है; कई attachments process करने के लिए tools.media.<cap>.attachments सेट करें।

Limits & Errors

Outbound send caps (WhatsApp web send)

  • Images: recompression के बाद ~6 MB cap।
  • Audio/voice/video: 16 MB cap; documents: 100 MB cap।
  • Oversize या unreadable media → logs में clear त्रुटि और reply skip है।

Media understanding caps (transcription/description)

  • Image डिफ़ॉल्ट: 10 MB (tools.media.image.maxBytes)।
  • Audio डिफ़ॉल्ट: 20 MB (tools.media.audio.maxBytes)।
  • Video डिफ़ॉल्ट: 50 MB (tools.media.video.maxBytes)।
  • Oversize media understanding skip करता है, लेकिन replies अभी भी original body के साथ through जाते हैं।