A tool to bridge local CLI applications with a remote Telegram interface.
Project description
Gramit
[!CAUTION] SECURITY WARNING: REMOTE ACCESS RISK
Gramit provides a bridge between your local machine and a remote Telegram interface. This allows remote command execution.
If you run a shell (like
/bin/bashorcmd.exe) or any interactive tool through Gramit, anyone with access to your Telegram bot (and whose Chat ID is authorized) has full control over your machine.USE ONLY IF YOU ARE HIGHLY SECURITY-AWARE.
- Never share your
GRAMIT_TELEGRAM_TOKEN.- Ensure your
GRAMIT_CHAT_IDis correctly configured to your ID only.- Be extremely cautious when bridging shells or administrative tools.
Gramit bridges a local CLI application with a remote Telegram interface. It allows you to run any long-running command on your machine and interact with it from anywhere using Telegram. While designed to be generic for any CLI, it's particularly useful for interactive AI CLIs like Gemini CLI, Claude Code, or similar tools where you want to maintain a persistent session and interact remotely.
How it Works
Gramit acts as a conduit between your local command-line application and your Telegram bot.
- Input Redirection: Any message you send to your Telegram bot is piped directly to the
stdinof the running local command. - Output Capture: All
stdoutfrom your local command is captured and sent back to you as a Telegram message. - Session Management: It maintains a persistent session, allowing for continuous interaction with your CLI application.
Setup
-
Installation
You can install Gramit using your favorite Python package manager:
Using
pip:pip install gramit
Using
pipx(Recommended for CLI tools):pipx install gramit
Using
uv:# Run without installing uvx gramit --help # Or install as a tool uv tool install gramit
-
Get a Telegram Bot Token
- Talk to the @BotFather on Telegram.
- Create a new bot and copy the token it gives you.
-
Set Environment Variables
- Create a file named
.envin the project root. - Add the following line to it, replacing
YOUR_TOKEN_HEREwith the token you just got:GRAMIT_TELEGRAM_TOKEN="YOUR_TOKEN_HERE" - You can also optionally add your Chat ID to this file (see step 4):
GRAMIT_CHAT_ID="YOUR_CHAT_ID_HERE"
- Create a file named
-
Find Your Chat ID
- The easiest way to find your chat ID is to use Gramit's built-in registration mode. Run the following command:
gramit --register - Now, send any message to your bot on Telegram. Gramit will print your Chat ID to the console and also reply with it.
- Once you have your ID, you can stop the command (
Ctrl_C).
- The easiest way to find your chat ID is to use Gramit's built-in registration mode. Run the following command:
Usage
Run gramit with your command. If you have not set GRAMIT_CHAT_ID in your .env file, you must also provide the --chat-id argument.
Basic Example:
# If GRAMIT_CHAT_ID is set in .env
gramit ping 8.8.8.8
# If GRAMIT_CHAT_ID is NOT set
gramit --chat-id YOUR_CHAT_ID ping 8.8.8.8
- Any text you send to your bot on Telegram will be piped to the
stdinof the running command. - Any
stdoutfrom the command will be sent back to you as a Telegram message.
Interactive Example (Reverse Echo):
gramit python examples/reverse_echo.py
Then, send messages to your bot on Telegram. It will echo them back in reverse.
Features:
- Upon starting, Gramit sends an initial message to Telegram indicating the command being run.
- When the orchestrated process ends, a "goodbye" message is sent to Telegram.
- Send
/quitto your bot to gracefully terminate the running command from Telegram.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions
Contributions are welcome! If you have suggestions for improvements, new features, or bug fixes, please open an issue or submit a pull request.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gramit-0.2.0.tar.gz.
File metadata
- Download URL: gramit-0.2.0.tar.gz
- Upload date:
- Size: 57.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04294ebf115ce5fd40009ec4865e1d11ae0e75dca8c5ca06ea7e9b5ee333a79e
|
|
| MD5 |
5da4472e7741ed50d55a752f57f83f14
|
|
| BLAKE2b-256 |
e88979cc7a437d2d58e2cd98851aa4a30aae6d408c8fb7572ac0d5d8df567a86
|
File details
Details for the file gramit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gramit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47e43933b10c1f9f7a7b1183f1dae405377d9bd3f8ee320f734bb66d3c89b1a9
|
|
| MD5 |
566942823d53473fb80d4f3e1f83e400
|
|
| BLAKE2b-256 |
8045607d09e9cb8d01c5c31d2ccaf42c63cdc8339b25870c55c0ea7f5f33ecbc
|