telegram-opencode-bridge-bot 0.1.2__tar.gz → 0.1.3__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.
Files changed (27) hide show
  1. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/.env.example +17 -17
  2. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/MANIFEST.in +2 -2
  3. {telegram_opencode_bridge_bot-0.1.2/telegram_opencode_bridge_bot.egg-info → telegram_opencode_bridge_bot-0.1.3}/PKG-INFO +151 -146
  4. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/README.md +7 -2
  5. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/bot.py +448 -430
  6. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/config.py +92 -92
  7. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/handlers/commands.py +943 -943
  8. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/handlers/messages.py +482 -482
  9. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/opencode/client.py +443 -443
  10. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/opencode/server.py +144 -144
  11. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/pyproject.toml +37 -37
  12. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/sessions/manager.py +342 -342
  13. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/setup.cfg +4 -4
  14. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3/telegram_opencode_bridge_bot.egg-info}/PKG-INFO +151 -146
  15. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/utils/formatting.py +218 -218
  16. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/handlers/__init__.py +0 -0
  17. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/list_session_models.py +0 -0
  18. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/opencode/__init__.py +0 -0
  19. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/requirements.txt +0 -0
  20. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/sessions/__init__.py +0 -0
  21. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/telegram_opencode_bridge_bot.egg-info/SOURCES.txt +0 -0
  22. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/telegram_opencode_bridge_bot.egg-info/dependency_links.txt +0 -0
  23. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/telegram_opencode_bridge_bot.egg-info/entry_points.txt +0 -0
  24. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/telegram_opencode_bridge_bot.egg-info/requires.txt +0 -0
  25. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/telegram_opencode_bridge_bot.egg-info/top_level.txt +0 -0
  26. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/utils/__init__.py +0 -0
  27. {telegram_opencode_bridge_bot-0.1.2 → telegram_opencode_bridge_bot-0.1.3}/utils/security.py +0 -0
@@ -1,17 +1,17 @@
1
- # Telegram Bot Configuration
2
- TELEGRAM_BOT_TOKEN=your_bot_token_from_botfather
3
- AUTHORIZED_USERS=123456789,987654321
4
-
5
- # OpenCode Configuration
6
- OPENCODE_SERVER_URL=http://localhost:4096
7
- OPENCODE_SERVER_USERNAME=
8
- OPENCODE_SERVER_PASSWORD=
9
- OPENCODE_MODEL=anthropic/claude-sonnet-4
10
- OPENCODE_WORK_DIR=.
11
-
12
- # Limits
13
- MAX_MESSAGE_LENGTH=4000
14
- RESPONSE_TIMEOUT=0 # Set to 0 to disable request timeouts entirely
15
-
16
- # Database
17
- DB_PATH=sessions.db
1
+ # Telegram Bot Configuration
2
+ TELEGRAM_BOT_TOKEN=your_bot_token_from_botfather
3
+ AUTHORIZED_USERS=123456789,987654321
4
+
5
+ # OpenCode Configuration
6
+ OPENCODE_SERVER_URL=http://localhost:4096
7
+ OPENCODE_SERVER_USERNAME=
8
+ OPENCODE_SERVER_PASSWORD=
9
+ OPENCODE_MODEL=opencode/deepseek-v4-flash-free
10
+ OPENCODE_WORK_DIR=.
11
+
12
+ # Limits
13
+ MAX_MESSAGE_LENGTH=4000
14
+ RESPONSE_TIMEOUT=0 # Set to 0 to disable request timeouts entirely
15
+
16
+ # Database
17
+ DB_PATH=sessions.db
@@ -1,3 +1,3 @@
1
- include .env.example
2
- include README.md
1
+ include .env.example
2
+ include README.md
3
3
  include requirements.txt
