TeleCLI is a web-based terminal interface that allows users to interact with command-line sessions through a web browser or Telegram bot. It provides isolated terminal sessions, supports multiple users, and includes optional AI proxy features for automated terminal interactions.
- Web Interface: Access terminal sessions via a modern web UI with WebSocket support
- Telegram Bot Integration: Control terminals through Telegram messages
- Session Management: Isolated terminal sessions per user with configurable timeouts
- Security: Authentication tokens, command whitelisting, and user restrictions
- AI Proxy: Optional AI-powered automation for terminal interactions (supports Gemini, Claude, GitHub models)
- Logging: Comprehensive logging with rotation and multiple output options
- Async Architecture: Built with FastAPI for high performance and scalability
- Python 3.10 or higher
- Linux/macOS/Windows (Linux recommended for full terminal compatibility)
- Telegram Bot Token (optional, for Telegram integration)
-
Clone the repository:
git clone <repository-url> cd telecli
-
Set up configuration:
cp .env.sample .env # Edit .env with your settings (see Configuration section below) -
Run the setup script (recommended):
./run_web.sh
This will:
- Create a Python virtual environment
- Install all dependencies
- Start the web server
- Start the Telegram bot when
TELEGRAM_BOT_TOKENis configured
Or install manually:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
TeleCLI uses environment variables for configuration. Copy .env.sample to .env and configure the following key settings:
TELEGRAM_BOT_TOKEN: Your Telegram bot token (get from @BotFather)AUTH_TOKEN: Authentication token for WebSocket connections
WEB_HOST: Host to bind the web server (default: 127.0.0.1)WEB_PORT: Port for the web server (default: 8000)LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)TERMINAL_SHELL: Default shell (default: bash)ALLOWED_COMMANDS_ONLY: Enable command whitelisting (true/false)AI_PROXY_ENABLED: Enable AI proxy features (true/false)
See .env.sample for all available configuration options.
Use the provided script:
./run_web.shOr run directly:
source venv/bin/activate
python -m src.mainThe application will start both the web server and Telegram bot (if configured).
When TELEGRAM_WEBHOOK_URL is configured, the combined src.main entrypoint starts only the web server to avoid binding WEB_PORT twice; run the Telegram bot separately for webhook deployments.
When running from a git worktree, run_web.sh will also accept a shared .env from a parent checkout directory.
For production, consider using a process manager like systemd or Docker. The application supports SSL certificates via WEB_SSL_CERT and WEB_SSL_KEY.
- Web Interface: Open
http://localhost:8000(or your configured host/port) - Telegram Bot: Send messages to your bot (if configured)
Run the test suite with pytest:
source venv/bin/activate
pytest tests/Run browser-based tests:
python run_playwright_tests.pyThis will install Playwright browsers if needed and run the full test suite.
Generate coverage reports:
pytest --cov=src --cov-report=html tests/- Always work on feature branches:
feature/descriptionorfix/description - Never commit directly to
main - Follow the pre-commit checklist:
- All tests pass (
pytest tests/) - Code is on a feature branch
- No hardcoded secrets/tokens/paths
- Branch name indicates feature/fix
- All tests pass (
src/: Main application codetests/: Test filesstatic/: Web assets (HTML, CSS)examples/: Sample configuration filesdocs/: Documentation and plans
web_app.py: FastAPI application with WebSocket endpointstelegram_bot.py: Telegram bot handlerterminal.py: Terminal session management with pexpectsession_manager.py: User session lifecycle managementai_proxy.py: AI-powered terminal automationconfig.py: Configuration management with Pydantic
- Use strong authentication tokens
- Enable command whitelisting for production
- Configure user restrictions via
ALLOWED_TELEGRAM_USERS - Keep dependencies updated
- Monitor logs for suspicious activity
- Permission denied on terminal commands: Ensure the application has proper permissions or use
sudocarefully - WebSocket connection fails: Check
AUTH_TOKENand firewall settings - Telegram bot not responding: Verify
TELEGRAM_BOT_TOKENand webhook configuration - AI proxy errors: Check API keys and provider configuration
Check logs in ./logs/ directory. Log level can be adjusted in .env.
- Follow the Git workflow guidelines
- Write tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PRs
[Add license information here]