cliclaw 1.0.3 → 1.0.6
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.
- package/.env.example +16 -16
- package/README.md +241 -241
- package/README.pt.md +241 -241
- package/bin/cli.js +374 -283
- package/ecosystem.config.js +25 -25
- package/index.ts +28 -28
- package/package.json +48 -48
- package/src/admin.ts +148 -148
- package/src/agents/claude.ts +92 -69
- package/src/agents/codex.ts +74 -59
- package/src/config.ts +87 -75
- package/src/handlers/commands.ts +280 -280
- package/src/handlers/messages.ts +126 -115
- package/src/i18n.ts +207 -207
- package/src/storage.ts +142 -142
- package/src/telegram.ts +75 -75
- package/src/utils/markdown.ts +76 -76
- package/tsconfig.json +29 -29
package/.env.example
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# Token do bot (obter no @BotFather)
|
|
2
|
-
TELEGRAM_BOT_TOKEN=
|
|
3
|
-
|
|
4
|
-
# ID do grupo com Forum/Topics ativado (usar /id no grupo)
|
|
5
|
-
FORUM_GROUP_ID=
|
|
6
|
-
|
|
7
|
-
# Anthropic API Key (opcional — o bot usa OAuth do Claude Code CLI)
|
|
8
|
-
# Deixar em branco se fizer login via: claude (abre link OAuth)
|
|
9
|
-
ANTHROPIC_API_KEY=
|
|
10
|
-
|
|
11
|
-
# OpenAI API Key (opcional — o bot usa o Codex CLI logado)
|
|
12
|
-
# Deixar em branco se já logado via: codex login
|
|
13
|
-
OPENAI_API_KEY=
|
|
14
|
-
|
|
15
|
-
# Pasta de dados (padrão: ~/openclaw/data)
|
|
16
|
-
DATA_DIR=
|
|
1
|
+
# Token do bot (obter no @BotFather)
|
|
2
|
+
TELEGRAM_BOT_TOKEN=
|
|
3
|
+
|
|
4
|
+
# ID do grupo com Forum/Topics ativado (usar /id no grupo)
|
|
5
|
+
FORUM_GROUP_ID=
|
|
6
|
+
|
|
7
|
+
# Anthropic API Key (opcional — o bot usa OAuth do Claude Code CLI)
|
|
8
|
+
# Deixar em branco se fizer login via: claude (abre link OAuth)
|
|
9
|
+
ANTHROPIC_API_KEY=
|
|
10
|
+
|
|
11
|
+
# OpenAI API Key (opcional — o bot usa o Codex CLI logado)
|
|
12
|
+
# Deixar em branco se já logado via: codex login
|
|
13
|
+
OPENAI_API_KEY=
|
|
14
|
+
|
|
15
|
+
# Pasta de dados (padrão: ~/openclaw/data)
|
|
16
|
+
DATA_DIR=
|
package/README.md
CHANGED
|
@@ -1,241 +1,241 @@
|
|
|
1
|
-
# 🦀 Cli-Claw
|
|
2
|
-
|
|
3
|
-
> **Cli-Claw** is a Telegram bot that acts as a **direct bridge between AI CLI tools and your phone**. Each conversation lives in a dedicated Forum Topic thread — you type from anywhere, the CLI runs on your server, the answer comes back. No API keys, no per-token billing, just your own subscription plan.
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
/new → opens a forum topic → 🟣 Claude or 🟢 Codex
|
|
7
|
-
└ each topic = one CLI session with full conversation memory
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
📖 **[Leia em Português →](README.pt.md)**
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Why a CLI bridge?
|
|
15
|
-
|
|
16
|
-
Most Telegram AI bots call HTTP APIs. Cli-Claw is different — it drives the actual CLI binaries installed on your server:
|
|
17
|
-
|
|
18
|
-
| | Cli-Claw | API-based bots |
|
|
19
|
-
|---|---|---|
|
|
20
|
-
| **Auth** | OAuth / ChatGPT login | API keys (paid per token) |
|
|
21
|
-
| **Cost** | Your subscription plan | Metered billing |
|
|
22
|
-
| **Agentic tasks** | ✅ Full tool access | ❌ Limited |
|
|
23
|
-
| **Permission control** | ✅ Per session / on demand | N/A |
|
|
24
|
-
| **Adds a new CLI** | Just install & restart | N/A |
|
|
25
|
-
|
|
26
|
-
Because it drives real CLI processes, Cli-Claw can do anything you can do in a terminal — install software, execute code, browse files, run long agentic workflows.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Supported agents
|
|
31
|
-
|
|
32
|
-
| Agent | Status | Notes |
|
|
33
|
-
|---|---|---|
|
|
34
|
-
| 🟣 **Claude Code** | ✅ Available | Requires claude.ai subscription |
|
|
35
|
-
| 🟢 **Codex** | ✅ Available | Requires OpenAI/ChatGPT account |
|
|
36
|
-
| 🔜 **OpenCode** | Coming soon | Open-source CLI, no subscription needed |
|
|
37
|
-
|
|
38
|
-
Each agent you install becomes immediately available. The bot detects which CLIs are in `PATH` on startup and shows a setup guide for anything not yet configured.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Bot commands
|
|
43
|
-
|
|
44
|
-
| English | Portuguese | Description |
|
|
45
|
-
|---|---|---|
|
|
46
|
-
| `/new` | `/nova` | New Claude session (creates a forum topic) |
|
|
47
|
-
| `/new codex` | `/nova codex` | New Codex session |
|
|
48
|
-
| `/sessions` | `/sessoes` | List all sessions |
|
|
49
|
-
| `/clear` | `/limpar` | Reset current session / topic |
|
|
50
|
-
| `/status` | `/status` | Active session info |
|
|
51
|
-
| `/id` | `/id` | Show this chat ID |
|
|
52
|
-
| `/help` | `/ajuda` | Show help message |
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Requirements
|
|
57
|
-
|
|
58
|
-
- **Ubuntu 22+** (tested on Oracle Cloud ARM64)
|
|
59
|
-
- **Node.js 22+**
|
|
60
|
-
- **Claude Code CLI** authenticated via OAuth (`claude`) — *optional, add to unlock 🟣*
|
|
61
|
-
- **Codex CLI** authenticated via ChatGPT (`codex login`) — *optional, add to unlock 🟢*
|
|
62
|
-
- A Telegram **group** with **Topics enabled**, bot added as **admin**
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## Installation
|
|
67
|
-
|
|
68
|
-
### 1. Clone and install
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
git clone https://github.com/luizfeer/cliclaw.git
|
|
72
|
-
cd cliclaw
|
|
73
|
-
npm install
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### 2. Install Node.js 22 (if needed)
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
80
|
-
sudo apt-get install -y nodejs
|
|
81
|
-
npm install -g tsx pm2
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 3. Install AI CLIs
|
|
85
|
-
|
|
86
|
-
Install at least one. You can add more later — just restart the bot.
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
# Set up npm global prefix (no sudo)
|
|
90
|
-
mkdir -p ~/.npm-global
|
|
91
|
-
npm config set prefix ~/.npm-global
|
|
92
|
-
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
|
|
93
|
-
|
|
94
|
-
# 🟣 Claude Code (requires claude.ai subscription)
|
|
95
|
-
npm install -g @anthropic-ai/claude-code
|
|
96
|
-
claude # opens OAuth link in your browser
|
|
97
|
-
|
|
98
|
-
# 🟢 Codex (requires OpenAI/ChatGPT account)
|
|
99
|
-
npm install -g @openai/codex
|
|
100
|
-
codex login
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
> **Don't have either yet?** That's fine — install the bot first, then send `/start` in Telegram. The bot will show exactly what to run.
|
|
104
|
-
|
|
105
|
-
### 4. Configure
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
cp .env.example .env
|
|
109
|
-
nano .env
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
```env
|
|
113
|
-
TELEGRAM_BOT_TOKEN= # from @BotFather → /newbot
|
|
114
|
-
FORUM_GROUP_ID= # run /id inside your group to get it
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 5. Choose a permission mode
|
|
118
|
-
|
|
119
|
-
Add `PERMISSION_MODE` to your `.env`:
|
|
120
|
-
|
|
121
|
-
| Mode | Value | Behavior |
|
|
122
|
-
|---|---|---|
|
|
123
|
-
| **Full auto** *(recommended)* | `auto` | Always skips all permission prompts — models run freely |
|
|
124
|
-
| **Per session** | `session` | Bot asks when you run `/new`: *"Allow full auto for this session?"* |
|
|
125
|
-
| **On demand** | `ask` | Restricted by default; prefix any message with `!` to grant full auto for that message only |
|
|
126
|
-
|
|
127
|
-
```env
|
|
128
|
-
PERMISSION_MODE=auto
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 6. Set up Telegram group
|
|
132
|
-
|
|
133
|
-
1. Create a Telegram group
|
|
134
|
-
2. **Edit group → Topics → Enable**
|
|
135
|
-
3. Add your bot as **Admin** with *Manage Topics* permission
|
|
136
|
-
4. Send `/id` in the group and copy the Chat ID
|
|
137
|
-
5. Paste it as `FORUM_GROUP_ID` in `.env`
|
|
138
|
-
|
|
139
|
-
### 7. Start
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
# Test run
|
|
143
|
-
npx tsx index.ts
|
|
144
|
-
|
|
145
|
-
# Production — auto-restarts on crash and reboot
|
|
146
|
-
pm2 start ecosystem.config.js
|
|
147
|
-
pm2 save && pm2 startup
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## How it works
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
Message in forum topic
|
|
156
|
-
↓
|
|
157
|
-
Resolve session by thread_id
|
|
158
|
-
↓
|
|
159
|
-
Lock session (prevent concurrent processes)
|
|
160
|
-
↓
|
|
161
|
-
Send "⚙️ Processing..." + typing loop every 4s
|
|
162
|
-
↓
|
|
163
|
-
Spawn CLI based on PERMISSION_MODE:
|
|
164
|
-
claude --resume <id> -p "msg" --output-format text
|
|
165
|
-
codex exec resume <thread> --json "msg"
|
|
166
|
-
↓
|
|
167
|
-
Process runs to completion (no kill timeout)
|
|
168
|
-
↓
|
|
169
|
-
Delete "Processing..." → send formatted HTML response
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
Session IDs are saved to `data/chat_<id>.json` — context survives bot restarts.
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## Publishing to npm *(planned)*
|
|
177
|
-
|
|
178
|
-
The goal is to make installation a single command:
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
npm install -g cliclaw
|
|
182
|
-
cliclaw setup # interactive wizard: bot token, group ID, permission mode
|
|
183
|
-
cliclaw start
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
This requires a `cli.js` setup wizard and a compiled entry point. The CLIs (`claude`, `codex`) will still need to be authenticated manually — npm can bundle the bot code but not OAuth sessions. The wizard would guide through that step.
|
|
187
|
-
|
|
188
|
-
Contributions welcome: **[github.com/luizfeer/cliclaw](https://github.com/luizfeer/cliclaw)**
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## Project structure
|
|
193
|
-
|
|
194
|
-
```
|
|
195
|
-
cliclaw/
|
|
196
|
-
├── index.ts # Entry point
|
|
197
|
-
├── ecosystem.config.js # PM2 config (uses tsx)
|
|
198
|
-
├── src/
|
|
199
|
-
│ ├── config.ts # Loads .env + detects available CLIs
|
|
200
|
-
│ ├── storage.ts # JSON session persistence
|
|
201
|
-
│ ├── agents/
|
|
202
|
-
│ │ ├── claude.ts # Claude Code CLI wrapper
|
|
203
|
-
│ │ └── codex.ts # Codex CLI wrapper
|
|
204
|
-
│ ├── handlers/
|
|
205
|
-
│ │ ├── commands.ts # /new /sessions /clear etc.
|
|
206
|
-
│ │ └── messages.ts # Routes by thread_id, typing loop, lock
|
|
207
|
-
│ └── utils/
|
|
208
|
-
│ └── markdown.ts # Markdown → Telegram HTML
|
|
209
|
-
├── data/ # Session JSON files (git-ignored)
|
|
210
|
-
├── .env # Secrets (git-ignored)
|
|
211
|
-
└── .env.example # Template
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
## Deploy to another VPS
|
|
217
|
-
|
|
218
|
-
```bash
|
|
219
|
-
git clone https://github.com/luizfeer/cliclaw.git
|
|
220
|
-
cd cliclaw && npm install
|
|
221
|
-
npm install -g tsx pm2 @anthropic-ai/claude-code @openai/codex
|
|
222
|
-
claude && codex login
|
|
223
|
-
cp .env.example .env && nano .env
|
|
224
|
-
pm2 start ecosystem.config.js && pm2 save
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
## Contributing
|
|
230
|
-
|
|
231
|
-
Cli-Claw is an open community project. PRs welcome — especially:
|
|
232
|
-
- New CLI agent adapters (OpenCode, Gemini CLI, etc.)
|
|
233
|
-
- `cliclaw setup` wizard for npm distribution
|
|
234
|
-
- i18n improvements
|
|
235
|
-
- Better permission UX
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
## License
|
|
240
|
-
|
|
241
|
-
MIT
|
|
1
|
+
# 🦀 Cli-Claw
|
|
2
|
+
|
|
3
|
+
> **Cli-Claw** is a Telegram bot that acts as a **direct bridge between AI CLI tools and your phone**. Each conversation lives in a dedicated Forum Topic thread — you type from anywhere, the CLI runs on your server, the answer comes back. No API keys, no per-token billing, just your own subscription plan.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
/new → opens a forum topic → 🟣 Claude or 🟢 Codex
|
|
7
|
+
└ each topic = one CLI session with full conversation memory
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
📖 **[Leia em Português →](README.pt.md)**
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Why a CLI bridge?
|
|
15
|
+
|
|
16
|
+
Most Telegram AI bots call HTTP APIs. Cli-Claw is different — it drives the actual CLI binaries installed on your server:
|
|
17
|
+
|
|
18
|
+
| | Cli-Claw | API-based bots |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| **Auth** | OAuth / ChatGPT login | API keys (paid per token) |
|
|
21
|
+
| **Cost** | Your subscription plan | Metered billing |
|
|
22
|
+
| **Agentic tasks** | ✅ Full tool access | ❌ Limited |
|
|
23
|
+
| **Permission control** | ✅ Per session / on demand | N/A |
|
|
24
|
+
| **Adds a new CLI** | Just install & restart | N/A |
|
|
25
|
+
|
|
26
|
+
Because it drives real CLI processes, Cli-Claw can do anything you can do in a terminal — install software, execute code, browse files, run long agentic workflows.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Supported agents
|
|
31
|
+
|
|
32
|
+
| Agent | Status | Notes |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| 🟣 **Claude Code** | ✅ Available | Requires claude.ai subscription |
|
|
35
|
+
| 🟢 **Codex** | ✅ Available | Requires OpenAI/ChatGPT account |
|
|
36
|
+
| 🔜 **OpenCode** | Coming soon | Open-source CLI, no subscription needed |
|
|
37
|
+
|
|
38
|
+
Each agent you install becomes immediately available. The bot detects which CLIs are in `PATH` on startup and shows a setup guide for anything not yet configured.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Bot commands
|
|
43
|
+
|
|
44
|
+
| English | Portuguese | Description |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| `/new` | `/nova` | New Claude session (creates a forum topic) |
|
|
47
|
+
| `/new codex` | `/nova codex` | New Codex session |
|
|
48
|
+
| `/sessions` | `/sessoes` | List all sessions |
|
|
49
|
+
| `/clear` | `/limpar` | Reset current session / topic |
|
|
50
|
+
| `/status` | `/status` | Active session info |
|
|
51
|
+
| `/id` | `/id` | Show this chat ID |
|
|
52
|
+
| `/help` | `/ajuda` | Show help message |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Requirements
|
|
57
|
+
|
|
58
|
+
- **Ubuntu 22+** (tested on Oracle Cloud ARM64)
|
|
59
|
+
- **Node.js 22+**
|
|
60
|
+
- **Claude Code CLI** authenticated via OAuth (`claude`) — *optional, add to unlock 🟣*
|
|
61
|
+
- **Codex CLI** authenticated via ChatGPT (`codex login`) — *optional, add to unlock 🟢*
|
|
62
|
+
- A Telegram **group** with **Topics enabled**, bot added as **admin**
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
### 1. Clone and install
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/luizfeer/cliclaw.git
|
|
72
|
+
cd cliclaw
|
|
73
|
+
npm install
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 2. Install Node.js 22 (if needed)
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
80
|
+
sudo apt-get install -y nodejs
|
|
81
|
+
npm install -g tsx pm2
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3. Install AI CLIs
|
|
85
|
+
|
|
86
|
+
Install at least one. You can add more later — just restart the bot.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Set up npm global prefix (no sudo)
|
|
90
|
+
mkdir -p ~/.npm-global
|
|
91
|
+
npm config set prefix ~/.npm-global
|
|
92
|
+
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
|
|
93
|
+
|
|
94
|
+
# 🟣 Claude Code (requires claude.ai subscription)
|
|
95
|
+
npm install -g @anthropic-ai/claude-code
|
|
96
|
+
claude # opens OAuth link in your browser
|
|
97
|
+
|
|
98
|
+
# 🟢 Codex (requires OpenAI/ChatGPT account)
|
|
99
|
+
npm install -g @openai/codex
|
|
100
|
+
codex login
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
> **Don't have either yet?** That's fine — install the bot first, then send `/start` in Telegram. The bot will show exactly what to run.
|
|
104
|
+
|
|
105
|
+
### 4. Configure
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
cp .env.example .env
|
|
109
|
+
nano .env
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```env
|
|
113
|
+
TELEGRAM_BOT_TOKEN= # from @BotFather → /newbot
|
|
114
|
+
FORUM_GROUP_ID= # run /id inside your group to get it
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 5. Choose a permission mode
|
|
118
|
+
|
|
119
|
+
Add `PERMISSION_MODE` to your `.env`:
|
|
120
|
+
|
|
121
|
+
| Mode | Value | Behavior |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| **Full auto** *(recommended)* | `auto` | Always skips all permission prompts — models run freely |
|
|
124
|
+
| **Per session** | `session` | Bot asks when you run `/new`: *"Allow full auto for this session?"* |
|
|
125
|
+
| **On demand** | `ask` | Restricted by default; prefix any message with `!` to grant full auto for that message only |
|
|
126
|
+
|
|
127
|
+
```env
|
|
128
|
+
PERMISSION_MODE=auto
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 6. Set up Telegram group
|
|
132
|
+
|
|
133
|
+
1. Create a Telegram group
|
|
134
|
+
2. **Edit group → Topics → Enable**
|
|
135
|
+
3. Add your bot as **Admin** with *Manage Topics* permission
|
|
136
|
+
4. Send `/id` in the group and copy the Chat ID
|
|
137
|
+
5. Paste it as `FORUM_GROUP_ID` in `.env`
|
|
138
|
+
|
|
139
|
+
### 7. Start
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Test run
|
|
143
|
+
npx tsx index.ts
|
|
144
|
+
|
|
145
|
+
# Production — auto-restarts on crash and reboot
|
|
146
|
+
pm2 start ecosystem.config.js
|
|
147
|
+
pm2 save && pm2 startup
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## How it works
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
Message in forum topic
|
|
156
|
+
↓
|
|
157
|
+
Resolve session by thread_id
|
|
158
|
+
↓
|
|
159
|
+
Lock session (prevent concurrent processes)
|
|
160
|
+
↓
|
|
161
|
+
Send "⚙️ Processing..." + typing loop every 4s
|
|
162
|
+
↓
|
|
163
|
+
Spawn CLI based on PERMISSION_MODE:
|
|
164
|
+
claude --resume <id> -p "msg" --output-format text
|
|
165
|
+
codex exec resume <thread> --json "msg"
|
|
166
|
+
↓
|
|
167
|
+
Process runs to completion (no kill timeout)
|
|
168
|
+
↓
|
|
169
|
+
Delete "Processing..." → send formatted HTML response
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Session IDs are saved to `data/chat_<id>.json` — context survives bot restarts.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Publishing to npm *(planned)*
|
|
177
|
+
|
|
178
|
+
The goal is to make installation a single command:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm install -g cliclaw
|
|
182
|
+
cliclaw setup # interactive wizard: bot token, group ID, permission mode
|
|
183
|
+
cliclaw start
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
This requires a `cli.js` setup wizard and a compiled entry point. The CLIs (`claude`, `codex`) will still need to be authenticated manually — npm can bundle the bot code but not OAuth sessions. The wizard would guide through that step.
|
|
187
|
+
|
|
188
|
+
Contributions welcome: **[github.com/luizfeer/cliclaw](https://github.com/luizfeer/cliclaw)**
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Project structure
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
cliclaw/
|
|
196
|
+
├── index.ts # Entry point
|
|
197
|
+
├── ecosystem.config.js # PM2 config (uses tsx)
|
|
198
|
+
├── src/
|
|
199
|
+
│ ├── config.ts # Loads .env + detects available CLIs
|
|
200
|
+
│ ├── storage.ts # JSON session persistence
|
|
201
|
+
│ ├── agents/
|
|
202
|
+
│ │ ├── claude.ts # Claude Code CLI wrapper
|
|
203
|
+
│ │ └── codex.ts # Codex CLI wrapper
|
|
204
|
+
│ ├── handlers/
|
|
205
|
+
│ │ ├── commands.ts # /new /sessions /clear etc.
|
|
206
|
+
│ │ └── messages.ts # Routes by thread_id, typing loop, lock
|
|
207
|
+
│ └── utils/
|
|
208
|
+
│ └── markdown.ts # Markdown → Telegram HTML
|
|
209
|
+
├── data/ # Session JSON files (git-ignored)
|
|
210
|
+
├── .env # Secrets (git-ignored)
|
|
211
|
+
└── .env.example # Template
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Deploy to another VPS
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
git clone https://github.com/luizfeer/cliclaw.git
|
|
220
|
+
cd cliclaw && npm install
|
|
221
|
+
npm install -g tsx pm2 @anthropic-ai/claude-code @openai/codex
|
|
222
|
+
claude && codex login
|
|
223
|
+
cp .env.example .env && nano .env
|
|
224
|
+
pm2 start ecosystem.config.js && pm2 save
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Contributing
|
|
230
|
+
|
|
231
|
+
Cli-Claw is an open community project. PRs welcome — especially:
|
|
232
|
+
- New CLI agent adapters (OpenCode, Gemini CLI, etc.)
|
|
233
|
+
- `cliclaw setup` wizard for npm distribution
|
|
234
|
+
- i18n improvements
|
|
235
|
+
- Better permission UX
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT
|