telemux 1.0.1__py3-none-any.whl

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.

@@ -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
@@ -0,0 +1,14 @@
1
+ telemux/__init__.py,sha256=NPsaDXPUdx3Vr5f-sAEwO4NCCsj1xSFrkFPdIR2zPBE,528
2
+ telemux/cleanup.py,sha256=bR3xRPnDieciLae1mosvZIqPb4w4esByVwLHFz-pV4I,5157
3
+ telemux/cli.py,sha256=FyxN0KT0z0JhfLZgATfUbaBQ10BTfRYtUdfvOFdtQ3E,2571
4
+ telemux/config.py,sha256=tRmrbgW-7tBpLhSSh21H_cdKOlYh2dFX-KFvlldGcnQ,2128
5
+ telemux/control.py,sha256=VdmmqnfehGhYNBWpITvqxGO4IXaWf2IFurNjF-4IjAI,9410
6
+ telemux/installer.py,sha256=tOtZGWAkKmY1NS2vt27QK_kNvh7t49Jngua9D_pO6nM,13667
7
+ telemux/listener.py,sha256=7RCexHSgzqoRVmDMto3WChHtyRKct59VTcyOl376jeM,11897
8
+ telemux/shell_functions.sh,sha256=j-uDRKlvEd_tVU4PmsMuf8NKmKUtnCd6VRZ3aELcio8,3476
9
+ telemux-1.0.1.dist-info/licenses/LICENSE,sha256=dDp-Qt-v7Zi0aUHsgKxLdeWcP-qO-BtCmtP5T43Z6VI,1070
10
+ telemux-1.0.1.dist-info/METADATA,sha256=1B0LX2PFtZZ0CS-XEvoWu-nWUQUEeY--IYheT_w_trA,10926
11
+ telemux-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ telemux-1.0.1.dist-info/entry_points.txt,sha256=mxK4w1flc7W4lj4tAHyDr4k_KOWmwmuqXw3cWmMZ7Dw,527
13
+ telemux-1.0.1.dist-info/top_level.txt,sha256=VSZ88IJhbt7XXwzMYBbFQMuXy-Q01JkzFXKn8ELixYw,8
14
+ telemux-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,15 @@
1
+ [console_scripts]
2
+ telemux = telemux.cli:main
3
+ telemux-attach = telemux.control:attach
4
+ telemux-cleanup = telemux.cleanup:main
5
+ telemux-doctor = telemux.control:doctor
6
+ telemux-install = telemux.installer:main
7
+ telemux-logs = telemux.control:logs
8
+ telemux-restart = telemux.control:restart
9
+ telemux-start = telemux.control:start
10
+ telemux-status = telemux.control:status
11
+ telemux-stop = telemux.control:stop
12
+ tg-logs = telemux.control:logs
13
+ tg-start = telemux.control:start
14
+ tg-status = telemux.control:status
15
+ tg-stop = telemux.control:stop
@@ -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 @@
1
+ telemux