create-openclaw-bot 5.3.0 → 5.3.3
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/CHANGELOG.md +24 -0
- package/CHANGELOG.vi.md +24 -0
- package/README.md +11 -11
- package/README.vi.md +12 -4
- package/cli.js +392 -1
- package/package.json +1 -1
- package/setup.js +515 -59
- package/tests/smoke-cli-logic.mjs +8 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# Changelog (English)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [5.3.3] — 2026-04-11
|
|
5
|
+
|
|
6
|
+
### 🧹 Automated Uninstall Scripts
|
|
7
|
+
|
|
8
|
+
- **Wizard UI Generation**: The HTML setup wizard now generates a matching `uninstall-openclaw-*.bat/sh` script when downloading the configuration for Native or Docker deployments.
|
|
9
|
+
- **Complete Cleanup**: The generated scripts cleanly kill 9Router/OpenClaw background processes, uninstall global npm packages, and safely remove the project and `.9router` data directories, allowing for a fresh start whenever needed.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [5.3.2] — 2026-04-11
|
|
14
|
+
|
|
15
|
+
### 🐛 Windows Native — 9Router Launch Stability
|
|
16
|
+
|
|
17
|
+
- **Fix: Remove `-l` (stdin listen) flag from native 9Router launch** — `resolveNative9RouterDesktopLaunch()` previously passed `-l` which puts 9Router into interactive REPL mode. When spawned as a background process (no TTY), this caused the process to hang waiting for stdin input. Removed the flag; 9Router now starts reliably in the background on Windows, macOS desktop, and any non-VPS native flow.
|
|
18
|
+
- **Fix: Pre-seed `DATA_DIR/.9router/db.json` with `requireLogin: false` before 9Router starts** — If `db.json` does not exist when 9Router boots, it uses its own default path (`~/.9router`) and defaults `requireLogin` to `true`, causing the dashboard login wall. The CLI wizard now creates the `.9router` directory and writes a minimal `db.json` (with `requireLogin: false`) **before** spawning 9Router, matching the behavior of the fixed `setup-openclaw-win.bat` batch file.
|
|
19
|
+
- **No change to PM2/VPS flow** — The fix applies only to the desktop/background spawn path (`osChoice !== 'vps'`). VPS users still use the existing PM2-managed `startNative9RouterPm2` flow which is unaffected.
|
|
20
|
+
|
|
21
|
+
## [5.3.1] — 2026-04-10
|
|
22
|
+
|
|
23
|
+
### 🌟 Zalo Personal DM Policy
|
|
24
|
+
|
|
25
|
+
- **Open Zalo Inboxes**: The default `dmPolicy` for Zalo Personal deployments has been changed from `pairing` to `open`. This allows any user on the Zalo network to interact with the AI assistant immediately without requiring explicit device pairing approvals natively.
|
|
26
|
+
|
|
27
|
+
|
|
4
28
|
## [5.3.0] — 2026-04-11
|
|
5
29
|
|
|
6
30
|
### 🆕 Multi-Channel: Telegram + Zalo Personal Simultaneously
|
package/CHANGELOG.vi.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# Changelog (Tiếng Việt)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [5.3.3] — 2026-04-11
|
|
5
|
+
|
|
6
|
+
### 🧹 Tự Động Tạo Script Gỡ Cài Đặt
|
|
7
|
+
|
|
8
|
+
- **Tính Năng Wizard UI**: Giao diện HTML wizard giờ đây sẽ tự động tải thêm một file script dọn dẹp hệ thống (`uninstall-openclaw-*.bat/sh`) mỗi khi tải file cài đặt cho Native hoặc Docker.
|
|
9
|
+
- **Dọn Dẹp Triệt Để**: Các script này giúp dừng sạch sẽ các tiến trình nền của 9Router/OpenClaw, gỡ cài đặt các gói npm toàn cầu và xoá an toàn thư mục project cũng như data `.9router`, giúp bạn làm sạch máy để cài đặt lại dễ dàng.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [5.3.2] — 2026-04-11
|
|
14
|
+
|
|
15
|
+
### 🐛 Windows Native — Sửa Lỗi Khởi Động 9Router
|
|
16
|
+
|
|
17
|
+
- **Sửa: Bỏ flag `-l` (chế độ đọc stdin) khỏi lệnh launch 9Router** — `resolveNative9RouterDesktopLaunch()` trước đây truyền `-l` khiến 9Router chạy ở chế độ REPL tương tác. Khi chạy ẩn (không có TTY), tiến trình bị treo chờ stdin mà không bao giờ nhận được. Đã bỏ flag; 9Router giờ khởi động ổn định ở nền trên Windows, macOS desktop và mọi luồng native không phải VPS.
|
|
18
|
+
- **Sửa: Pre-seed `DATA_DIR/.9router/db.json` với `requireLogin: false` trước khi 9Router khởi động** — Nếu `db.json` chưa tồn tại khi 9Router khởi chạy, nó dùng đường dẫn mặc định của riêng mình (`~/.9router`) và đặt `requireLogin` là `true`, gây ra màn hình login khi mở dashboard. CLI wizard giờ tạo thư mục `.9router` và ghi sẵn `db.json` (với `requireLogin: false`) **trước** khi spawn 9Router, khớp với hành vi của file `setup-openclaw-win.bat` đã được sửa.
|
|
19
|
+
- **Không thay đổi luồng PM2/VPS** — Fix chỉ áp dụng cho path spawn nền của desktop (`osChoice !== 'vps'`). Người dùng VPS vẫn dùng luồng PM2 `startNative9RouterPm2` hiện tại, không bị ảnh hưởng.
|
|
20
|
+
|
|
21
|
+
## [5.3.1] — 2026-04-10
|
|
22
|
+
|
|
23
|
+
### 🌟 Đổi Chính Sách Bảo Mật Zalo Personal
|
|
24
|
+
|
|
25
|
+
- **Thả Ga Inbox Zalo Cầm Tay**: Lược bỏ rào cản duyệt bảo mật của Zalo Personal. Thông số `dmPolicy` trên cài đặt Zalo cá nhân đã được chuyển mặc định từ `pairing` sang `open`. Bây giờ bất cứ ai trên mạng lưới Zalo nhắn tin vào tài khoản của Bot đều sẽ được AI tự động tiếp đón ngay lập tức thay vì bị chặn lại chờ bạn duyệt lệnh kết nối E2E!
|
|
26
|
+
|
|
27
|
+
|
|
4
28
|
## [5.3.0] — 2026-04-11
|
|
5
29
|
|
|
6
30
|
### 🆕 Đa Kênh: Telegram + Zalo Personal Cùng Lúc
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# 🦞 OpenClaw Setup
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<a href="https://github.com/tuanminhhole/openclaw-setup/releases"><img src="https://img.shields.io/badge/RELEASE-v5.3.
|
|
6
|
+
<a href="https://github.com/tuanminhhole/openclaw-setup/releases"><img src="https://img.shields.io/badge/RELEASE-v5.3.1-0EA5E9?style=for-the-badge" alt="Version 5.3.1" /></a>
|
|
7
7
|
<a href="https://github.com/tuanminhhole/openclaw-setup?tab=MIT-1-ov-file"><img src="https://img.shields.io/badge/LICENSE-MIT-success?style=for-the-badge" alt="MIT License" /></a>
|
|
8
8
|
<a href="https://www.npmjs.com/package/create-openclaw-bot"><img src="https://img.shields.io/npm/v/create-openclaw-bot?style=for-the-badge&label=CLI&color=2563EB&logo=npm&logoColor=white" alt="NPM Version" /></a>
|
|
9
9
|
<a href="https://github.com/tuanminhhole/openclaw-setup/stargazers"><img src="https://img.shields.io/github/stars/tuanminhhole/openclaw-setup?style=for-the-badge&color=eab308&logo=github&logoColor=white" alt="GitHub Stars" /></a>
|
|
@@ -24,19 +24,19 @@ An interactive **CLI tool** and **Setup Wizard** to deploy your own free AI Bot
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
## 🆕 What's new in v5.3.
|
|
27
|
+
## 🆕 What's new in v5.3.1
|
|
28
28
|
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
29
|
+
- 🐛 **Fix: Telegram token input missing in combo channel** — When selecting "Telegram + Zalo Personal", the wizard now shows the Telegram Bot Token input field AND the Zalo Personal warning side by side.
|
|
30
|
+
- 🐛 **Fix: Next button stuck on step 4 for combo** — Validation now correctly requires a Telegram token before enabling "Generate Configs" in combo mode.
|
|
31
|
+
- 🐛 **Fix: Windows Docker script crashes with "docker not recognized"** — The generated `.ps1` now uses `Get-Command` to locate Docker, checks that Docker Desktop is running, and calls it via `&` operator — works even when Docker isn't in the default PowerShell PATH.
|
|
32
|
+
- 🐛 **Fix: Zalo QR login instructions missing for combo in Windows script** — Post-install notes now show the `docker compose exec` login command when the combo channel is selected.
|
|
32
33
|
|
|
33
34
|
<details>
|
|
34
|
-
<summary><b>Previous: What's new in v5.
|
|
35
|
+
<summary><b>Previous: What's new in v5.3.0</b></summary>
|
|
35
36
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
- 🛡️ **All user data preserved** — `.env`, memory, sessions, credentials, and 9Router OAuth tokens are never touched during upgrade.
|
|
37
|
+
- 📱 **Telegram + Zalo Personal together** — New combo channel option lets you run one bot on both Telegram **and** Zalo Personal simultaneously, from a single config. No separate setup needed.
|
|
38
|
+
- 🔌 **Auto-inject `zalouser` plugin** — When Zalo Personal is selected, the wizard now automatically adds `plugins.entries.zalouser` to `openclaw.json`, eliminating the most common Zalo "not configured" startup error.
|
|
39
|
+
- ⏱️ **Docker cold-start fix baked in** — Dockerfile CMD now includes a background 45-second trigger that forces Zalo channel initialization after Docker network is warm. No more manual `lastTouchedAt` hacks.
|
|
40
40
|
|
|
41
41
|
</details>
|
|
42
42
|
|
|
@@ -110,7 +110,7 @@ Run in your terminal → follow the interactive prompts → startup script is ge
|
|
|
110
110
|
2. Open this repo as your workspace
|
|
111
111
|
3. Paste into chat:
|
|
112
112
|
```
|
|
113
|
-
Read SETUP.md and set up OpenClaw v5.3.
|
|
113
|
+
Read SETUP.md and set up OpenClaw v5.3.1 for me.
|
|
114
114
|
My bot token is X. Use 9Router (no API key).
|
|
115
115
|
My project folder: <YOUR_PATH>
|
|
116
116
|
```
|
package/README.vi.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<div align="center">
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
3
|
# 🦞 OpenClaw Setup
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<a href="https://github.com/tuanminhhole/openclaw-setup/releases"><img src="https://img.shields.io/badge/RELEASE-v5.3.
|
|
6
|
+
<a href="https://github.com/tuanminhhole/openclaw-setup/releases"><img src="https://img.shields.io/badge/RELEASE-v5.3.1-0EA5E9?style=for-the-badge" alt="Version 5.3.1" /></a>
|
|
7
7
|
<a href="https://github.com/tuanminhhole/openclaw-setup?tab=MIT-1-ov-file"><img src="https://img.shields.io/badge/LICENSE-MIT-success?style=for-the-badge" alt="MIT License" /></a>
|
|
8
8
|
<a href="https://www.npmjs.com/package/create-openclaw-bot"><img src="https://img.shields.io/npm/v/create-openclaw-bot?style=for-the-badge&label=CLI&color=2563EB&logo=npm&logoColor=white" alt="NPM Version" /></a>
|
|
9
9
|
<a href="https://github.com/tuanminhhole/openclaw-setup/stargazers"><img src="https://img.shields.io/github/stars/tuanminhhole/openclaw-setup?style=for-the-badge&color=eab308&logo=github&logoColor=white" alt="GitHub Stars" /></a>
|
|
@@ -24,7 +24,15 @@ Công cụ **CLI tương tác** và **Setup Wizard** để tự triển khai Bot
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
## 🆕 Có gì mới trong v5.3.
|
|
27
|
+
## 🆕 Có gì mới trong v5.3.1
|
|
28
|
+
|
|
29
|
+
- 🐛 **Fix: Combo channel thiếu ô nhập Telegram Bot Token** — Khi chọn "Telegram + Zalo Personal", wizard giờ hiển thị cả ô nhập Telegram Token LẪN cảnh báo Zalo Personal.
|
|
30
|
+
- 🐛 **Fix: Nút Next bị kẹt ở bước 4 khi chọn combo** — Validation giờ yêu cầu đúng Telegram token trước khi kích hoạt "Generate Configs" ở combo mode.
|
|
31
|
+
- 🐛 **Fix: Script Windows Docker crash "docker not recognized"** — File `.ps1` được generate giờ dùng `Get-Command` để tìm Docker, kiểm tra Docker Desktop đang chạy, và gọi lệnh qua toán tử `&` — hoạt động kể cả khi Docker không có trong PATH mặc định của PowerShell.
|
|
32
|
+
- 🐛 **Fix: Thiếu hướng dẫn login Zalo QR cho combo trong script Windows** — Phần hướng dẫn sau cài đặt giờ hiển thị lệnh `docker compose exec` login khi chọn combo channel.
|
|
33
|
+
|
|
34
|
+
<details>
|
|
35
|
+
<summary><b>Trước đó: Có gì mới ở v5.3.0</b></summary>
|
|
28
36
|
|
|
29
37
|
- 📱 **Telegram + Zalo Personal cùng lúc** — Tuỳ chọn kênh combo mới cho phép chạy 1 bot trên cả Telegram **và** Zalo Personal cùng lúc, từ 1 config duy nhất. Không cần cài riêng.
|
|
30
38
|
- 🔌 **Tự cấu hình plugin `zalouser`** — Khi chọn Zalo Personal, wizard tự động thêm `plugins.entries.zalouser` vào `openclaw.json`, xử lý lỗi "not configured" phổ biến nhất khi khởi động Zalo.
|
|
@@ -110,7 +118,7 @@ Chạy lệnh trên trong Terminal → làm theo các prompt tương tác → sc
|
|
|
110
118
|
2. Mở repo này làm workspace
|
|
111
119
|
3. Paste vào chat:
|
|
112
120
|
```
|
|
113
|
-
Read SETUP.md and set up OpenClaw v5.3.
|
|
121
|
+
Read SETUP.md and set up OpenClaw v5.3.1 for me.
|
|
114
122
|
My bot token is X. Use 9Router (no API key).
|
|
115
123
|
My project folder: <THƯ_MỤC_CỦA_BẠN>
|
|
116
124
|
```
|
package/cli.js
CHANGED
|
@@ -188,10 +188,12 @@ function spawnBackgroundProcess(command, args, options = {}) {
|
|
|
188
188
|
|
|
189
189
|
function resolveNative9RouterDesktopLaunch() {
|
|
190
190
|
// Use installed 9router CLI directly (more reliable than finding server.js in npm dirs)
|
|
191
|
+
// NOTE: -l (stdin listen mode) is intentionally omitted — it causes hangs when there is
|
|
192
|
+
// no interactive TTY (background spawned process, wizard-generated bat, etc.)
|
|
191
193
|
const routerBin = resolveCommandOnPath('9router') || '9router';
|
|
192
194
|
return {
|
|
193
195
|
command: routerBin,
|
|
194
|
-
args: ['-n', '-
|
|
196
|
+
args: ['-n', '-H', '0.0.0.0', '-p', '20128', '--skip-update'],
|
|
195
197
|
env: {
|
|
196
198
|
PORT: '20128',
|
|
197
199
|
HOSTNAME: '0.0.0.0'
|
|
@@ -2537,6 +2539,357 @@ const { chromium } = require('playwright');
|
|
|
2537
2539
|
} // END FOR LOOP
|
|
2538
2540
|
}
|
|
2539
2541
|
|
|
2542
|
+
// ── Uninstall scripts — generated per OS / deploy mode ─────────────────────
|
|
2543
|
+
{
|
|
2544
|
+
const absProjectDir = projectDir.replace(/\\/g, '\\\\');
|
|
2545
|
+
const unixProjectDir = projectDir.replace(/\\/g, '/');
|
|
2546
|
+
|
|
2547
|
+
if (deployMode === 'native') {
|
|
2548
|
+
// ── Windows .bat uninstall ──────────────────────────────────────────────
|
|
2549
|
+
if (osChoice === 'windows') {
|
|
2550
|
+
const winUninstall = `@echo off
|
|
2551
|
+
setlocal EnableExtensions
|
|
2552
|
+
chcp 65001 >nul
|
|
2553
|
+
echo.
|
|
2554
|
+
echo ============================================================
|
|
2555
|
+
echo OpenClaw Uninstaller - Windows Native
|
|
2556
|
+
echo Project: ${absProjectDir}
|
|
2557
|
+
echo ============================================================
|
|
2558
|
+
echo.
|
|
2559
|
+
echo [WARNING] This will:
|
|
2560
|
+
echo 1. Kill openclaw and 9router background processes
|
|
2561
|
+
echo 2. Uninstall global npm packages (openclaw, 9router, pm2)
|
|
2562
|
+
echo 3. Delete the project folder and all its data
|
|
2563
|
+
echo.
|
|
2564
|
+
set /p CONFIRM=Nhap YES de xac nhan xoa toan bo:
|
|
2565
|
+
if /i not "%CONFIRM%"=="YES" (
|
|
2566
|
+
echo Huy bo. Khong xoa gi ca.
|
|
2567
|
+
pause
|
|
2568
|
+
exit /b 0
|
|
2569
|
+
)
|
|
2570
|
+
echo.
|
|
2571
|
+
echo [1/4] Dang dung cac tien trinh openclaw va 9router...
|
|
2572
|
+
taskkill /F /IM openclaw.exe >nul 2>&1
|
|
2573
|
+
taskkill /F /IM 9router.exe >nul 2>&1
|
|
2574
|
+
:: Kill Node.js processes spawned from project dir
|
|
2575
|
+
powershell -NoProfile -Command "Get-Process node -ErrorAction SilentlyContinue | Where-Object { $_.Path -like '*${absProjectDir}*' } | Stop-Process -Force" >nul 2>&1
|
|
2576
|
+
:: Kill processes listening on ports 18791 and 20128
|
|
2577
|
+
powershell -NoProfile -Command "& { $p=@(18791,20128); foreach($port in $p){ $id=(netstat -ano | Select-String \":$port \").Line -split ' +' | Select-Object -Last 1; if($id -and $id -ne '0'){ Stop-Process -Id $id -Force -ErrorAction SilentlyContinue } } }" >nul 2>&1
|
|
2578
|
+
echo OK: Tien trinh da dung.
|
|
2579
|
+
echo.
|
|
2580
|
+
echo [2/4] Dang go cai npm packages toan cau...
|
|
2581
|
+
set "PATH=%APPDATA%\\npm;%PATH%"
|
|
2582
|
+
call npm uninstall -g openclaw 9router grammy @grammyjs/runner @grammyjs/transformer-throttler @buape/carbon @larksuiteoapi/node-sdk @slack/web-api 2>nul
|
|
2583
|
+
echo OK: npm packages da duoc go cai.
|
|
2584
|
+
echo.
|
|
2585
|
+
echo [3/4] Xoa thu muc project...
|
|
2586
|
+
set "TARGET=${absProjectDir}"
|
|
2587
|
+
if exist "%TARGET%" (
|
|
2588
|
+
rd /s /q "%TARGET%"
|
|
2589
|
+
echo OK: Da xoa %TARGET%
|
|
2590
|
+
) else (
|
|
2591
|
+
echo INFO: Thu muc khong ton tai: %TARGET%
|
|
2592
|
+
)
|
|
2593
|
+
echo.
|
|
2594
|
+
echo [4/4] Xoa thu muc .9router va .openclaw trong Home (neu co)...
|
|
2595
|
+
if exist "%USERPROFILE%\\.9router" (
|
|
2596
|
+
set /p CLEAN_HOME=Xoa ca %USERPROFILE%\\.9router? (YES/no):
|
|
2597
|
+
if /i "%CLEAN_HOME%"=="YES" rd /s /q "%USERPROFILE%\\.9router" >nul 2>&1
|
|
2598
|
+
)
|
|
2599
|
+
echo.
|
|
2600
|
+
echo ============================================================
|
|
2601
|
+
echo Go cai hoan tat!
|
|
2602
|
+
echo De cai lai: chay lai file setup hoac npx create-openclaw-bot
|
|
2603
|
+
echo ============================================================
|
|
2604
|
+
pause
|
|
2605
|
+
`;
|
|
2606
|
+
await fs.writeFile(path.join(projectDir, 'uninstall-openclaw-win.bat'), winUninstall);
|
|
2607
|
+
console.log(chalk.gray(isVi
|
|
2608
|
+
? ` 📄 File go cai: ${path.join(projectDir, 'uninstall-openclaw-win.bat')}`
|
|
2609
|
+
: ` 📄 Uninstall script: ${path.join(projectDir, 'uninstall-openclaw-win.bat')}`));
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
// ── Linux/macOS desktop .sh uninstall ──────────────────────────────────
|
|
2613
|
+
if (osChoice === 'macos' || osChoice === 'ubuntu') {
|
|
2614
|
+
const desktopUninstall = `#!/usr/bin/env bash
|
|
2615
|
+
# ====== OpenClaw Uninstaller — macOS / Linux Desktop ======
|
|
2616
|
+
set -e
|
|
2617
|
+
PROJECT_DIR="${unixProjectDir}"
|
|
2618
|
+
|
|
2619
|
+
echo ""
|
|
2620
|
+
echo "============================================================"
|
|
2621
|
+
echo " OpenClaw Uninstaller — Native (macOS/Linux Desktop)"
|
|
2622
|
+
echo " Project: $PROJECT_DIR"
|
|
2623
|
+
echo "============================================================"
|
|
2624
|
+
echo ""
|
|
2625
|
+
echo "WARNING: This will:"
|
|
2626
|
+
echo " 1. Kill openclaw and 9router processes"
|
|
2627
|
+
echo " 2. Uninstall global npm packages (openclaw, 9router)"
|
|
2628
|
+
echo " 3. Delete the project folder and all its data"
|
|
2629
|
+
echo ""
|
|
2630
|
+
read -rp "Type YES to confirm full removal: " CONFIRM
|
|
2631
|
+
if [ "$CONFIRM" != "YES" ]; then
|
|
2632
|
+
echo "Cancelled. Nothing was deleted."
|
|
2633
|
+
exit 0
|
|
2634
|
+
fi
|
|
2635
|
+
|
|
2636
|
+
echo ""
|
|
2637
|
+
echo "[1/4] Stopping openclaw and 9router processes..."
|
|
2638
|
+
pkill -f "openclaw gateway run" 2>/dev/null || true
|
|
2639
|
+
pkill -f "9router.*20128" 2>/dev/null || true
|
|
2640
|
+
pkill -f "9router-smart-route" 2>/dev/null || true
|
|
2641
|
+
# Kill any node process inside the project dir
|
|
2642
|
+
pkill -f "$PROJECT_DIR" 2>/dev/null || true
|
|
2643
|
+
# Kill processes on port 18791 and 20128
|
|
2644
|
+
for port in 18791 20128; do
|
|
2645
|
+
pid=$(lsof -ti tcp:$port 2>/dev/null || true)
|
|
2646
|
+
[ -n "$pid" ] && kill -9 $pid 2>/dev/null || true
|
|
2647
|
+
done
|
|
2648
|
+
echo " OK: Processes stopped."
|
|
2649
|
+
|
|
2650
|
+
echo ""
|
|
2651
|
+
echo "[2/4] Uninstalling global npm packages..."
|
|
2652
|
+
npm uninstall -g openclaw 9router grammy @grammyjs/runner @grammyjs/transformer-throttler @buape/carbon @larksuiteoapi/node-sdk @slack/web-api 2>/dev/null || true
|
|
2653
|
+
# Also try with sudo if the above fails (system npm prefix)
|
|
2654
|
+
sudo npm uninstall -g openclaw 9router 2>/dev/null || true
|
|
2655
|
+
echo " OK: npm packages removed."
|
|
2656
|
+
|
|
2657
|
+
echo ""
|
|
2658
|
+
echo "[3/4] Removing project directory..."
|
|
2659
|
+
if [ -d "$PROJECT_DIR" ]; then
|
|
2660
|
+
rm -rf "$PROJECT_DIR"
|
|
2661
|
+
echo " OK: Deleted $PROJECT_DIR"
|
|
2662
|
+
else
|
|
2663
|
+
echo " INFO: Directory not found: $PROJECT_DIR"
|
|
2664
|
+
fi
|
|
2665
|
+
|
|
2666
|
+
echo ""
|
|
2667
|
+
echo "[4/4] Checking for home-level .9router / .openclaw..."
|
|
2668
|
+
for dir in "$HOME/.9router" "$HOME/.openclaw"; do
|
|
2669
|
+
if [ -d "$dir" ]; then
|
|
2670
|
+
read -rp "Delete $dir ? (YES/no): " CLEAN
|
|
2671
|
+
if [ "$CLEAN" = "YES" ]; then
|
|
2672
|
+
rm -rf "$dir"
|
|
2673
|
+
echo " OK: Deleted $dir"
|
|
2674
|
+
else
|
|
2675
|
+
echo " Kept: $dir"
|
|
2676
|
+
fi
|
|
2677
|
+
fi
|
|
2678
|
+
done
|
|
2679
|
+
|
|
2680
|
+
echo ""
|
|
2681
|
+
echo "============================================================"
|
|
2682
|
+
echo " Uninstall complete!"
|
|
2683
|
+
echo " To reinstall: run the setup script or npx create-openclaw-bot"
|
|
2684
|
+
echo "============================================================"
|
|
2685
|
+
`;
|
|
2686
|
+
const desktopShPath = path.join(projectDir, 'uninstall-openclaw.sh');
|
|
2687
|
+
await fs.writeFile(desktopShPath, desktopUninstall);
|
|
2688
|
+
try { await fs.chmod(desktopShPath, 0o755); } catch (_) {}
|
|
2689
|
+
console.log(chalk.gray(isVi
|
|
2690
|
+
? ` 📄 File go cai: ${desktopShPath}`
|
|
2691
|
+
: ` 📄 Uninstall script: ${desktopShPath}`));
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
// ── VPS / PM2 .sh uninstall ─────────────────────────────────────────────
|
|
2695
|
+
if (osChoice === 'vps') {
|
|
2696
|
+
const vpsUninstall = `#!/usr/bin/env bash
|
|
2697
|
+
# ====== OpenClaw Uninstaller — VPS / Ubuntu Server (PM2) ======
|
|
2698
|
+
set -e
|
|
2699
|
+
PROJECT_DIR="${unixProjectDir}"
|
|
2700
|
+
APP_NAME="${(botName || 'openclaw').toLowerCase().replace(/[^a-z0-9]+/g, '-')}"
|
|
2701
|
+
|
|
2702
|
+
echo ""
|
|
2703
|
+
echo "============================================================"
|
|
2704
|
+
echo " OpenClaw Uninstaller — VPS / Ubuntu Server"
|
|
2705
|
+
echo " Project: $PROJECT_DIR"
|
|
2706
|
+
echo " PM2 app: $APP_NAME"
|
|
2707
|
+
echo "============================================================"
|
|
2708
|
+
echo ""
|
|
2709
|
+
echo "WARNING: This will:"
|
|
2710
|
+
echo " 1. Stop and delete all PM2 processes for this bot"
|
|
2711
|
+
echo " 2. Uninstall global npm packages (openclaw, 9router, pm2)"
|
|
2712
|
+
echo " 3. Delete the project folder and all its data"
|
|
2713
|
+
echo ""
|
|
2714
|
+
read -rp "Type YES to confirm full removal: " CONFIRM
|
|
2715
|
+
if [ "$CONFIRM" != "YES" ]; then
|
|
2716
|
+
echo "Cancelled. Nothing was deleted."
|
|
2717
|
+
exit 0
|
|
2718
|
+
fi
|
|
2719
|
+
|
|
2720
|
+
echo ""
|
|
2721
|
+
echo "[1/5] Stopping and deleting PM2 processes..."
|
|
2722
|
+
if command -v pm2 &>/dev/null; then
|
|
2723
|
+
pm2 delete "$APP_NAME" 2>/dev/null || true
|
|
2724
|
+
pm2 delete "$APP_NAME-9router" 2>/dev/null || true
|
|
2725
|
+
pm2 delete "$APP_NAME-9router-sync" 2>/dev/null || true
|
|
2726
|
+
pm2 delete "openclaw" 2>/dev/null || true
|
|
2727
|
+
pm2 delete "openclaw-multibot" 2>/dev/null || true
|
|
2728
|
+
pm2 save --force 2>/dev/null || true
|
|
2729
|
+
echo " OK: PM2 processes removed."
|
|
2730
|
+
else
|
|
2731
|
+
echo " INFO: PM2 not found — skipping."
|
|
2732
|
+
fi
|
|
2733
|
+
|
|
2734
|
+
echo ""
|
|
2735
|
+
echo "[2/5] Killing any remaining processes on port 18791 / 20128..."
|
|
2736
|
+
for port in 18791 20128; do
|
|
2737
|
+
pid=$(lsof -ti tcp:$port 2>/dev/null || true)
|
|
2738
|
+
[ -n "$pid" ] && kill -9 $pid 2>/dev/null || true
|
|
2739
|
+
done
|
|
2740
|
+
echo " OK: Ports cleared."
|
|
2741
|
+
|
|
2742
|
+
echo ""
|
|
2743
|
+
echo "[3/5] Uninstalling global npm packages..."
|
|
2744
|
+
npm uninstall -g openclaw 9router pm2 grammy @grammyjs/runner @grammyjs/transformer-throttler @buape/carbon @larksuiteoapi/node-sdk @slack/web-api 2>/dev/null || true
|
|
2745
|
+
echo " OK: npm packages removed."
|
|
2746
|
+
|
|
2747
|
+
echo ""
|
|
2748
|
+
echo "[4/5] Removing project directory..."
|
|
2749
|
+
if [ -d "$PROJECT_DIR" ]; then
|
|
2750
|
+
rm -rf "$PROJECT_DIR"
|
|
2751
|
+
echo " OK: Deleted $PROJECT_DIR"
|
|
2752
|
+
else
|
|
2753
|
+
echo " INFO: Directory not found: $PROJECT_DIR"
|
|
2754
|
+
fi
|
|
2755
|
+
|
|
2756
|
+
echo ""
|
|
2757
|
+
echo "[5/5] Checking for home-level .9router / .openclaw..."
|
|
2758
|
+
for dir in "$HOME/.9router" "$HOME/.openclaw"; do
|
|
2759
|
+
if [ -d "$dir" ]; then
|
|
2760
|
+
read -rp "Delete $dir ? (YES/no): " CLEAN
|
|
2761
|
+
if [ "$CLEAN" = "YES" ]; then
|
|
2762
|
+
rm -rf "$dir"
|
|
2763
|
+
echo " OK: Deleted $dir"
|
|
2764
|
+
else
|
|
2765
|
+
echo " Kept: $dir"
|
|
2766
|
+
fi
|
|
2767
|
+
fi
|
|
2768
|
+
done
|
|
2769
|
+
|
|
2770
|
+
echo ""
|
|
2771
|
+
echo "============================================================"
|
|
2772
|
+
echo " Uninstall complete!"
|
|
2773
|
+
echo " To reinstall: npx create-openclaw-bot@latest"
|
|
2774
|
+
echo "============================================================"
|
|
2775
|
+
`;
|
|
2776
|
+
const vpsShPath = path.join(projectDir, 'uninstall-openclaw-vps.sh');
|
|
2777
|
+
await fs.writeFile(vpsShPath, vpsUninstall);
|
|
2778
|
+
try { await fs.chmod(vpsShPath, 0o755); } catch (_) {}
|
|
2779
|
+
console.log(chalk.gray(isVi
|
|
2780
|
+
? ` 📄 File go cai VPS: ${vpsShPath}`
|
|
2781
|
+
: ` 📄 VPS uninstall script: ${vpsShPath}`));
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
} else {
|
|
2785
|
+
// ── Docker uninstall .sh ────────────────────────────────────────────────
|
|
2786
|
+
const dockerUninstall = `#!/usr/bin/env bash
|
|
2787
|
+
# ====== OpenClaw Uninstaller — Docker ======
|
|
2788
|
+
set -e
|
|
2789
|
+
PROJECT_DIR="${unixProjectDir}"
|
|
2790
|
+
DOCKER_DIR="$PROJECT_DIR/docker/openclaw"
|
|
2791
|
+
|
|
2792
|
+
echo ""
|
|
2793
|
+
echo "============================================================"
|
|
2794
|
+
echo " OpenClaw Uninstaller — Docker"
|
|
2795
|
+
echo " Project: $PROJECT_DIR"
|
|
2796
|
+
echo "============================================================"
|
|
2797
|
+
echo ""
|
|
2798
|
+
echo "WARNING: This will:"
|
|
2799
|
+
echo " 1. Stop and remove all Docker containers + volumes"
|
|
2800
|
+
echo " 2. Delete the project folder and all its data"
|
|
2801
|
+
echo ""
|
|
2802
|
+
read -rp "Type YES to confirm full removal: " CONFIRM
|
|
2803
|
+
if [ "$CONFIRM" != "YES" ]; then
|
|
2804
|
+
echo "Cancelled. Nothing was deleted."
|
|
2805
|
+
exit 0
|
|
2806
|
+
fi
|
|
2807
|
+
|
|
2808
|
+
echo ""
|
|
2809
|
+
echo "[1/3] Stopping Docker containers and removing volumes..."
|
|
2810
|
+
if [ -d "$DOCKER_DIR" ] && command -v docker &>/dev/null; then
|
|
2811
|
+
cd "$DOCKER_DIR"
|
|
2812
|
+
docker compose down --volumes --remove-orphans 2>/dev/null || docker-compose down --volumes --remove-orphans 2>/dev/null || true
|
|
2813
|
+
echo " OK: Containers + volumes removed."
|
|
2814
|
+
else
|
|
2815
|
+
echo " INFO: Docker dir not found or docker not installed — skipping."
|
|
2816
|
+
fi
|
|
2817
|
+
|
|
2818
|
+
echo ""
|
|
2819
|
+
echo "[2/3] Removing project directory..."
|
|
2820
|
+
if [ -d "$PROJECT_DIR" ]; then
|
|
2821
|
+
rm -rf "$PROJECT_DIR"
|
|
2822
|
+
echo " OK: Deleted $PROJECT_DIR"
|
|
2823
|
+
else
|
|
2824
|
+
echo " INFO: Directory not found: $PROJECT_DIR"
|
|
2825
|
+
fi
|
|
2826
|
+
|
|
2827
|
+
echo ""
|
|
2828
|
+
echo "[3/3] Checking for home-level .openclaw..."
|
|
2829
|
+
if [ -d "$HOME/.openclaw" ]; then
|
|
2830
|
+
read -rp "Delete $HOME/.openclaw? (YES/no): " CLEAN
|
|
2831
|
+
if [ "$CLEAN" = "YES" ]; then
|
|
2832
|
+
rm -rf "$HOME/.openclaw"
|
|
2833
|
+
echo " OK: Deleted $HOME/.openclaw"
|
|
2834
|
+
else
|
|
2835
|
+
echo " Kept: $HOME/.openclaw"
|
|
2836
|
+
fi
|
|
2837
|
+
fi
|
|
2838
|
+
|
|
2839
|
+
echo ""
|
|
2840
|
+
echo "============================================================"
|
|
2841
|
+
echo " Uninstall complete!"
|
|
2842
|
+
echo " To reinstall: npx create-openclaw-bot@latest"
|
|
2843
|
+
echo "============================================================"
|
|
2844
|
+
`;
|
|
2845
|
+
const dockerShPath = path.join(projectDir, 'uninstall-openclaw-docker.sh');
|
|
2846
|
+
await fs.writeFile(dockerShPath, dockerUninstall);
|
|
2847
|
+
try { await fs.chmod(dockerShPath, 0o755); } catch (_) {}
|
|
2848
|
+
|
|
2849
|
+
// Windows .bat for docker uninstall
|
|
2850
|
+
const dockerWinUninstall = `@echo off
|
|
2851
|
+
setlocal EnableExtensions
|
|
2852
|
+
chcp 65001 >nul
|
|
2853
|
+
echo.
|
|
2854
|
+
echo ============================================================
|
|
2855
|
+
echo OpenClaw Uninstaller - Docker (Windows)
|
|
2856
|
+
echo Project: ${absProjectDir}
|
|
2857
|
+
echo ============================================================
|
|
2858
|
+
echo.
|
|
2859
|
+
echo [WARNING] This will stop Docker containers and delete the project folder.
|
|
2860
|
+
echo.
|
|
2861
|
+
set /p CONFIRM=Nhap YES de xac nhan xoa toan bo:
|
|
2862
|
+
if /i not "%CONFIRM%"=="YES" (
|
|
2863
|
+
echo Huy bo. Khong xoa gi ca.
|
|
2864
|
+
pause
|
|
2865
|
+
exit /b 0
|
|
2866
|
+
)
|
|
2867
|
+
echo.
|
|
2868
|
+
echo [1/2] Dang dung Docker containers...
|
|
2869
|
+
cd /d "${absProjectDir}\\docker\\openclaw" 2>nul && (
|
|
2870
|
+
docker compose down --volumes --remove-orphans 2>nul || docker-compose down --volumes --remove-orphans 2>nul
|
|
2871
|
+
echo OK: Containers da dung.
|
|
2872
|
+
) || echo INFO: Khong tim thay docker compose.
|
|
2873
|
+
echo.
|
|
2874
|
+
echo [2/2] Xoa thu muc project...
|
|
2875
|
+
cd /d "%USERPROFILE%"
|
|
2876
|
+
if exist "${absProjectDir}" (
|
|
2877
|
+
rd /s /q "${absProjectDir}"
|
|
2878
|
+
echo OK: Da xoa ${absProjectDir}
|
|
2879
|
+
)
|
|
2880
|
+
echo.
|
|
2881
|
+
echo ============================================================
|
|
2882
|
+
echo Go cai hoan tat! De cai lai: npx create-openclaw-bot@latest
|
|
2883
|
+
echo ============================================================
|
|
2884
|
+
pause
|
|
2885
|
+
`;
|
|
2886
|
+
await fs.writeFile(path.join(projectDir, 'uninstall-openclaw-docker.bat'), dockerWinUninstall);
|
|
2887
|
+
console.log(chalk.gray(isVi
|
|
2888
|
+
? ` 📄 File go cai Docker: ${dockerShPath}`
|
|
2889
|
+
: ` 📄 Docker uninstall script: ${dockerShPath}`));
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2540
2893
|
// ── Chrome Debug scripts — always created (user may need browser later)
|
|
2541
2894
|
const batPath = path.join(projectDir, 'start-chrome-debug.bat');
|
|
2542
2895
|
await fs.writeFile(batPath, `@echo off
|
|
@@ -2817,6 +3170,44 @@ fi
|
|
|
2817
3170
|
} else {
|
|
2818
3171
|
if (providerKey === '9router') {
|
|
2819
3172
|
console.log(chalk.yellow(`\n${isVi ? 'Khoi dong 9Router native (background)...' : 'Starting native 9Router (background)...'}`));
|
|
3173
|
+
|
|
3174
|
+
// ── Pre-seed DATA_DIR + db.json BEFORE launching 9Router ──────────────
|
|
3175
|
+
// 9Router reads DATA_DIR on startup to find its db. If we don't set this
|
|
3176
|
+
// first it falls back to its own default (~/.9router) and requireLogin
|
|
3177
|
+
// defaults to true, causing the dashboard login wall.
|
|
3178
|
+
const routerDataDir = getProject9RouterDataDir(projectDir);
|
|
3179
|
+
try {
|
|
3180
|
+
await fs.ensureDir(routerDataDir);
|
|
3181
|
+
const dbPath = path.join(routerDataDir, 'db.json');
|
|
3182
|
+
if (!fs.existsSync(dbPath)) {
|
|
3183
|
+
await fs.writeJson(dbPath, {
|
|
3184
|
+
providerConnections: [],
|
|
3185
|
+
providerNodes: [],
|
|
3186
|
+
proxyPools: [],
|
|
3187
|
+
modelAliases: {},
|
|
3188
|
+
mitmAlias: {},
|
|
3189
|
+
combos: [],
|
|
3190
|
+
apiKeys: [],
|
|
3191
|
+
settings: {
|
|
3192
|
+
requireLogin: false,
|
|
3193
|
+
cloudEnabled: false,
|
|
3194
|
+
tunnelEnabled: false,
|
|
3195
|
+
comboStrategy: 'fallback',
|
|
3196
|
+
mitmRouterBaseUrl: 'http://localhost:20128'
|
|
3197
|
+
},
|
|
3198
|
+
pricing: {}
|
|
3199
|
+
}, { spaces: 2 });
|
|
3200
|
+
console.log(chalk.gray(isVi
|
|
3201
|
+
? ` ✅ Pre-seeded db.json (requireLogin: false) tại: ${dbPath}`
|
|
3202
|
+
: ` ✅ Pre-seeded db.json (requireLogin: false) at: ${dbPath}`));
|
|
3203
|
+
}
|
|
3204
|
+
} catch (err) {
|
|
3205
|
+
console.log(chalk.yellow(isVi
|
|
3206
|
+
? ` ⚠️ Khong the pre-seed db.json: ${err?.message}. 9Router van se khoi dong.`
|
|
3207
|
+
: ` ⚠️ Could not pre-seed db.json: ${err?.message}. 9Router will still start.`));
|
|
3208
|
+
}
|
|
3209
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
3210
|
+
|
|
2820
3211
|
const native9RouterLaunch = resolveNative9RouterDesktopLaunch();
|
|
2821
3212
|
spawnBackgroundProcess(native9RouterLaunch.command, native9RouterLaunch.args, {
|
|
2822
3213
|
cwd: projectDir,
|