@softtynet/zplus-worker 1.0.4 → 1.0.5

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/README.md CHANGED
@@ -1,108 +1,130 @@
1
1
  # @softtynet/zplus-worker
2
2
 
3
- ZPlus 24/7 Headless Automation & Omnichannel Worker Engine.
3
+ ZPlus 24/7 Headless Automation & Omnichannel Worker Daemon.
4
4
 
5
5
  ---
6
6
 
7
7
  ## 🌟 Giới Thiệu (Introduction)
8
8
 
9
- `@softtynet/zplus-worker` là tiến trình chạy nền độc lập 24/7 cho hệ sinh thái ZPlus Enterprise. Phân hệ chịu trách nhiệm duy trì phiên kết nối mạng xã hội, tiếp nhận tin nhắn và thực thi kịch bản tự động hóa liên tục ngay cả khi người dùng không mở máy tính cá nhân.
9
+ `@softtynet/zplus-worker` là tiến trình chạy nền độc lập 24/7 cho hệ sinh thái ZPlus Enterprise. Phân hệ chịu trách nhiệm duy trì phiên kết nối mạng xã hội (Zalo, Facebook Messenger, Telegram, WhatsApp...), tiếp nhận tin nhắn và thực thi kịch bản tự động hóa liên tục ngay cả khi người dùng tắt máy tính cá nhân.
10
+
11
+ - **100% Headless**: Chạy trên mọi VPS Linux không cần màn hình hay trình duyệt.
12
+ - **Bảo Mật SSO / RBAC**: Đăng nhập bằng Softty ID, không cần API Key backend.
13
+ - **Gatekeeper Tự Động**: Chỉ Team Owner sở hữu gói Enterprise mới được cấp quyền kích hoạt.
14
+ - **Ghép Nối 1-Click**: Tạo mã ghép nối trực tiếp từ ZPlus Desktop.
10
15
 
11
16
  ---
12
17
 
13
- ## 🚀 Hướng Dẫn Cài Đặt & Sử Dụng (Quickstart)
18
+ ## 🚀 Hướng Dẫn Nhanh (Quickstart)
19
+
20
+ ### ⭐ Cách 1: Cài Đặt Tự Động 1 Dòng Lệnh Đa Nền Tảng (1-Line Auto Installer - Khuyên Dùng)
21
+
22
+ #### 🪟 Trên Windows (Windows 10, Windows 11, Windows Server):
23
+
24
+ Mở **PowerShell** và chạy:
25
+
26
+ ```powershell
27
+ & { irm https://zplus.softty.net/install.ps1 | iex } -pair "<TOKEN_TỪ_DESKTOP>"
28
+ ```
29
+
30
+ > Tự động cài Node.js, thiết lập Task Scheduler (`onstart`). Mất điện hay khởi động lại máy thì Worker **tự động chạy ngầm ngay từ màn hình boot**.
31
+
32
+ #### 🐧 Trên Linux VPS & 🍎 macOS:
14
33
 
15
- ### Cách 1: Chạy trực tiếp qua NPX (Không cần cài đặt)
34
+ Mở **Terminal** và chạy:
16
35
 
17
36
  ```bash
18
- npx @softtynet/zplus-worker
37
+ # Cài đặt tự động bằng Systemd/LaunchAgent (Khuyên dùng):
38
+ curl -fsSL https://zplus.softty.net/install.sh | bash -s -- --pair="<TOKEN_TỪ_DESKTOP>"
39
+
40
+ # Hoặc cài đặt tự động bằng Docker Container:
41
+ curl -fsSL https://zplus.softty.net/install-docker.sh | bash -s -- --pair="<TOKEN_TỪ_DESKTOP>"
19
42
  ```
20
43
 
21
- ### Cách 2: Cài đặt toàn cục trên máy chủ VPS / Linux
44
+ ---
45
+
46
+ ### Cách 2: Cài Đặt Toàn Cục Bằng NPM & Vận Hành Thủ Công
22
47
 
