8 Commits
Author SHA1 Message Date
comadrejaandXubin Ren 51bd3337ef feat(bridge): send read receipts (blue ticks) for incoming messages
Mark each incoming WhatsApp message as read via sock.readMessages()
right after the startup-timestamp filter. Wrapped in try/catch so a
failed receipt never blocks message processing.
2026-06-18 00:08:42 +08:00
comadrejaandXubin Ren 4d7c2074e6 fix(anthropic): sanitize tool_use/tool_result IDs to API pattern
The Anthropic Messages API rejects tool IDs that don't match
`^[a-zA-Z0-9_-]+$` with a 400 error. Tool IDs originating from other
providers or restored multi-turn sessions can contain invalid
characters (pipes, dots). Add a deterministic _sanitize_tool_id() and
apply it to both the tool_use id and the matching tool_result
tool_use_id so the pair stays consistent.
2026-06-18 00:03:08 +08:00
comadrejaandXubin Ren 4262375c19 chore: ignore bridge/node_modules
The .gitignore already excludes desktop/ and webui/ node_modules but
not the bridge's. Add bridge/node_modules/ so the compiled bridge deps
are never accidentally committed.
2026-06-16 17:32:02 +08:00
comadrejaandXubin Ren f3eb2aa08b feat(transcription): add AssemblyAI as transcription provider
Add AssemblyAI as a third transcription provider option alongside
OpenAI and Groq. AssemblyAI offers better accuracy for certain
audio types (distant voices, noisy environments) and serves as a
reliable fallback when other providers struggle.

Changes:
- Add AssemblyAITranscriptionProvider class in providers/transcription.py
- Add 'assemblyai' option in base channel's transcribe_audio()
- Per-channel configuration via transcriptionProvider in config

Usage:
  Set transcriptionProvider: 'assemblyai' and provide an AssemblyAI
  API key via transcriptionApiKey in the channel config.
2026-06-09 05:33:18 +08:00
comadreja eec59c05de feat(bridge): WhatsApp forwarded message detection, startup guard, and contact handling
Three improvements to the WhatsApp Baileys bridge:

1. Forwarded message detection: Extracts contextInfo.isForwarded from
   all message types (text, image, video, audio, document) and passes
   it as isForwarded in the InboundMessage. Allows the agent to
   distinguish forwarded content from direct messages — useful for
   different handling (e.g., transcribe-only vs execute as instruction).

2. Startup timestamp guard: Records the timestamp when the bridge
   starts and drops any messages with messageTimestamp older than
   startup time. Prevents replaying message history on reconnect,
   which caused duplicate processing and stale command execution.

3. Contact message handling: Adds support for contactMessage and
   contactsArrayMessage types, extracting displayName and vcard
   data instead of silently dropping shared contacts.

Changes:
- Add isForwarded field to InboundMessage interface
- Add startupTimestamp guard in message processing loop
- Add contactMessage/contactsArrayMessage extraction
- Extract contextInfo.isForwarded from all media message types
2026-06-06 12:25:24 -05:00
comadrejaandXubin Ren bfe53ebb10 fix(memory): harden consolidation with try/except on token estimation and chunk size cap
- Wrap both token estimation calls in try/except to prevent silent failures
  from crashing the consolidation cycle
- Add _MAX_CHUNK_MESSAGES = 60 to cap messages per consolidation round,
  avoiding oversized chunks being sent to the consolidation LLM
- Improve idle log to include unconsolidated message count for easier debugging

These are purely defensive improvements with no behaviour change for
normal sessions.
2026-04-10 12:58:58 +08:00
comadreja 59396bdbef fix(whatsapp): detect phone vs LID by JID suffix, not field name
The bridge's pn/sender fields don't consistently map to phone/LID
across different versions. Classify by JID suffix instead:
  @s.whatsapp.net  → phone number
  @lid.whatsapp.net → LID (internal WhatsApp identifier)

This ensures allowFrom works reliably with phone numbers regardless
of which field the bridge populates.
2026-03-26 21:48:30 -05:00
comadreja db50dd8a77 feat(whatsapp): add voice message transcription via OpenAI/Groq Whisper
Automatically transcribe WhatsApp voice messages using OpenAI Whisper
or Groq. Configurable via transcriptionProvider and transcriptionApiKey.

Config:
  "whatsapp": {
    "transcriptionProvider": "openai",
    "transcriptionApiKey": "sk-..."
  }
2026-03-26 21:46:31 -05:00