Commit Graph

409 Commits

Author SHA1 Message Date
Arne Moor
7290734f2b fix: normalize Telegram phone numbers to E.164 format
Fixed extractSenderIdentifier to always add + prefix to phone numbers
from GramJS, ensuring they match normalized allowFrom entries.

Without this fix, Telegram senders with phone-based identifiers would
be blocked when using allowFrom whitelists because:
- GramJS returns phone as "123456789"
- normalizeAllowFromEntry expects "+123456789"
- Comparison fails: telegram:123456789 != telegram:+123456789

Now all phone identifiers are consistently normalized to telegram:+phone.
2025-12-06 03:29:37 +01:00
Arne Moor
4ac19117c1 fix: update all Telegram paths to use clawdis branding
- Fixed normalizeAllowFromEntry to properly handle telegram: prefix
- Removed unused telegram.allowFrom config field from schema
- Updated all documentation to use ~/.clawdis paths with legacy fallback notes
- Fixed selectProviders to include Twilio support
- Added provider disconnect in agent delivery
- Improved media type detection
- Made Telegram inbound media save buffer to disk for Claude access

All Telegram identifiers now require telegram: prefix in shared inbound.allowFrom config.
2025-12-06 03:26:23 +01:00
Arne Moor
6e9f615a95 docs: update allowFrom examples with Telegram identifiers
- Update Full Configuration example to include Telegram identifiers
- Expand allowFrom documentation to show all supported formats
- Add note about telegram: prefix requirement in allowFrom lists
- Show examples of telegram usernames, phone numbers, and numeric IDs
2025-12-06 02:52:23 +01:00
Arne Moor
30ff0fda64 docs: add session isolation and identity mapping documentation
Document how provider prefixes prevent session ID collisions and explain
the identity-map.json feature for intentional cross-provider session sharing.

Covers:
- Default isolated session behavior (telegram: prefix)
- Why isolation prevents context confusion
- How to use identity-map.json for intentional sharing
- Provider identifier format reference
2025-12-06 02:43:57 +01:00
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
a67243dd49 fix: session management and Telegram message formatting
- Fix /new command session creation by checking isNewSession flag
- Add timestamp prefix to Telegram messages matching WhatsApp format
- Add reply logging for Telegram matching WhatsApp behavior
- Move think level token extraction before bodyPrefix to avoid false matches
- Update agent specs (claude, gemini, opencode) to send identity on new sessions
- Pass sessionIntro in command context for proper agent initialization
2025-12-06 02:27:37 +01:00
Arne Moor
08bede3a0b fix: align console logs in multi-provider mode
Suppress individual provider startup messages when running in
multi-provider mode to avoid duplicate/conflicting console output.
The multi-relay orchestrator provides unified startup messaging.

Changes:
- Add suppressStartMessage to WebMonitorTuning type
- Update monitorWebProvider to suppress startup message when flag set
- Update Telegram monitor to suppress initial "Starting..." message
- Pass suppressStartMessage: true from multi-relay to both providers

Console output before:
  📡 Starting 2 provider(s): web, telegram
  📡 Starting Telegram relay...
  📡 Listening for personal WhatsApp Web inbound messages. Leave this running; Ctrl+C to stop.
   All 2 provider(s) active. Listening for messages... (Ctrl+C to stop)

Console output after:
  📡 Starting 2 provider(s): web, telegram
   All 2 provider(s) active. Listening for messages... (Ctrl+C to stop)
2025-12-05 23:39:24 +01:00
Arne Moor
15a4631a97 feat: add multi-provider concurrent relay support
Implement --providers option to run multiple messaging providers
simultaneously in a single relay command. This enables seamless
session sharing across WhatsApp, Telegram, and Twilio.

Changes:
- Add src/cli/multi-relay.ts: Core multi-provider orchestration
  - Concurrent provider execution with Promise.allSettled
  - Graceful shutdown handling with AbortController
  - Unified startup and shutdown messaging
  - Per-provider error isolation

- Add selectProviders() to src/web/session.ts
  - Validates provider authentication before starting
  - Expands "auto" to all authenticated providers
  - User-friendly error messages for missing auth

- Update src/cli/program.ts relay command
  - Add --providers option (comma-separated list)
  - Refactor to build webTuning before multi-provider check
  - Pass suppressStartMessage=true to prevent duplicate logs

- Fix src/config/sessions.test.ts
  - Update tests to await async deriveSessionKey()

Tests:
- Add 11 new tests in src/cli/multi-relay.test.ts
  - Provider startup and shutdown
  - Concurrent execution
  - SIGINT handling
  - Error isolation
  - Console log alignment
- All 480 tests passing

Usage:
  warelay relay --providers web,telegram
  warelay relay --providers auto --verbose