23
48
  ```bash
49
+ # Cài đặt qua NPM
24
50
  npm install -g @softtynet/zplus-worker
25
- zplus-worker
51
+
52
+ # Hoặc chạy trực tiếp qua NPX:
53
+ npx @softtynet/zplus-worker help
26
54
  ```
27
55
 
28
- #### Khuyên dùng: Quản tiến trình nền bằng PM2 trên VPS
56
+ #### Đăng nhập cho Worker trên VPS (Không cần Browser)
57
+
58
+ ##### Cách A: Ghép nối 1-Click từ ZPlus Desktop (Khuyên dùng)
59
+
60
+ Trên ZPlus Desktop: Vào **Cài Đặt** $\rightarrow$ **Worker & VPS Cluster** $\rightarrow$ Bấm **Tạo Lệnh Ghép Nối 1-Click Cho VPS** và dán lệnh vào VPS:
61
+
29
62
  ```bash
30
- npm install -g pm2
31
- pm2 start zplus-worker --name "zplus-worker" --time
32
- pm2 save && pm2 startup
63
+ npx @softtynet/zplus-worker login --pair="<TOKEN_TỪ_DESKTOP>"
33
64
  ```
34
65
 
35
- ---
36
-
37
- ### Cách 3: Chạy với Docker & Docker Compose
66
+ ##### Cách B: Đăng nhập bằng tài khoản Softty ID qua SSH Terminal
38
67
 
39
- #### A. Chạy nhanh 1 lệnh Container:
40
68
  ```bash
41
- docker run -d \
42
- --name zplus-worker \
43
- --restart always \
44
- -p 8080:8080 \
45
- -e WORKER_ID=vps_node_1 \
46
- -e DESKTOP_SECRET=your_secure_secret \
47
- ghcr.io/softtynet/zplus-worker:latest
69
+ npx @softtynet/zplus-worker login --email="admin@congty.com" --password="mat_khau_tai_day"
48
70
  ```
49
71
 
50
- #### B. Khởi chạy trọn gói qua Docker Compose:
51
- ```yaml
52
- version: "3.8"
53
-
54
- services:
55
- zplus-worker:
56
- image: ghcr.io/softtynet/zplus-worker:latest
57
- container_name: zplus-worker
58
- restart: always
59
- ports:
60
- - "8080:8080"
61
- environment:
62
- - NODE_ENV=production
63
- - PORT=8080
64
- - WORKER_ID=vps_node_1
65
- - DESKTOP_SECRET=your_secure_secret
66
- - REDIS_URL=redis://redis:6379
67
- - DATA_DIR=/data
68
- volumes:
69
- - worker_data:/data
70
- depends_on:
71
- - redis
72
-
73
- redis:
74
- image: redis:7-alpine
75
- container_name: zplus-worker-redis
76
- restart: always
77
- command: redis-server --appendonly yes
78
- volumes:
79
- - redis_data:/data
80
-
81
- volumes:
82
- worker_data:
83
- redis_data:
72
+ #### Kiểm tra trạng thái xác thực & phân quyền
73
+
74
+ ```bash
75
+ npx @softtynet/zplus-worker status
84
76
  ```
85
77
 
78
+ #### Khởi chạy 24/7 với PM2
79
+
86
80
  ```bash
