warelay 1.3.0 (2025-12-02)
Highlights
- Pluggable agents (Claude, Pi, Codex, Opencode): New
inbound.reply.agentblock chooses the CLI and parser per command reply; per-agent argv builders inject the right flags/identity/prompt handling and parse NDJSON streams, enabling Pi/Codex swaps without changing templates. - Safety stop words for agents: If an inbound message is exactly
stop,esc,abort,wait, orexit, warelay immediately replies “Agent was aborted.”, kills the pending agent run, and marks the session so the next prompt is prefixed with a reminder that the previous run was aborted. - Agent session reliability: Only Claude currently returns a
session_idthat warelay persists; other agents (Gemini, Opencode, Codex, Pi) don’t emit stable session identifiers, so multi-turn continuity may reset between runs for those harnesses.
Bug Fixes
- Empty result field handling: Fixed bug where Claude CLI returning
result: ""(empty string) would cause raw JSON to be sent to WhatsApp instead of being treated as valid empty output. Changed truthy check to explicit type check incommand-reply.ts. - Response prefix on heartbeat replies: Fixed
responsePrefix(e.g.,🦞) not being applied to heartbeat alert messages. The prefix was only applied in the regular message handler, not inrunReplyHeartbeat. - User-visible error messages: Command failures (non-zero exit, killed processes, exceptions) now return user-friendly error messages to WhatsApp instead of silently failing with empty responses.
- Test session isolation: Fixed tests corrupting production
sessions.jsonby mocking session persistence in all test files. - Signal session corruption prevention: Added IPC mechanism so
warelay sendandwarelay heartbeatreuse the running relay's WhatsApp connection instead of creating new Baileys sockets. Previously, using these commands while the relay was running could corrupt the Signal session ratchet (both connections wrote to the same auth state), causing the relay's subsequent sends to fail silently. - Web send media kinds:
sendMessageWebnow honors media kind when sending via WhatsApp Web: audio → PTT with correct opus mimetype, video → video, image → image, other → document with filename. Previously all media were sent as images, breaking audio/video/doc sends.
Changes
- IPC server for relay: The web relay now starts a Unix socket server at
~/.warelay/relay.sock. Commands likewarelay send --provider webautomatically connect via IPC when the relay is running, falling back to direct connection otherwise. - Batched inbound messaging with timestamps: When multiple WhatsApp messages queue up, they’re sent to the agent in one combined batch, each line timestamped consistently to preserve ordering and context.
- Typing indicator after IPC send: After sending a message via IPC (e.g.,
warelay send), the relay now automatically shows the typing indicator ("composing") to signal that more messages may be coming. - Auto-recovery from stuck WhatsApp sessions: Added watchdog timer that detects when WhatsApp event emitter stops firing (e.g., after Bad MAC decryption errors) and automatically restarts the connection after 30 minutes of no message activity. Heartbeat logging now includes
minutesSinceLastMessageand warns when >30 minutes without messages. The 30-minute timeout is intentionally longer than typicalheartbeatMinutesconfigs to avoid false positives. - Early allowFrom filtering: Unauthorized senders are now blocked in
inbound.tsBEFORE encryption/decryption attempts, preventing Bad MAC errors from corrupting session state. Previously, messages from unauthorized senders would trigger decryption failures that could silently kill the event emitter. - Test isolation improvements: Mock
loadConfig()in all test files to prevent loading real user config (with emojis/prefixes) during tests. Default test config now has no prefixes/timestamps for cleaner assertions. - Same-phone mode (self-messaging): warelay now supports running on the same phone number you message from. This enables setups where you chat with yourself to control an AI assistant. Same-phone mode (
from === to) is always allowed, even without configuringallowFrom. Echo detection prevents infinite loops by tracking recently sent message text and skipping auto-replies when incoming messages match. - Echo detection: The
fromMefilter ininbound.tsis deliberately removed for same-phone setups; instead, text-based echo detection inauto-reply.tstracks sent messages in a bounded Set (max 100 entries) and skips processing when a match is found. - Same-phone detection logging: Verbose mode now logs
📱 Same-phone mode detectedwhenfrom === to. - Configurable same-phone marker: New
inbound.samePhoneMarkerconfig option to customize the prefix added to messages in same-phone mode (default:[same-phone]). Set it to something cute like[🦞 same-phone]to help distinguish bot replies.
Contributors
- @RealSid08 (Sidhaarth Krishnan)
Testing
- pnpm lint
- pnpm test
- pnpm build