2025-12-05 23:26:30 +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
916a41ed60 branding: default to clawdis paths and launchd label 2025-12-04 18:01:30 +00:00
Peter Steinberger
9797a9993a docs: document agent CLI and changelog 2025-12-04 17:55:38 +00:00
Peter Steinberger
04ce98148d web: fix mentioned JID extraction typing 2025-12-04 17:54:51 +00:00
Peter Steinberger
34eb75f634 auto-reply: honor /new after timestamp prefixes 2025-12-04 17:54:20 +00:00
Peter Steinberger
05b76281f7 CLI: add agent command for direct agent runs 2025-12-04 17:54:20 +00:00
Eng. Juan Combetto
4a35bcec21 fix: resolve lint errors (unused vars, imports, formatting)
- Prefix unused test variables with underscore
- Remove unused piSpec import and idleMs class member
- Fix import ordering and code formatting
2025-12-04 16:15:17 +00:00
Eng. Juan Combetto
518af0ef24 config: support clawdis.json path for rebranding
- Add CONFIG_PATH_CLAWDIS (~/.clawdis/clawdis.json) as preferred path
- Keep CONFIG_PATH_LEGACY (~/.warelay/warelay.json) for backward compatibility
- Update loadConfig() to check clawdis.json first, fallback to warelay.json
- Fix TypeScript type error in extractMentionedJids (null handling)

Part of the warelay → clawdis rebranding effort.
2025-12-04 16:15:17 +00:00
Peter Steinberger
a155ec0599 auto-reply: handle group think/verbose directives 2025-12-04 02:29:32 +00:00
Peter Steinberger
80979cf4d0 🦞 Add backlinks to clawd.me, soul.md, steipete.me 2025-12-03 15:46:29 +00:00
Peter Steinberger
a27ee2366e 🦞 Rebrand to CLAWDIS - add docs, update README
- New README with CLAWDIS branding
- docs/index.md - Main landing page
- docs/configuration.md - Config guide
- docs/agents.md - Agent integration guide
- docs/security.md - Security lessons (including the find ~ incident)
- docs/troubleshooting.md - Debug guide
- docs/lore.md - The origin story

EXFOLIATE!
2025-12-03 15:45:43 +00:00
Peter Steinberger
7bc56d7cfe test: cover verbose directive in group batches 2025-12-03 15:45:43 +00:00
Peter Steinberger
088bdb3313 fix: allow directive-only toggles inside group batches 2025-12-03 15:45:43 +00:00
Peter Steinberger
89d49cd925 chore: bump version to 1.4.0 2025-12-03 15:45:43 +00:00
Peter Steinberger
84f8d8733e docs: note media-only mention fix 2025-12-03 15:45:43 +00:00
Peter Steinberger
07f323222b fix(web): capture mentions from media captions 2025-12-03 15:45:43 +00:00
Peter Steinberger
a321bf1a90 fix(web): surface media fetch failures 2025-12-03 15:45:43 +00:00
Peter Steinberger
92a0763a74 changelog: note verbose tool emoji/previews 2025-12-03 15:45:43 +00:00
Peter Steinberger
e878780808 auto-reply: single emoji per verbose tool line 2025-12-03 15:45:43 +00:00
Peter Steinberger
cb5f1fa99d auto-reply: emoji + result preview for verbose tool calls 2025-12-03 15:45:43 +00:00
Peter Steinberger
b55ac994ea feat(web): prime group sessions with member roster 2025-12-03 15:45:43 +00:00
Peter Steinberger
3a8d6b80e0 auto-reply: surface tool args from rpc start events 2025-12-03 15:45:43 +00:00
Peter Steinberger
3354a68373
Create CNAME 2025-12-03 16:44:03 +01:00
Peter Steinberger
edc894f6c7 fix(web): annotate group replies with sender 2025-12-03 13:25:34 +00:00
Peter Steinberger
f68714ec8e fix(web): unwrap ephemeral/view-once and keep mentions 2025-12-03 13:15:46 +00:00
Peter Steinberger
7be9352a3a test(web): ensure group messages carry sender + bypass allowFrom 2025-12-03 13:12:05 +00:00
Peter Steinberger
3a782b6ace fix(web): let group pings bypass allowFrom 2025-12-03 13:11:01 +00:00
Peter Steinberger
47d0b6fc14 changelog: note logging capture and verbose trace 2025-12-03 13:09:29 +00:00
Peter Steinberger
8204351d67 fix(web): allow group replies past allowFrom 2025-12-03 13:08:54 +00:00
Peter Steinberger
4c3635a7c0 logging: route console output into pino 2025-12-03 13:07:47 +00:00
Peter Steinberger
7ea43b0145 fix(web): detect self number mentions in group chats 2025-12-03 12:43:20 +00:00
Peter Steinberger
6afe6f4ecb feat(web): add group chat mention support 2025-12-03 12:35:18 +00:00
Peter Steinberger
273f2b61d0 Docs: document /restart WhatsApp command 2025-12-03 12:16:51 +00:00
Peter Steinberger
0824873ffb Add /restart WhatsApp command to restart warelay 2025-12-03 12:14:32 +00:00
Peter Steinberger
8f99b13305 Pi: stream tool results faster (0.5s, flush after 5) 2025-12-03 12:08:58 +00:00
Peter Steinberger
9253702966 Pi: stream assistant text during RPC runs 2025-12-03 11:50:49 +00:00
Peter Steinberger
3958450223 Tau RPC: resolve on agent_end or exit 2025-12-03 11:34:00 +00:00
Peter Steinberger
cc596ef011 Pi: resume Tau sessions with --continue 2025-12-03 11:33:51 +00:00
Peter Steinberger
8220b11770 Tau RPC: wait for agent_end when tools run 2025-12-03 11:29:12 +00:00
Peter Steinberger
62c54cd47c Web: simplify logout message 2025-12-03 11:04:12 +00:00