This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
> **Fork** of [alexanxin/opencode-dispatch](https://github.com/alexanxin/opencode-dispatch) — security hardening and Python-only rewrite.
|
||||
|
||||
# Beyond the Terminal: The Road to a Truly Autonomous AI Agent
|
||||
|
||||
**opencode-dispatch** is a secure Telegram bridge for the [opencode CLI](https://opencode.ai). It brings the power of a 120K-star, self-hosted AI agent to your pocket—giving you "Dispatch-style" remote access without the corporate subscription or vendor lock-in.
|
||||
@@ -37,7 +39,7 @@ This repository is more than a bridge; it's a foundational layer for a persisten
|
||||
|
||||
- **[opencode CLI](https://opencode.ai)** installed — verify with `opencode --version`
|
||||
- A Telegram account
|
||||
- Python 3.10+ or Node.js
|
||||
- Python 3.10+
|
||||
- A Telegram bot token (free from [@BotFather](https://t.me/BotFather))
|
||||
|
||||
## Quick Setup
|
||||
@@ -49,31 +51,26 @@ This repository is more than a bridge; it's a foundational layer for a persisten
|
||||
|
||||
### Step 2: Install Dependencies
|
||||
|
||||
Choose Python or Node.js (both work the same):
|
||||
|
||||
**Python:**
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
**Node.js:**
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### Step 3: Configure
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Edit `.env` and add your Telegram bot token:
|
||||
Edit `.env` and set your Telegram bot token and chat ID:
|
||||
|
||||
```env
|
||||
TELEGRAM_BOT_TOKEN=your_bot_token_here
|
||||
TELEGRAM_ALLOWED_CHAT_ID=your_chat_id_here
|
||||
OPENCODE_API_URL=http://127.0.0.1:5050
|
||||
```
|
||||
|
||||
> Get your chat ID by messaging [@userinfobot](https://t.me/userinfobot) on Telegram.
|
||||
|
||||
### Step 4: Start opencode
|
||||
|
||||
```bash
|
||||
@@ -85,8 +82,9 @@ opencode serve --port 5050
|
||||
|
||||
### Step 5: Run the Bot
|
||||
|
||||
- **Python:** `python bot.py`
|
||||
- **Node.js:** `npm start`
|
||||
```bash
|
||||
python bot.py
|
||||
```
|
||||
|
||||
### Bot Commands
|
||||
|
||||
@@ -97,13 +95,17 @@ opencode serve --port 5050
|
||||
| `/working` | Check what task is currently being processed |
|
||||
| `/clear` | Clear pending messages from queue |
|
||||
|
||||
## Security Recommendations
|
||||
## Security
|
||||
|
||||
### 1. Limit workspace access
|
||||
### 1. Chat ID locking (Required)
|
||||
|
||||
The bot **requires** `TELEGRAM_ALLOWED_CHAT_ID` to be set and will refuse to start without it. This ensures only your Telegram account can interact with the bot.
|
||||
|
||||
### 2. Limit workspace access
|
||||
|
||||
Never run from your home directory (`~`) or root (`/`). opencode can access all files in the directory it's started from.
|
||||
|
||||
### 2. Password protect (Recommended)
|
||||
### 3. Password protect (Recommended)
|
||||
|
||||
Set a password to prevent unauthorized local access:
|
||||
|
||||
@@ -117,17 +119,6 @@ Then add to `.env`:
|
||||
OPENCODE_SERVER_PASSWORD=your-secret
|
||||
```
|
||||
|
||||
### 3. Restrict to your Telegram account (Highly Recommended)
|
||||
|
||||
To lock the bot so only YOU can use it:
|
||||
|
||||
1. Get your chat ID from [@userinfobot](https://t.me/userinfobot)
|
||||
2. Add to `.env`:
|
||||
|
||||
```env
|
||||
TELEGRAM_ALLOWED_CHAT_ID=your_chat_id_here
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**"Can't connect to opencode"**
|
||||
@@ -136,7 +127,7 @@ TELEGRAM_ALLOWED_CHAT_ID=your_chat_id_here
|
||||
|
||||
**"Bot isn't responding"**
|
||||
- Check your Telegram bot token in `.env`
|
||||
- Make sure the bot is running (`python bot.py` or `npm start`)
|
||||
- Make sure the bot is running (`python bot.py`)
|
||||
|
||||
**"Port already in use"**
|
||||
- Pick a different port: `opencode serve --port 5051`
|
||||
|
||||
Reference in New Issue
Block a user