@@ -1,146 +1,151 @@
1
- Metadata-Version: 2.4
2
- Name: telegram-opencode-bridge-bot
3
- Version: 0.1.2
4
- Summary: A Telegram bot that bridges messages directly to OpenCode — an AI coding agent running on your machine
5
- Author-email: MaheshNagabhairava <maheshnagabhirava12345@gmail.com>
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/MaheshNagabhairava/telegram-opencode-bridge-bot
8
- Keywords: telegram,bot,opencode,ai,coding,bridge
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.10
12
- Description-Content-Type: text/markdown
13
- Requires-Dist: python-telegram-bot[ext]>=21.0
14
- Requires-Dist: aiohttp>=3.9.0
15
- Requires-Dist: python-dotenv>=1.0.0
16
- Requires-Dist: aiosqlite>=0.19.0
17
-
18
- # 🤖 Telegram → OpenCode Bridge Bot
19
-
20
- A lightweight Python bot that bridges your Telegram messages directly to [OpenCode](https://opencode.ai) — an AI coding agent running on your machine. Think of it as having Claude/GPT-powered coding assistance right in your pocket via Telegram.
21
-
22
- ## ✨ Features
23
-
24
- - **Direct OpenCode integration** — routes your messages to OpenCode's HTTP API
25
- - **Persistent sessions** — conversations maintain context across messages
26
- - **Session management** — create, switch, list, and share sessions
27
- - **Model switching** — change AI models on the fly (`/model`)
28
- - **Plan/Build modes** — toggle between read-only analysis and full execution
29
- - **Smart formatting** — code blocks with syntax highlighting in Telegram
30
- - **Auto message splitting** — handles responses longer than Telegram's 4096 char limit
31
- - **Security** — whitelist-based access control + rate limiting
32
- - **Workspace Switching** — Switching from one workspace to another
33
-
34
- ## 📋 Prerequisites
35
-
36
- 1. **Python 3.10+**
37
- 2. **OpenCode CLI** — install via:
38
- ```bash
39
- npm install -g opencode-ai
40
- # or
41
- curl -fsSL https://opencode.ai/install | bash
42
- ```
43
- 3. **Telegram Bot Token** — get one from [@BotFather](https://t.me/BotFather)
44
- 4. **Your Telegram User ID** — send `/id` to the bot after setup, or use [@userinfobot](https://t.me/userinfobot)
45
-
46
- ## 🚀 Quick Start
47
-
48
- ### 1. Clone & Install
49
-
50
- ```bash
51
- cd telegram-opencode-bot
52
- pip install -r requirements.txt
53
- ```
54
-
55
- ### 2. Run the Bot
56
-
57
- ```bash
58
- python bot.py
59
- python bot.py --env (use --env flag if u want to re-configure later anytime)
60
- ```
61
- > **💡 Tip:** Don't know your Telegram user ID? Start the bot with `AUTHORIZED_USERS=0` temporarily, send `/id` to the bot, then update the `.env` with your real ID.
62
-
63
- ### 3. Chat!
64
-
65
- Open Telegram, find your bot, and start asking! 🎉
66
-
67
- ## 📱 Commands
68
-
69
- | Command | Description |
70
- |---------|-------------|
71
- | `/start` | Welcome message & connection check |
72
- | `/help` | Show all commands |
73
- | `/new` | Start a fresh conversation |
74
- | `/sessions` | List your recent sessions |
75
- | `/switch <id>` | Switch to a different session |
76
- | `/model <name>` | Change AI model(ex: /model opencode/deepseek-v4-flash-free) |
77
- | `/mode <plan\|build>` | Toggle plan/build mode |
78
- | `/share` | Share current session (public URL) |
79
- | `/status` | Check connection & session details |
80
- | `/id` | Show your Telegram user ID |
81
- | `/stop` | Abort active model processing |
82
- | `/models` | List all available models |
83
- | `/project` | To view the current workspace, sub folder workspaces and to change the workspace (ex: /project 2)|
84
- | `/project depth <1to5>` | Depth level recursive check for subfolders (ex: if u give depth 2, only 2 sub folders it will show from root) |
85
- | `/enable` | To enable the streaming |
86
- | `/disable` | To disable the streaming |
87
-
88
- ## 🏗️ Architecture
89
-
90
- ```
91
- Telegram User
92
-
93
-
94
- Telegram Bot (Python)
95
-
96
- ├──► OpenCode HTTP API (localhost:4096) ← primary
97
-
98
- ├──► LLM Provider (Claude/GPT/Gemini)
99
- └──► Local Filesystem & Shell
100
- ```
101
-
102
- ## ⚙️ Configuration
103
-
104
- | Variable | Description | Default |
105
- |----------|-------------|---------|
106
- | `TELEGRAM_BOT_TOKEN` | Bot token from @BotFather | **Required** |
107
- | `AUTHORIZED_USERS` | Comma-separated Telegram user IDs | **Required** |
108
- | `OPENCODE_SERVER_URL` | OpenCode HTTP API URL | `http://localhost:4096` |
109
- | `OPENCODE_SERVER_USERNAME` | OpenCode auth username | *(empty)* |
110
- | `OPENCODE_SERVER_PASSWORD` | OpenCode auth password | *(empty)* |
111
- | `OPENCODE_MODEL` | Default AI model | `anthropic/claude-sonnet-4` |
112
- | `OPENCODE_WORK_DIR` | Working directory for OpenCode | `.` |
113
- | `MAX_MESSAGE_LENGTH` | Max Telegram message length | `4000` |
114
- | `RESPONSE_TIMEOUT` | Max wait for response (seconds) | `0` |
115
- | `DB_PATH` | SQLite database path | `sessions.db` |
116
-
117
- ## 🔒 Security
118
-
119
- - **User whitelist** only Telegram user IDs in `AUTHORIZED_USERS` can use the bot
120
- - **Rate limiting** 20 requests per minute per user (configurable)
121
- - **No public exposure** — designed to run on your local machine
122
-
123
- > ⚠️ **Warning:** This bot executes AI-driven code on your machine. Only authorize trusted users.
124
-
125
- ## 📁 Project Structure
126
-
127
- ```
128
- telegram-opencode-bot/
129
- ├── bot.py # Main entry point
130
- ├── config.py # Environment configuration
131
- ├── handlers/
132
- │ ├── commands.py # Slash command handlers
133
- │ └── messages.py # Text message → OpenCode bridge
134
- ├── opencode/
135
- ├── client.py # OpenCode HTTP API client
136
-
137
- ├── sessions/
138
- │ └── manager.py # Per-user session tracking (SQLite)
139
- ├── utils/
140
- │ ├── formatting.py # Telegram message formatting
141
- └── security.py # Auth, rate limiting, sanitization
142
- ├── .env.example # Environment template
143
- ├── requirements.txt # Python dependencies
144
- └── README.md # This file
145
- ```
146
-
1
+ Metadata-Version: 2.4
2
+ Name: telegram-opencode-bridge-bot
3
+ Version: 0.1.3
4
+ Summary: A Telegram bot that bridges messages directly to OpenCode — an AI coding agent running on your machine
5
+ Author-email: MaheshNagabhairava <maheshnagabhirava12345@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/MaheshNagabhairava/telegram-opencode-bridge-bot
8
+ Keywords: telegram,bot,opencode,ai,coding,bridge
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: python-telegram-bot[ext]>=21.0
14
+ Requires-Dist: aiohttp>=3.9.0
15
+ Requires-Dist: python-dotenv>=1.0.0
16
+ Requires-Dist: aiosqlite>=0.19.0
17
+
18
+ # 🤖 Telegram → OpenCode Bridge Bot
19
+
20
+ A lightweight Python bot that bridges your Telegram messages directly to [OpenCode](https://opencode.ai) — an AI coding agent running on your machine. Think of it as having Claude/GPT-powered coding assistance right in your pocket via Telegram.
21
+
22
+ ## ✨ Features
23
+
24
+ - **Direct OpenCode integration** — routes your messages to OpenCode's HTTP API
25
+ - **Persistent sessions** — conversations maintain context across messages
26
+ - **Session management** — create, switch, list, and share sessions
27
+ - **Model switching** — change AI models on the fly (`/model`)
28
+ - **Plan/Build modes** — toggle between read-only analysis and full execution
29
+ - **Smart formatting** — code blocks with syntax highlighting in Telegram
30
+ - **Auto message splitting** — handles responses longer than Telegram's 4096 char limit
31
+ - **Security** — whitelist-based access control + rate limiting
32
+ - **Workspace Switching** — Switching from one workspace to another
33
+
34
+ ## 📋 Prerequisites
35
+
36
+ 1. **Python 3.10+**
37
+ 2. **OpenCode CLI** — install via:
38
+ ```bash
39
+ npm install -g opencode-ai
40
+ # or
41
+ curl -fsSL https://opencode.ai/install | bash
42
+ ```
43
+ 3. **Telegram Bot Token** — get one from [@BotFather](https://t.me/BotFather)
44
+ 4. **Your Telegram User ID** — send `/id` to the bot after setup, or use [@userinfobot](https://t.me/userinfobot)
45
+
46
+ ### Quick Installation:
47
+ ```bash
48
+ pip install telegram-opencode-bridge-bot==0.1.2
49
+ telegram-opencode-bot
50
+ telegram-opencode-bot --env (use --env flag if u want to re-configure later anytime)
51
+ ```
52
+ ### Manuall Installation:
53
+ ### 1. Clone & Install
54
+
55
+ ```bash
56
+ cd telegram-opencode-bot
57
+ pip install -r requirements.txt
58
+ ```
59
+
60
+ ### 2. Run the Bot
61
+
62
+ ```bash
63
+ python bot.py
64
+ python bot.py --env (use --env flag if u want to re-configure later anytime)
65
+ ```
66
+ > **💡 Tip:** Don't know your Telegram user ID? Start the bot with `AUTHORIZED_USERS=0` temporarily, send `/id` to the bot, then update the `.env` with your real ID.
67
+
68
+ ### 3. Chat!
69
+
70
+ Open Telegram, find your bot, and start asking! 🎉
71
+
72
+ ## 📱 Commands
73
+
74
+ | Command | Description |
75
+ |---------|-------------|
76
+ | `/start` | Welcome message & connection check |
77
+ | `/help` | Show all commands |
78
+ | `/new` | Start a fresh conversation |
79
+ | `/sessions` | List your recent sessions |
80
+ | `/switch <id>` | Switch to a different session |
81
+ | `/model <name>` | Change AI model(ex: /model opencode/deepseek-v4-flash-free) |
82
+ | `/mode <plan\|build>` | Toggle plan/build mode |
83
+ | `/share` | Share current session (public URL) |
84
+ | `/status` | Check connection & session details |
85
+ | `/id` | Show your Telegram user ID |
86
+ | `/stop` | Abort active model processing |
87
+ | `/models` | List all available models |
88
+ | `/project` | To view the current workspace, sub folder workspaces and to change the workspace (ex: /project 2)|
89
+ | `/project depth <1to5>` | Depth level recursive check for subfolders (ex: if u give depth 2, only 2 sub folders it will show from root) |
90
+ | `/enable` | To enable the streaming |
91
+ | `/disable` | To disable the streaming |
92
+
93
+ ## 🏗️ Architecture
94
+
95
+ ```
96
+ Telegram User
97
+
98
+
99
+ Telegram Bot (Python)
100
+
101
+ ├──► OpenCode HTTP API (localhost:4096) ← primary
102
+
103
+ ├──► LLM Provider (Claude/GPT/Gemini)
104
+ └──► Local Filesystem & Shell
105
+ ```
106
+
107
+ ## ⚙️ Configuration
108
+
109
+ | Variable | Description | Default |
110
+ |----------|-------------|---------|
111
+ | `TELEGRAM_BOT_TOKEN` | Bot token from @BotFather | **Required** |
112
+ | `AUTHORIZED_USERS` | Comma-separated Telegram user IDs | **Required** |
113
+ | `OPENCODE_SERVER_URL` | OpenCode HTTP API URL | `http://localhost:4096` |
114
+ | `OPENCODE_SERVER_USERNAME` | OpenCode auth username | *(empty)* |
115
+ | `OPENCODE_SERVER_PASSWORD` | OpenCode auth password | *(empty)* |
116
+ | `OPENCODE_MODEL` | Default AI model | `anthropic/claude-sonnet-4` |
117
+ | `OPENCODE_WORK_DIR` | Working directory for OpenCode | `.` |
118
+ | `MAX_MESSAGE_LENGTH` | Max Telegram message length | `4000` |
119
+ | `RESPONSE_TIMEOUT` | Max wait for response (seconds) | `0` |
120
+ | `DB_PATH` | SQLite database path | `sessions.db` |
121
+
122
+ ## 🔒 Security
123
+
124
+ - **User whitelist** — only Telegram user IDs in `AUTHORIZED_USERS` can use the bot
125
+ - **Rate limiting** — 20 requests per minute per user (configurable)
126
+ - **No public exposure** — designed to run on your local machine
127
+
128
+ > ⚠️ **Warning:** This bot executes AI-driven code on your machine. Only authorize trusted users.
129
+
130
+ ## 📁 Project Structure
131
+
132
+ ```
133
+ telegram-opencode-bot/
134
+ ├── bot.py # Main entry point
135
+ ├── config.py # Environment configuration
136
+ ├── handlers/
137
+ ├── commands.py # Slash command handlers
138
+ │ └── messages.py # Text message OpenCode bridge
139
+ ├── opencode/
140
+ │ ├── client.py # OpenCode HTTP API client
141
+
142
+ ├── sessions/
143
+ │ └── manager.py # Per-user session tracking (SQLite)
144
+ ├── utils/
145
+ │ ├── formatting.py # Telegram message formatting
146
+ │ └── security.py # Auth, rate limiting, sanitization
147
+ ├── .env.example # Environment template
148
+ ├── requirements.txt # Python dependencies
149
+ └── README.md # This file
150
+ ```
151
+
@@ -26,8 +26,13 @@ A lightweight Python bot that bridges your Telegram messages directly to [OpenCo
26
26
  3. **Telegram Bot Token** — get one from [@BotFather](https://t.me/BotFather)
27
27
  4. **Your Telegram User ID** — send `/id` to the bot after setup, or use [@userinfobot](https://t.me/userinfobot)
28
28
 
29
- ## 🚀 Quick Start
30
-
29
+ ### Quick Installation:
30
+ ```bash
31
+ pip install telegram-opencode-bridge-bot==0.1.2
32
+ telegram-opencode-bot
33
+ telegram-opencode-bot --env (use --env flag if u want to re-configure later anytime)
34
+ ```
35
+ ### Manuall Installation:
31
36
  ### 1. Clone & Install
32
37
 
33
38
  ```bash