87
- docker compose up -d
81
+ npm install -g pm2
82
+ pm2 start zplus-worker --name "zplus-worker" --time
83
+ pm2 save && pm2 startup
88
84
  ```
89
85
 
90
86
  ---
91
87
 
88
+ ## 📖 Bảng Lệnh CLI (Command Cheatsheet)
89
+
90
+ | Lệnh | Ý nghĩa |
91
+ | :----------------------------------- | :------------------------------------------------------------------- |
92
+ | `zplus-worker help` | Hiển thị bảng trợ giúp và các tùy chọn |
93
+ | `zplus-worker status` | Kiểm tra trạng thái đăng nhập, vai trò Owner/Member, gói Enterprise |
94
+ | `zplus-worker doctor` | Chẩn đoán sức khỏe toàn diện: OS, RAM, Cloud API, Cổng Ingress, File |
95
+ | `zplus-worker health` (hoặc `ping`) | Kiểm tra nhịp tim: Uptime, Nick đang chạy WSS, RAM chiếm dụng |
96
+ | `zplus-worker logs` | Xem trực tiếp live logs tiến trình nền đang chạy (PM2 / Docker) |
97
+ | `zplus-worker restart` | Khởi động lại dịch vụ Worker nền an toàn |
98
+ | `zplus-worker login` | Đăng nhập tài khoản Softty ID |
99
+ | `zplus-worker login --pair="<CODE>"` | Ghép nối 1-Click từ Desktop Client |
100
+ | `zplus-worker logout` | Đăng xuất và xóa phiên lưu trữ trên máy chủ |
101
+ | `zplus-worker uninstall` | Dừng tiến trình PM2/Docker/Systemd và gỡ bỏ Worker an toàn |
102
+ | `zplus-worker uninstall --purge` | Gỡ bỏ hoàn toàn kèm xóa sạch cache, dữ liệu & logs (~/.zplus) |
103
+ | `zplus-worker` (mặc định) | Khởi chạy Worker Daemon 24/7 |
104
+
105
+ > 💡 **Gỡ cài đặt 1-Click tự động:** Bạn cũng có thể chạy lệnh sau trên VPS:
106
+ > `curl -fsSL https://zplus.softty.net/uninstall.sh | bash` (hoặc thêm `--purge` để xóa toàn bộ dữ liệu).
107
+
108
+ ---
109
+
92
110
  ## ⚙️ Biến Môi Trường (Environment Variables)
93
111
 
94
- | Biến | Mặc định | Mô tả |
95
- | :--- | :--- | :--- |
96
- | `PORT` | `8080` | Cổng HTTP Ingress & Healthcheck |
97
- | `WORKER_ID` | `worker_<pid>` | Tên định danh duy nhất của Worker Node |
98
- | `DESKTOP_SECRET` | `zplus_shared_secret_token` | Khóa xác thực an toàn giữa Desktop và Worker |
99
- | `REDIS_URL` | `undefined` | URL Redis cho Distributed Lock (Tùy chọn khi chạy cụm) |
100
- | `DATA_DIR` | `./data` | Thư mục lưu trữ database cục bộ và session cache |
112
+ | Biến | Mặc định | Mô tả |
113
+ | :-------------------- | :-------------------------- | :-------------------------------------------- |
114
+ | `PORT` | `8080` | Cổng HTTP Ingress & Healthcheck (`/health`) |
115
+ | `WORKER_ID` | `worker_<pid>` | Tên định danh duy nhất của Worker Node |
116
+ | `TEAM_ID` | `default` | ID của Team sở hữu Worker |
117
+ | `DATA_DIR` | `~/.zplus` | Thư mục lưu phiên đăng nhập cache tin nhắn |
118
+ | `APPWRITE_ENDPOINT` | `https://api.softty.net/v1` | URL Appwrite Cloud Backend |
119
+ | `APPWRITE_PROJECT_ID` | `699cfc3100136099c1c1` | Project ID của hệ thống Softty |
101
120
 
102
121
  ---
103
122
 
104
- ## 🛡️ Bản Quyền & Hỗ Trợ (License & Support)
123
+ ## 📄 Tài Liệu Chi Tiết
124
+
125
+ Xem tài liệu hướng dẫn vận hành chi tiết từ A đến Z tại:
126
+ 👉 [Hướng Dẫn Vận Hành & Triển Khai Worker 24/7 (docs/02-guides/huong_dan_su_dung_worker.md)](../../docs/02-guides/huong_dan_su_dung_worker.md)
127
+
128
+ ---
105
129
 
106
- Sản phẩm thuộc bản quyền của **SOFTTY.NET COMPANY LIMITED**.
107
- Website chính thức: [https://softty.net](https://softty.net)
108
- Hỗ trợ kỹ thuật: [support@softty.net](mailto:support@softty.net)
130
+ © 2026 **SOFTTY.NET COMPANY LIMITED**.