Commit Graph

22 Commits

Author SHA1 Message Date
Arne Moor
6da26f3f21 fix: critical Telegram integration issues
- Add Telegram handling to relay command when selected via pickProvider
- Add Telegram delivery support to agent --deliver command
- Add telegram: prefix to sender identifiers to prevent session ID collisions
- Update detectProvider to properly handle telegram: prefixed identifiers
- Document provider detection logic and session ID collision prevention

Fixes session ID collisions where Telegram users without usernames (numeric IDs
or phone numbers) were being misidentified as WhatsApp users, causing cross-
provider session leakage.
2025-12-06 02:34:44 +01:00
Arne Moor
a9f3527c4c feat: add cross-provider Claude session sharing
Implements identity mapping to allow linking WhatsApp, Telegram, and Twilio
identities for shared Claude conversation sessions across providers.

Core Features:
- Identity mapping storage in ~/.clawdis/identity-map.json
- Session ID normalization for unified sessions
- CLI commands for managing identity mappings
- Full backwards compatibility (opt-in feature)

New Identity Module (src/identity/):
- types.ts: Type definitions for identity mappings
- storage.ts: CRUD operations for identity persistence
- normalize.ts: Session ID normalization logic
- Comprehensive test coverage (29 tests passing)

CLI Commands (src/commands/identity.ts):
- identity link: Link multiple provider identities
- identity list: Show all identity mappings
- identity show: Display specific mapping details
- identity unlink: Remove identity mapping
- Input validation for E.164 phone numbers and Telegram usernames
- JSON output support for list/show commands

Session Integration:
- Made deriveSessionKey() async to support identity lookups
- Updated all callers: auto-reply, agent command, web provider
- Group conversations excluded from identity mapping
- Provider detection based on ID format

Documentation:
- docs/session-sharing.md: Comprehensive user documentation
- Architecture overview and use cases
- CLI usage examples and troubleshooting guide

Test Coverage:
- src/identity/normalize.test.ts: 11 tests for normalization
- src/identity/storage.test.ts: 18 tests for storage operations
- 100% coverage of identity module functionality

Files Changed:
- 10 new files (identity module, CLI, docs, tests)
- 5 modified files (sessions, CLI integration, auto-reply)

Build Status:
- All tests passing (29/29)
- Zero TypeScript errors
- Ready for production use
2025-12-05 23:02:01 +01:00
Arne Moor
69608fd305 feat: add telegram provider with CLI integration
Add Telegram as a third messaging provider alongside web and twilio.

Core Features:
- Interactive login flow with phone/SMS/2FA authentication
- Send text and media messages (images, videos, audio, documents)
- Monitor incoming messages with auto-reply support
- Session management at ~/.clawdis/telegram/session/
- Full CLI integration (login, logout, status, send, relay commands)

Implementation Details:
- Uses telegram npm package for MTProto API access
- Supports both URL and local file media sending
- Cross-platform path handling (Windows/Unix)
- Optional Twilio env vars (supports Telegram-only usage)
- Minimal provider abstraction pattern
- Comprehensive test coverage (440 tests passing)

Changes:
- Add Telegram module (client, login, monitor, inbound, outbound, session)
- Add provider factory and base interfaces
- Wire Telegram functions into CLI deps
- Update env validation to make Twilio fields optional
- Add telegram to all CLI commands (login, logout, status, send, relay)
- Add null checks in Twilio code for optional env fields
- Fix send command to properly load session and connect
- Add local file support with cross-platform path handling
- Update login message to show correct ~/.clawdis path
- Add comprehensive tests and documentation

Basic Usage:
  warelay login --provider telegram
  warelay send --provider telegram --to "@user" --message "Hi"
  warelay send --provider telegram --to "@user" --media "/path/to/file.jpg"
  warelay relay --provider telegram

All tests pass (63 files, 440 tests). Zero TypeScript errors.
2025-12-05 18:59:38 +01:00
Peter Steinberger
20cb709ae3 chore: organize imports after rebrand 2025-12-04 18:02:51 +00:00
Peter Steinberger
05b76281f7 CLI: add agent command for direct agent runs 2025-12-04 17:54:20 +00:00
Peter Steinberger
ed080ae988 Tests: cover agents and fix web defaults
Co-authored-by: RealSid08 <RealSid08@users.noreply.github.com>
2025-12-02 11:08:00 +00:00
Peter Steinberger
e86b507da7 Add IPC to prevent Signal session corruption from concurrent connections
When the relay is running, `warelay send` and `warelay heartbeat` now
communicate via Unix socket IPC (~/.warelay/relay.sock) to send messages
through the relay's existing WhatsApp connection.

Previously, these commands created new Baileys sockets that wrote to the
same auth state files, corrupting the Signal session ratchet and causing
the relay's subsequent sends to fail silently.

Changes:
- Add src/web/ipc.ts with Unix socket server/client
- Relay starts IPC server after connecting
- send command tries IPC first, falls back to direct
- heartbeat uses sendWithIpcFallback helper
- inbound.ts exposes sendMessage on listener object
- Messages sent via IPC are added to echo detection set
2025-12-02 06:31:07 +00:00
Peter Steinberger
e5f677803f chore: format to 2-space and bump changelog 2025-11-26 00:53:53 +01:00
Peter Steinberger
b6250efbf3 Raise test coverage to ~73% 2025-11-25 12:48:12 +01:00
Peter Steinberger
c83efdc5bc CLI: unify webhook ingress and keep up as tailscale alias 2025-11-25 12:38:38 +01:00
Peter Steinberger
ff6e13d274 Add CLI and infra test coverage 2025-11-25 12:30:43 +01:00
Peter Steinberger
800c7a1e1f chore: sync source updates 2025-11-25 12:12:13 +01:00
Peter Steinberger
a9533d0999 chore: add connection/send logs and web error surfacing 2025-11-25 05:10:19 +01:00
Peter Steinberger
948ff7f035 feat: add image support across web and twilio 2025-11-25 04:58:31 +01:00
Peter Steinberger
2aac606979 chore: fix type regressions and helpers 2025-11-25 04:40:57 +01:00
Peter Steinberger
28277a298a feat: retries for webhook bring-up and send --json docs 2025-11-25 04:10:20 +01:00
Peter Steinberger
d1923e6efe feat: add send --json, logger cleanup, and resilient Claude parsing 2025-11-25 04:08:42 +01:00
Peter Steinberger
fdfb1df0de feat: add dry-run options and retry helper 2025-11-25 03:57:50 +01:00
Peter Steinberger
8bd406f6b1 feat: add config validation and send dry-run 2025-11-25 03:46:26 +01:00
Peter Steinberger
a89d7319a9 refactor: modularize cli helpers 2025-11-25 03:42:12 +01:00
Peter Steinberger
938e237411 Add command modules and tests; commit remaining changes 2025-11-25 00:12:12 +01:00
Peter Steinberger
52e0c8de25 Fix lint warnings and tighten test mocks 2025-11-25 00:10:34 +01:00