telemux 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of telemux might be problematic. Click here for more details.
- telemux-1.0.1/CHANGELOG.md +171 -0
- telemux-1.0.1/LICENSE +21 -0
- telemux-1.0.1/MANIFEST.in +15 -0
- telemux-1.0.1/PKG-INFO +479 -0
- telemux-1.0.1/README.md +441 -0
- telemux-1.0.1/examples/ai-agent-question.sh +3 -0
- telemux-1.0.1/examples/deployment-approval.sh +3 -0
- telemux-1.0.1/examples/long-build-notify.sh +3 -0
- telemux-1.0.1/pyproject.toml +80 -0
- telemux-1.0.1/setup.cfg +4 -0
- telemux-1.0.1/src/telemux/__init__.py +24 -0
- telemux-1.0.1/src/telemux/cleanup.py +189 -0
- telemux-1.0.1/src/telemux/cli.py +76 -0
- telemux-1.0.1/src/telemux/config.py +78 -0
- telemux-1.0.1/src/telemux/control.py +305 -0
- telemux-1.0.1/src/telemux/installer.py +419 -0
- telemux-1.0.1/src/telemux/listener.py +345 -0
- telemux-1.0.1/src/telemux/shell_functions.sh +110 -0
- telemux-1.0.1/src/telemux.egg-info/PKG-INFO +479 -0
- telemux-1.0.1/src/telemux.egg-info/SOURCES.txt +22 -0
- telemux-1.0.1/src/telemux.egg-info/dependency_links.txt +1 -0
- telemux-1.0.1/src/telemux.egg-info/entry_points.txt +15 -0
- telemux-1.0.1/src/telemux.egg-info/requires.txt +7 -0
- telemux-1.0.1/src/telemux.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to TeleMux will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased] - v1.0.0
|
|
9
|
+
|
|
10
|
+
### Planned
|
|
11
|
+
- Production testing completion (7+ days with 3+ users)
|
|
12
|
+
- Performance benchmarking validation (1000+ messages)
|
|
13
|
+
- Security audit execution
|
|
14
|
+
- Public release announcement
|
|
15
|
+
|
|
16
|
+
## [0.9.1] - 2025-11-10
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- **Comprehensive test suite** (56 passing tests)
|
|
20
|
+
- Unit tests for message parsing, agent lookup, state management
|
|
21
|
+
- Integration tests with mocked Telegram API
|
|
22
|
+
- Security tests for command injection prevention
|
|
23
|
+
- Test coverage >70% of critical paths
|
|
24
|
+
- **Performance benchmarking tool** (`benchmark.sh`)
|
|
25
|
+
- Configurable message count and delays
|
|
26
|
+
- Success rate validation (95%+ threshold)
|
|
27
|
+
- Comprehensive logging and metrics
|
|
28
|
+
- **Security audit checklist** (`SECURITY_AUDIT.md`)
|
|
29
|
+
- 50+ checks across 13 security categories
|
|
30
|
+
- Credential management validation
|
|
31
|
+
- Command injection prevention tests
|
|
32
|
+
- **Documentation improvements**
|
|
33
|
+
- Organized docs into `docs/` folder
|
|
34
|
+
- Added emoji-free style guide
|
|
35
|
+
- Created `.env.example` template
|
|
36
|
+
- Fixed config path errors in README (9 instances)
|
|
37
|
+
- **GitHub Actions CI/CD**
|
|
38
|
+
- Automated testing on push/PR
|
|
39
|
+
- Multi-version Python support (3.8-3.12)
|
|
40
|
+
- Code linting and shellcheck
|
|
41
|
+
- Coverage reporting
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
- README.md config paths (`~/.telegram_config` → `~/.telemux/telegram_config`)
|
|
45
|
+
- Shell function installation instructions now match INSTALL.sh
|
|
46
|
+
- Missing v0.9.1 command aliases in documentation
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
- Simplified shell function installation (source from single file)
|
|
50
|
+
- Cleaned up 7 development artifact files
|
|
51
|
+
|
|
52
|
+
## [0.9.0] - 2025-11-09
|
|
53
|
+
|
|
54
|
+
### Added
|
|
55
|
+
- **Log rotation system** (`cleanup-logs.sh`)
|
|
56
|
+
- 10MB size limit with automatic archiving
|
|
57
|
+
- Archives to `message_queue/archive/YYYY-MM/`
|
|
58
|
+
- Auto-cleanup of archives older than 6 months
|
|
59
|
+
- Optional cron job installation
|
|
60
|
+
- New command: `tg-cleanup`
|
|
61
|
+
- **Health check diagnostics** (`tg-doctor`)
|
|
62
|
+
- Validates tmux, Python, dependencies
|
|
63
|
+
- Checks config file format and permissions
|
|
64
|
+
- Tests bot connection
|
|
65
|
+
- Validates chat ID format
|
|
66
|
+
- Shows message queue statistics
|
|
67
|
+
- **Enhanced error handling**
|
|
68
|
+
- Retry logic with exponential backoff (3 attempts)
|
|
69
|
+
- Separate timeout and connection error handling
|
|
70
|
+
- Better error messages for common failures
|
|
71
|
+
- Graceful degradation when Telegram unreachable
|
|
72
|
+
- Separate error log file (`telegram_errors.log`)
|
|
73
|
+
- **Dependency management**
|
|
74
|
+
- Created `requirements.txt` with pinned versions
|
|
75
|
+
- Updated INSTALL.sh to check/install dependencies
|
|
76
|
+
- Python version detection
|
|
77
|
+
- Graceful handling when pip3 not available
|
|
78
|
+
- **Enhanced logging**
|
|
79
|
+
- Configurable log levels (DEBUG/INFO/WARNING/ERROR)
|
|
80
|
+
- `TELEMUX_LOG_LEVEL` environment variable
|
|
81
|
+
- Separate error log file
|
|
82
|
+
- Multiple handlers with different levels
|
|
83
|
+
- **Migration and uninstall tools**
|
|
84
|
+
- `MIGRATE.sh` - Migrate from legacy `.team_mux` paths
|
|
85
|
+
- `UNINSTALL.sh` - Complete removal with backup option
|
|
86
|
+
- `UPDATE.sh` - Upgrade existing installations
|
|
87
|
+
|
|
88
|
+
### Fixed
|
|
89
|
+
- Documentation inconsistencies (function names, branding)
|
|
90
|
+
- Path references (updated `.team_mux` → `.telemux`)
|
|
91
|
+
- All TODOs resolved
|
|
92
|
+
|
|
93
|
+
### Changed
|
|
94
|
+
- Environment variables: `TELEGRAM_*` → `TELEMUX_TG_*`
|
|
95
|
+
- Project renamed from "Team Mux" to "TeleMux"
|
|
96
|
+
- Moved from `~/.team_mux/` to `~/.telemux/`
|
|
97
|
+
|
|
98
|
+
## [0.1.0] - 2025-11-09
|
|
99
|
+
|
|
100
|
+
### Added
|
|
101
|
+
- Initial release of TeleMux bidirectional Telegram bridge
|
|
102
|
+
- **Core Features**
|
|
103
|
+
- `tg_alert()` - Send one-way notifications to Telegram
|
|
104
|
+
- `tg_agent()` - Bidirectional agent messaging
|
|
105
|
+
- `tg_done()` - Alert when commands complete
|
|
106
|
+
- **Listener Daemon**
|
|
107
|
+
- Python daemon with long-polling
|
|
108
|
+
- Runs 24/7 in dedicated tmux session
|
|
109
|
+
- Auto-recovery on restart
|
|
110
|
+
- State management for message tracking
|
|
111
|
+
- **Message Queue System**
|
|
112
|
+
- Persistent logging of all messages
|
|
113
|
+
- Inbox files for each agent
|
|
114
|
+
- Audit trail for sent/received messages
|
|
115
|
+
- **Clean API**
|
|
116
|
+
- Session name as message ID (simple format)
|
|
117
|
+
- Formatted delivery: `message`
|
|
118
|
+
- Proper tmux injection with sleep + Enter
|
|
119
|
+
- **Control Commands**
|
|
120
|
+
- `tg-start` / `tg-stop` / `tg-restart`
|
|
121
|
+
- `tg-status` - Check listener status
|
|
122
|
+
- `tg-logs` - View logs
|
|
123
|
+
- `tg-attach` - Attach to listener session
|
|
124
|
+
- **Components**
|
|
125
|
+
- `telegram_listener.py` - Main listener daemon
|
|
126
|
+
- `telegram_control.sh` - Control script
|
|
127
|
+
- `shell_functions.sh` - Shell integration
|
|
128
|
+
- `INSTALL.sh` - Automated installer
|
|
129
|
+
- **Documentation**
|
|
130
|
+
- README.md - Complete user guide
|
|
131
|
+
- QUICKSTART.md - 5-minute setup
|
|
132
|
+
- CLAUDE.md - Technical documentation
|
|
133
|
+
- Example scripts (deployment, build, agent questions)
|
|
134
|
+
|
|
135
|
+
### Requirements
|
|
136
|
+
- tmux
|
|
137
|
+
- Python 3.6+
|
|
138
|
+
- curl
|
|
139
|
+
- Telegram bot (via @BotFather)
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Future Enhancements
|
|
144
|
+
|
|
145
|
+
### v1.1.0 (Planned)
|
|
146
|
+
- Multiple chat support (group + personal DM)
|
|
147
|
+
- Rich message formatting (markdown, buttons)
|
|
148
|
+
- Message threading/conversations
|
|
149
|
+
- Command shortcuts (/deploy, /status, etc.)
|
|
150
|
+
- Fish shell support
|
|
151
|
+
- Interactive setup wizard
|
|
152
|
+
|
|
153
|
+
### v1.2.0 (Planned)
|
|
154
|
+
- Web dashboard for message history
|
|
155
|
+
- Agent status monitoring
|
|
156
|
+
- Message analytics and insights
|
|
157
|
+
- Performance optimizations
|
|
158
|
+
|
|
159
|
+
### v2.0.0 (Planned - Multi-Platform)
|
|
160
|
+
- WhatsApp integration (Twilio API)
|
|
161
|
+
- Slack integration
|
|
162
|
+
- Discord integration
|
|
163
|
+
- Multi-user support
|
|
164
|
+
- Permission system
|
|
165
|
+
- Approval workflows
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
**Repository:** https://github.com/maarco/telemux
|
|
170
|
+
**License:** MIT
|
|
171
|
+
**Maintainer:** Marco (with Claude Code)
|
telemux-1.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Marco Almazan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Include shell functions
|
|
2
|
+
include telemux/shell_functions.sh
|
|
3
|
+
|
|
4
|
+
# Include documentation
|
|
5
|
+
include README.md
|
|
6
|
+
include LICENSE
|
|
7
|
+
include CHANGELOG.md
|
|
8
|
+
|
|
9
|
+
# Include example scripts
|
|
10
|
+
recursive-include examples *.sh
|
|
11
|
+
|
|
12
|
+
# Exclude tests and development files
|
|
13
|
+
exclude tests/*
|
|
14
|
+
exclude .gitignore
|
|
15
|
+
exclude .python-version
|
telemux-1.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: telemux
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Bidirectional Telegram integration for tmux sessions - monitor commands and interact with agents
|
|
5
|
+
Author-email: Marco Almazan <marco@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/malmazan/telemux
|
|
8
|
+
Project-URL: Repository, https://github.com/malmazan/telemux
|
|
9
|
+
Project-URL: Issues, https://github.com/malmazan/telemux/issues
|
|
10
|
+
Keywords: telegram,tmux,notifications,monitoring,agent,automation
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Communications :: Chat
|
|
25
|
+
Classifier: Topic :: System :: Monitoring
|
|
26
|
+
Classifier: Topic :: System :: Systems Administration
|
|
27
|
+
Classifier: Topic :: Utilities
|
|
28
|
+
Requires-Python: >=3.7
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Dist: requests<3.0.0,>=2.25.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-mock>=3.11.1; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
36
|
+
Requires-Dist: responses>=0.23.0; extra == "dev"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# TeleMux
|
|
40
|
+
|
|
41
|
+
**Bidirectional Telegram integration for tmux sessions** - Monitor commands, interact with agents, and stay connected to your terminal from anywhere.
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- **One-way notifications**: Send alerts to Telegram when commands complete
|
|
46
|
+
- **Bidirectional communication**: Interact with tmux sessions via Telegram
|
|
47
|
+
- **Agent support**: Create interactive agents that can receive replies
|
|
48
|
+
- **Session routing**: Messages automatically delivered to the correct tmux session
|
|
49
|
+
- **Daemon-based**: Runs as a background service in tmux
|
|
50
|
+
- **Shell integration**: Simple shell functions for easy use
|
|
51
|
+
- **Secure**: Configuration files are automatically protected (chmod 600)
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
### Via pip (Recommended)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Install the package
|
|
59
|
+
pip install telemux
|
|
60
|
+
|
|
61
|
+
# Run the interactive installer
|
|
62
|
+
telemux install
|
|
63
|
+
|
|
64
|
+
# Start the listener daemon
|
|
65
|
+
telemux start
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### From source
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Clone the repository
|
|
72
|
+
git clone https://github.com/malmazan/telemux.git
|
|
73
|
+
cd telemux
|
|
74
|
+
|
|
75
|
+
# Install in development mode
|
|
76
|
+
pip install -e .
|
|
77
|
+
|
|
78
|
+
# Run the installer
|
|
79
|
+
telemux install
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Quick Start
|
|
83
|
+
|
|
84
|
+
### 1. Create a Telegram Bot
|
|
85
|
+
|
|
86
|
+
1. Open Telegram and search for [@BotFather](https://t.me/BotFather)
|
|
87
|
+
2. Send `/newbot` and follow the prompts
|
|
88
|
+
3. Save the bot token provided
|
|
89
|
+
|
|
90
|
+
### 2. Install TeleMux
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Install via pip
|
|
94
|
+
pip install telemux
|
|
95
|
+
|
|
96
|
+
# Run the interactive installer
|
|
97
|
+
telemux install
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The installer will:
|
|
101
|
+
- Check prerequisites (tmux, python3, curl)
|
|
102
|
+
- Validate your bot token
|
|
103
|
+
- Auto-detect available chats (with retry logic)
|
|
104
|
+
- Create configuration files
|
|
105
|
+
- Install shell functions
|
|
106
|
+
- Test the connection
|
|
107
|
+
|
|
108
|
+
### 3. Start the Listener
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Start the daemon
|
|
112
|
+
telemux start
|
|
113
|
+
|
|
114
|
+
# Check status
|
|
115
|
+
telemux status
|
|
116
|
+
|
|
117
|
+
# View logs
|
|
118
|
+
telemux logs
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 4. Use Shell Functions
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Send a simple notification
|
|
125
|
+
tg_alert "Build complete!"
|
|
126
|
+
|
|
127
|
+
# Send a message and receive replies
|
|
128
|
+
tg_agent "deploy-agent" "Ready to deploy to production?"
|
|
129
|
+
# Reply via Telegram: "session-name: yes"
|
|
130
|
+
# The reply appears directly in your terminal
|
|
131
|
+
|
|
132
|
+
# Get notified when a command completes
|
|
133
|
+
npm run build && tg_done
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Commands
|
|
137
|
+
|
|
138
|
+
### Control Commands
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
telemux start # Start the listener daemon
|
|
142
|
+
telemux stop # Stop the listener daemon
|
|
143
|
+
telemux restart # Restart the listener daemon
|
|
144
|
+
telemux status # Check daemon status
|
|
145
|
+
telemux logs # View listener logs (tail -f)
|
|
146
|
+
telemux attach # Attach to the listener tmux session
|
|
147
|
+
telemux cleanup # Rotate and clean up log files
|
|
148
|
+
telemux doctor # Run health check and diagnose issues
|
|
149
|
+
telemux install # Run interactive installer
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Shortcuts
|
|
153
|
+
|
|
154
|
+
For convenience, all commands have `tg-` shortcuts:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
tg-start # Same as: telemux start
|
|
158
|
+
tg-stop # Same as: telemux stop
|
|
159
|
+
tg-status # Same as: telemux status
|
|
160
|
+
tg-logs # Same as: telemux logs
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Shell Functions
|
|
164
|
+
|
|
165
|
+
After installation, these functions are available in your shell:
|
|
166
|
+
|
|
167
|
+
### `tg_alert`
|
|
168
|
+
|
|
169
|
+
Send one-way notifications to Telegram:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
tg_alert "Message text"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Examples:**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Simple notification
|
|
179
|
+
tg_alert "Server is ready"
|
|
180
|
+
|
|
181
|
+
# Notify when command completes
|
|
182
|
+
npm install && tg_alert "Dependencies installed"
|
|
183
|
+
|
|
184
|
+
# Multiline messages
|
|
185
|
+
tg_alert "Deploy complete
|
|
186
|
+
- 50 files updated
|
|
187
|
+
- 0 errors"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### `tg_agent`
|
|
191
|
+
|
|
192
|
+
Send messages and receive replies via Telegram:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
tg_agent "agent-name" "Message text"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Examples:**
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Ask a question
|
|
202
|
+
tg_agent "deploy-agent" "Ready to deploy to production?"
|
|
203
|
+
|
|
204
|
+
# Wait for user response via Telegram
|
|
205
|
+
# User replies: "session-name: yes, proceed"
|
|
206
|
+
# Reply appears in your terminal
|
|
207
|
+
|
|
208
|
+
# Use in scripts
|
|
209
|
+
response=$(tg_agent "approval-agent" "Approve release v2.0?")
|
|
210
|
+
if [[ "$response" == *"yes"* ]]; then
|
|
211
|
+
./deploy.sh
|
|
212
|
+
fi
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### `tg_done`
|
|
216
|
+
|
|
217
|
+
Automatically notify when the previous command completes:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
npm run build && tg_done
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
This sends a notification with:
|
|
224
|
+
- Command that ran
|
|
225
|
+
- Exit code (success/failure)
|
|
226
|
+
- Timestamp
|
|
227
|
+
|
|
228
|
+
## Bidirectional Communication
|
|
229
|
+
|
|
230
|
+
TeleMux uses **session-based routing** for bidirectional communication:
|
|
231
|
+
|
|
232
|
+
### Sending Messages from Terminal
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# In tmux session named "deploy"
|
|
236
|
+
tg_agent "deploy-check" "Should I proceed with deployment?"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
This sends a message to Telegram with instructions on how to reply.
|
|
240
|
+
|
|
241
|
+
### Replying from Telegram
|
|
242
|
+
|
|
243
|
+
Reply with the format: `session-name: your message`
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
deploy: yes, proceed with deployment
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
The reply is automatically routed to the correct tmux session and appears in your terminal.
|
|
250
|
+
|
|
251
|
+
### Security
|
|
252
|
+
|
|
253
|
+
- Messages are routed **only** to existing tmux sessions
|
|
254
|
+
- User input is sanitized to prevent command injection
|
|
255
|
+
- Session names are validated before routing
|
|
256
|
+
- No session names are revealed in error messages
|
|
257
|
+
|
|
258
|
+
## Configuration
|
|
259
|
+
|
|
260
|
+
Configuration is stored in `~/.telemux/`:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
~/.telemux/
|
|
264
|
+
├── telegram_config # Bot token and chat ID (chmod 600)
|
|
265
|
+
├── telegram_listener.log # Listener daemon logs
|
|
266
|
+
├── telegram_errors.log # Error logs
|
|
267
|
+
├── message_queue/ # Message routing data
|
|
268
|
+
│ ├── outgoing.log # Sent messages
|
|
269
|
+
│ ├── incoming.log # Received messages
|
|
270
|
+
│ └── archive/ # Rotated logs
|
|
271
|
+
└── shell_functions.sh # Shell integration functions
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Environment Variables
|
|
275
|
+
|
|
276
|
+
You can override configuration with environment variables:
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
export TELEMUX_TG_BOT_TOKEN="your-bot-token"
|
|
280
|
+
export TELEMUX_TG_CHAT_ID="your-chat-id"
|
|
281
|
+
export TELEMUX_LOG_LEVEL="DEBUG" # DEBUG, INFO, WARNING, ERROR
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Log Management
|
|
285
|
+
|
|
286
|
+
Logs are automatically rotated when they exceed 10MB:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Manual log rotation
|
|
290
|
+
telemux cleanup
|
|
291
|
+
|
|
292
|
+
# Install automatic monthly cleanup
|
|
293
|
+
telemux cleanup --install-cron
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Archives are stored in `~/.telemux/message_queue/archive/` and compressed with gzip.
|
|
297
|
+
|
|
298
|
+
## Troubleshooting
|
|
299
|
+
|
|
300
|
+
### Run Health Check
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
telemux doctor
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
This checks:
|
|
307
|
+
- Prerequisites (tmux, python3)
|
|
308
|
+
- Configuration files
|
|
309
|
+
- Telegram bot connection
|
|
310
|
+
- Listener daemon status
|
|
311
|
+
- Log files
|
|
312
|
+
|
|
313
|
+
### Common Issues
|
|
314
|
+
|
|
315
|
+
**Listener won't start:**
|
|
316
|
+
```bash
|
|
317
|
+
# Check if it's already running
|
|
318
|
+
telemux status
|
|
319
|
+
|
|
320
|
+
# View logs for errors
|
|
321
|
+
telemux logs
|
|
322
|
+
|
|
323
|
+
# Restart the listener
|
|
324
|
+
telemux restart
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**Messages not being received:**
|
|
328
|
+
```bash
|
|
329
|
+
# Check listener status
|
|
330
|
+
telemux status
|
|
331
|
+
|
|
332
|
+
# Verify configuration
|
|
333
|
+
cat ~/.telemux/telegram_config
|
|
334
|
+
|
|
335
|
+
# Test bot connection
|
|
336
|
+
telemux doctor
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Shell functions not available:**
|
|
340
|
+
```bash
|
|
341
|
+
# Reload your shell configuration
|
|
342
|
+
source ~/.zshrc # or ~/.bashrc
|
|
343
|
+
|
|
344
|
+
# Verify functions are sourced
|
|
345
|
+
type tg_alert
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## Examples
|
|
349
|
+
|
|
350
|
+
### Long-Running Build Notification
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
#!/bin/bash
|
|
354
|
+
# Build script with notification
|
|
355
|
+
|
|
356
|
+
echo "Starting build..."
|
|
357
|
+
tg_alert "Build started for project-x"
|
|
358
|
+
|
|
359
|
+
npm run build
|
|
360
|
+
if [ $? -eq 0 ]; then
|
|
361
|
+
tg_alert "Build succeeded!"
|
|
362
|
+
else
|
|
363
|
+
tg_alert "Build failed! Check logs."
|
|
364
|
+
fi
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Interactive Deployment Agent
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
#!/bin/bash
|
|
371
|
+
# Deployment with approval
|
|
372
|
+
|
|
373
|
+
tg_agent "deploy-agent" "Ready to deploy v2.0 to production?"
|
|
374
|
+
|
|
375
|
+
# User responds via Telegram: "session-name: yes"
|
|
376
|
+
# Response appears in terminal
|
|
377
|
+
|
|
378
|
+
read -p "Proceed with deployment? " response
|
|
379
|
+
if [[ "$response" == *"yes"* ]]; then
|
|
380
|
+
./deploy.sh
|
|
381
|
+
tg_alert "Deployment complete!"
|
|
382
|
+
fi
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Multi-Step Workflow
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
#!/bin/bash
|
|
389
|
+
# Complex workflow with multiple checkpoints
|
|
390
|
+
|
|
391
|
+
tg_alert "Starting migration workflow..."
|
|
392
|
+
|
|
393
|
+
# Step 1: Backup
|
|
394
|
+
tg_agent "migration-agent" "Backup database before migration?"
|
|
395
|
+
# Wait for approval...
|
|
396
|
+
|
|
397
|
+
# Step 2: Migration
|
|
398
|
+
./run-migration.sh && tg_done
|
|
399
|
+
|
|
400
|
+
# Step 3: Verification
|
|
401
|
+
tg_agent "migration-agent" "Verify migration results?"
|
|
402
|
+
# Wait for verification...
|
|
403
|
+
|
|
404
|
+
tg_alert "Migration workflow complete!"
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Development
|
|
408
|
+
|
|
409
|
+
### Running Tests
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
# Install development dependencies
|
|
413
|
+
pip install -e ".[dev]"
|
|
414
|
+
|
|
415
|
+
# Run tests
|
|
416
|
+
pytest
|
|
417
|
+
|
|
418
|
+
# Run with coverage
|
|
419
|
+
pytest --cov=telemux --cov-report=term-missing
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Project Structure
|
|
423
|
+
|
|
424
|
+
```
|
|
425
|
+
telemux/
|
|
426
|
+
├── telemux/
|
|
427
|
+
│ ├── __init__.py # Package initialization
|
|
428
|
+
│ ├── cli.py # Main CLI entry point
|
|
429
|
+
│ ├── control.py # Daemon control (start, stop, status)
|
|
430
|
+
│ ├── listener.py # Telegram listener daemon
|
|
431
|
+
│ ├── installer.py # Interactive installer
|
|
432
|
+
│ ├── cleanup.py # Log rotation and cleanup
|
|
433
|
+
│ ├── config.py # Configuration management
|
|
434
|
+
│ └── shell_functions.sh # Shell integration
|
|
435
|
+
├── examples/ # Example scripts
|
|
436
|
+
├── tests/ # Test suite
|
|
437
|
+
├── pyproject.toml # Package metadata and dependencies
|
|
438
|
+
├── MANIFEST.in # Package file manifest
|
|
439
|
+
└── README.md # This file
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
## Requirements
|
|
443
|
+
|
|
444
|
+
- Python 3.7+
|
|
445
|
+
- tmux
|
|
446
|
+
- curl
|
|
447
|
+
- requests library (automatically installed)
|
|
448
|
+
|
|
449
|
+
## License
|
|
450
|
+
|
|
451
|
+
MIT License - see LICENSE file for details
|
|
452
|
+
|
|
453
|
+
## Contributing
|
|
454
|
+
|
|
455
|
+
Contributions are welcome! Please:
|
|
456
|
+
|
|
457
|
+
1. Fork the repository
|
|
458
|
+
2. Create a feature branch
|
|
459
|
+
3. Make your changes
|
|
460
|
+
4. Add tests if applicable
|
|
461
|
+
5. Submit a pull request
|
|
462
|
+
|
|
463
|
+
## Changelog
|
|
464
|
+
|
|
465
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
466
|
+
|
|
467
|
+
## Support
|
|
468
|
+
|
|
469
|
+
- GitHub Issues: https://github.com/malmazan/telemux/issues
|
|
470
|
+
- Documentation: https://github.com/malmazan/telemux
|
|
471
|
+
|
|
472
|
+
## Credits
|
|
473
|
+
|
|
474
|
+
Created by Marco Almazan
|
|
475
|
+
|
|
476
|
+
## Related Projects
|
|
477
|
+
|
|
478
|
+
- [tmux](https://github.com/tmux/tmux) - Terminal multiplexer
|
|
479
|
+
- [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) - Telegram Bot API wrapper
|