@workclaw/cli 1.0.313 → 1.0.315
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 +226 -57
- package/dist/box/installer/installer.d.ts +0 -1
- package/dist/box/installer/installer.d.ts.map +1 -1
- package/dist/{index-BZh3SXHn.js → index-CkTwizLH.js} +25 -40
- package/dist/index.js +1 -1
- package/dist/local/installer/installer.d.ts +0 -1
- package/dist/local/installer/installer.d.ts.map +1 -1
- package/dist/shared/utils/index.d.ts +1 -0
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/shared/utils/path.d.ts +7 -0
- package/dist/shared/utils/path.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,80 +2,232 @@
|
|
|
2
2
|
|
|
3
3
|
WorkClaw CLI 是一个用于初始化和配置 WorkClaw 插件的命令行工具。
|
|
4
4
|
|
|
5
|
-
## 特性
|
|
5
|
+
## ✨ 特性
|
|
6
6
|
|
|
7
7
|
- 🚀 **快速初始化** - 一键安装 WorkClaw 插件
|
|
8
8
|
- 🔐 **安全认证** - RSA 加密密码,保护用户隐私
|
|
9
9
|
- 🌐 **多平台支持** - Windows, macOS, Linux
|
|
10
10
|
- 📊 **详细日志** - 完整的请求/响应日志
|
|
11
11
|
- 🎨 **友好界面** - 彩色输出和加载动画
|
|
12
|
+
- 📦 **npm 安装** - 支持自定义安装路径
|
|
13
|
+
- 🔧 **灵活配置** - 支持自定义 OpenClaw 安装目录
|
|
12
14
|
|
|
13
|
-
##
|
|
15
|
+
## 📋 前置要求
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
npm
|
|
17
|
-
```
|
|
17
|
+
- **Node.js**: >= 20.0.0
|
|
18
|
+
- **包管理器**: npm / pnpm / yarn(推荐 pnpm)
|
|
18
19
|
|
|
19
|
-
## 快速开始
|
|
20
|
+
## 🚀 快速开始
|
|
20
21
|
|
|
21
|
-
###
|
|
22
|
+
### 使用 npx(推荐,无需安装)
|
|
22
23
|
|
|
23
24
|
```bash
|
|
24
|
-
|
|
25
|
+
# 本地账户安装
|
|
26
|
+
npx @workclaw/cli local
|
|
27
|
+
|
|
28
|
+
# 盒子设备安装
|
|
29
|
+
npx @workclaw/cli box
|
|
30
|
+
|
|
31
|
+
# 查看帮助
|
|
32
|
+
npx @workclaw/cli --help
|
|
25
33
|
```
|
|
26
34
|
|
|
27
|
-
###
|
|
35
|
+
### 全局安装后使用
|
|
28
36
|
|
|
29
37
|
```bash
|
|
38
|
+
# 全局安装
|
|
39
|
+
npm install -g @workclaw/cli
|
|
40
|
+
|
|
41
|
+
# 本地账户安装
|
|
42
|
+
workclaw local
|
|
43
|
+
|
|
44
|
+
# 盒子设备安装
|
|
30
45
|
workclaw box
|
|
31
46
|
```
|
|
32
47
|
|
|
33
|
-
##
|
|
48
|
+
## 📖 两种安装模式
|
|
49
|
+
|
|
50
|
+
### local 命令 - 本地账户安装
|
|
51
|
+
|
|
52
|
+
**适用场景**:个人电脑或需要用户登录的设备
|
|
53
|
+
|
|
54
|
+
**特点**:
|
|
55
|
+
- ✅ 需要用户登录(手机号 + 密码)
|
|
56
|
+
- ✅ 自动获取 appKey 和 appSecret
|
|
57
|
+
- ✅ 支持多账号管理
|
|
58
|
+
- ✅ 自动创建和管理配置
|
|
59
|
+
|
|
60
|
+
**安装流程**:
|
|
61
|
+
1. 用户登录(RSA 加密密码)
|
|
62
|
+
2. 获取绑定配置
|
|
63
|
+
3. 通过手机号补全配置
|
|
64
|
+
4. 下载并安装插件
|
|
65
|
+
5. 更新配置文件
|
|
66
|
+
|
|
67
|
+
### box 命令 - 盒子设备安装
|
|
68
|
+
|
|
69
|
+
**适用场景**:专用设备或无需用户登录的环境
|
|
70
|
+
|
|
71
|
+
**特点**:
|
|
72
|
+
- ✅ 无需登录(直接使用 appKey + appSecret)
|
|
73
|
+
- ✅ 适合批量部署
|
|
74
|
+
- ✅ 配置文件默认设置为开放策略
|
|
75
|
+
- ✅ 更快的安装速度
|
|
76
|
+
|
|
77
|
+
**安装流程**:
|
|
78
|
+
1. 清理旧版本插件
|
|
79
|
+
2. 下载并安装插件
|
|
80
|
+
3. 更新配置文件(`dmPolicy: "open"`)
|
|
81
|
+
|
|
82
|
+
## 📖 使用文档
|
|
34
83
|
|
|
35
84
|
### 命令
|
|
36
85
|
|
|
37
86
|
```bash
|
|
38
|
-
#
|
|
39
|
-
workclaw local [options]
|
|
87
|
+
# 本地账户安装(需要登录)
|
|
88
|
+
npx @workclaw/cli local [options]
|
|
40
89
|
|
|
41
|
-
#
|
|
42
|
-
workclaw box [options]
|
|
90
|
+
# 盒子设备安装(无需登录)
|
|
91
|
+
npx @workclaw/cli box [options]
|
|
43
92
|
|
|
44
|
-
#
|
|
45
|
-
workclaw --help
|
|
93
|
+
# 查看帮助
|
|
94
|
+
npx @workclaw/cli --help
|
|
46
95
|
```
|
|
47
96
|
|
|
48
97
|
### local 命令参数
|
|
49
98
|
|
|
50
|
-
| 参数
|
|
51
|
-
| --------------- |
|
|
52
|
-
| --phone |
|
|
53
|
-
| --user-pass |
|
|
54
|
-
| --
|
|
55
|
-
| --
|
|
56
|
-
| --
|
|
57
|
-
| --debug |
|
|
99
|
+
| 参数 | 说明 |
|
|
100
|
+
| --------------- | --------------------------------------- |
|
|
101
|
+
| --phone | 手机号码(登录账号),未填写时会交互式提示输入 |
|
|
102
|
+
| --user-pass | 用户密码,未填写时会交互式提示输入 |
|
|
103
|
+
| --env | 环境 (test/prod),默认 test,未填写时会交互式提示选择 |
|
|
104
|
+
| --plugin-version | 插件版本号(默认安装最新版) |
|
|
105
|
+
| --openclaw-path | OpenClaw 安装目录(默认 ~/.openclaw) |
|
|
106
|
+
| --debug | 开启调试日志 |
|
|
58
107
|
|
|
59
108
|
### box 命令参数
|
|
60
109
|
|
|
61
|
-
| 参数
|
|
62
|
-
| --------------- |
|
|
63
|
-
| --app-key |
|
|
64
|
-
| --app-secret |
|
|
65
|
-
| --env |
|
|
66
|
-
| --plugin-version |
|
|
67
|
-
| --
|
|
110
|
+
| 参数 | 说明 |
|
|
111
|
+
| --------------- | --------------------------------------- |
|
|
112
|
+
| --app-key | App Key,未填写时会交互式提示输入 |
|
|
113
|
+
| --app-secret | App Secret,未填写时会交互式提示输入 |
|
|
114
|
+
| --env | 环境 (test/prod),默认 test,未填写时会交互式提示选择 |
|
|
115
|
+
| --plugin-version | 插件版本号(默认安装最新版) |
|
|
116
|
+
| --openclaw-path | OpenClaw 安装目录(默认 ~/.openclaw) |
|
|
117
|
+
| --debug | 开启调试日志 |
|
|
68
118
|
|
|
69
|
-
##
|
|
119
|
+
## 💡 使用示例
|
|
70
120
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
121
|
+
### 本地账户安装
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# 交互式安装(会提示输入手机号和密码)
|
|
125
|
+
npx @workclaw/cli local
|
|
126
|
+
|
|
127
|
+
# 指定手机号和密码
|
|
128
|
+
npx @workclaw/cli local --phone 18111657826 --user-pass yourpassword
|
|
129
|
+
|
|
130
|
+
# 指定正式环境
|
|
131
|
+
npx @workclaw/cli local --env prod --phone 18111657826 --user-pass yourpassword
|
|
132
|
+
|
|
133
|
+
# 自定义安装路径
|
|
134
|
+
npx @workclaw/cli local --openclaw-path "C:\CustomPath\OpenClaw" --phone 18111657826 --user-pass yourpassword
|
|
135
|
+
|
|
136
|
+
# 开启调试模式
|
|
137
|
+
npx @workclaw/cli local --debug --phone 18111657826 --user-pass yourpassword
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 盒子设备安装
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# 交互式安装(会提示输入 AppKey 和 AppSecret)
|
|
144
|
+
npx @workclaw/cli box
|
|
77
145
|
|
|
78
|
-
|
|
146
|
+
# 指定参数
|
|
147
|
+
npx @workclaw/cli box --app-key your-app-key --app-secret your-app-secret
|
|
148
|
+
|
|
149
|
+
# 指定正式环境
|
|
150
|
+
npx @workclaw/cli box --env prod --app-key your-app-key --app-secret your-app-secret
|
|
151
|
+
|
|
152
|
+
# 自定义安装路径
|
|
153
|
+
npx @workclaw/cli box --openclaw-path "/custom/path" --app-key your-app-key --app-secret your-app-secret
|
|
154
|
+
|
|
155
|
+
# 开启调试模式
|
|
156
|
+
npx @workclaw/cli box --debug --app-key your-app-key --app-secret your-app-secret
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 🔧 技术实现
|
|
160
|
+
|
|
161
|
+
### 安装机制
|
|
162
|
+
|
|
163
|
+
1. **插件下载**
|
|
164
|
+
- 使用 `npm pack` 从 npm 镜像源下载插件包
|
|
165
|
+
- 默认使用腾讯云 npm 镜像:`https://mirrors.tencent.com/npm/`
|
|
166
|
+
- 支持重试机制(最多 3 次)
|
|
167
|
+
|
|
168
|
+
2. **文件解压**
|
|
169
|
+
- 使用 `tar.extract()` 解压到目标目录
|
|
170
|
+
- 自动创建必要的目录结构
|
|
171
|
+
|
|
172
|
+
3. **依赖安装**
|
|
173
|
+
- 使用 `npm install --omit=dev` 安装生产依赖
|
|
174
|
+
- 自动跳过开发依赖,减小安装体积
|
|
175
|
+
|
|
176
|
+
### 路径结构
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
~/.openclaw/ # 或自定义路径
|
|
180
|
+
├── openclaw.json # 主配置文件
|
|
181
|
+
├── extensions/
|
|
182
|
+
│ └── openclaw-workclaw/ # 插件目录
|
|
183
|
+
│ ├── package.json
|
|
184
|
+
│ ├── dist/
|
|
185
|
+
│ └── ...
|
|
186
|
+
├── workspace/ # 工作空间
|
|
187
|
+
└── .temp/ # 临时文件
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 路径验证
|
|
191
|
+
|
|
192
|
+
工具会自动验证用户输入的 `--openclaw-path` 参数:
|
|
193
|
+
- ✅ 必须是绝对路径
|
|
194
|
+
- ✅ 不能包含非法字符:`< > : " | ? *`
|
|
195
|
+
|
|
196
|
+
## ❓ 常见问题
|
|
197
|
+
|
|
198
|
+
### Q: 安装失败,提示"网络错误"?
|
|
199
|
+
|
|
200
|
+
**A**: 检查网络连接,可以尝试:
|
|
201
|
+
- 使用代理或 VPN
|
|
202
|
+
- 配置 npm 镜像源:`npm config set registry https://registry.npmmirror.com`
|
|
203
|
+
|
|
204
|
+
### Q: 提示"路径必须是绝对路径"?
|
|
205
|
+
|
|
206
|
+
**A**: `--openclaw-path` 需要使用绝对路径,例如:
|
|
207
|
+
- Windows: `C:\OpenClaw` 或 `C:/OpenClaw`
|
|
208
|
+
- Linux/macOS: `/opt/openclaw`
|
|
209
|
+
|
|
210
|
+
### Q: 如何查看详细日志?
|
|
211
|
+
|
|
212
|
+
**A**: 使用 `--debug` 参数:
|
|
213
|
+
```bash
|
|
214
|
+
npx @workclaw/cli local --debug --phone 18111657826 --user-pass yourpassword
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Q: 如何指定插件版本?
|
|
218
|
+
|
|
219
|
+
**A**: 使用 `--plugin-version` 参数:
|
|
220
|
+
```bash
|
|
221
|
+
npx @workclaw/cli local --plugin-version 1.0.100 --phone 18111657826 --user-pass yourpassword
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Q: local 和 box 命令有什么区别?
|
|
225
|
+
|
|
226
|
+
**A**:
|
|
227
|
+
- **local**: 需要用户登录,适合个人设备,支持多账号
|
|
228
|
+
- **box**: 无需登录,直接使用 appKey+appSecret,适合专用设备
|
|
229
|
+
|
|
230
|
+
## 🛠 开发
|
|
79
231
|
|
|
80
232
|
### 项目结构
|
|
81
233
|
|
|
@@ -83,12 +235,16 @@ workclaw --help
|
|
|
83
235
|
packages/cli/
|
|
84
236
|
├── src/
|
|
85
237
|
│ ├── bin/ # CLI 入口
|
|
86
|
-
│ ├──
|
|
87
|
-
│ ├──
|
|
88
|
-
│ ├──
|
|
89
|
-
│ ├──
|
|
238
|
+
│ ├── local/ # 本地账户安装模块
|
|
239
|
+
│ │ ├── installer/ # 安装器
|
|
240
|
+
│ │ ├── apis/ # API 调用
|
|
241
|
+
│ │ ├── types/ # 类型定义
|
|
242
|
+
│ │ ├── error/ # 错误处理
|
|
243
|
+
│ │ └── utils/ # 工具函数
|
|
244
|
+
│ ├── box/ # 盒子设备安装模块
|
|
90
245
|
│ ├── shared/ # 共享模块
|
|
91
246
|
│ └── utils/ # 工具函数
|
|
247
|
+
├── package.json
|
|
92
248
|
├── vite.config.ts
|
|
93
249
|
└── README.md
|
|
94
250
|
```
|
|
@@ -96,25 +252,38 @@ packages/cli/
|
|
|
96
252
|
### 构建
|
|
97
253
|
|
|
98
254
|
```bash
|
|
99
|
-
|
|
255
|
+
# 安装依赖
|
|
256
|
+
pnpm install
|
|
257
|
+
|
|
258
|
+
# 构建项目
|
|
259
|
+
pnpm build
|
|
260
|
+
|
|
261
|
+
# 代码检查
|
|
262
|
+
pnpm lint
|
|
263
|
+
|
|
264
|
+
# 自动修复
|
|
265
|
+
pnpm lint:fix
|
|
100
266
|
```
|
|
101
267
|
|
|
102
|
-
## 更新日志
|
|
268
|
+
## 📝 更新日志
|
|
103
269
|
|
|
104
|
-
### v1.0.
|
|
270
|
+
### v1.0.313 (2026-04-23)
|
|
271
|
+
|
|
272
|
+
- ✨ 新增 `--openclaw-path` 参数 - 支持自定义安装路径
|
|
273
|
+
- 🔧 新增路径验证功能 - 检查绝对路径和非法字符
|
|
274
|
+
- ⚡ 优化安装流程 - 使用 npm pack + tar 替代 openclaw 命令
|
|
275
|
+
- 🔒 移除 `--scenario` 参数 - 自动检测系统环境
|
|
276
|
+
- 📦 更新 npm 镜像源 - 使用腾讯云 npm 镜像
|
|
277
|
+
- 📝 完善文档和错误提示
|
|
278
|
+
|
|
279
|
+
### v1.0.30 (2026-04-08)
|
|
105
280
|
|
|
106
281
|
- ✨ 新增 local 命令 - 本地账户安装(需要登录)
|
|
107
282
|
- ✨ 新增 box 命令 - 盒子设备安装(无需登录)
|
|
108
283
|
- 🔧 重构命令结构,分离 local 和 box 命令
|
|
109
|
-
|
|
110
|
-
### v2.0.0 (2026-04-08)
|
|
111
|
-
|
|
112
|
-
- ✨ 新增 phone + userPass 认证方式
|
|
113
284
|
- 🔒 新增 RSA 密码加密
|
|
114
285
|
- 📝 新增完整请求日志
|
|
115
286
|
- 🎨 优化交互式提示和进度显示
|
|
116
|
-
- 🌐 支持 NPM 安装插件
|
|
117
|
-
- 🔧 统一错误码管理
|
|
118
287
|
|
|
119
288
|
### v1.0.0
|
|
120
289
|
|
|
@@ -122,18 +291,18 @@ npm run build # 构建
|
|
|
122
291
|
- ✨ 支持 appKey + appSecret 认证
|
|
123
292
|
- ✨ 支持多平台安装
|
|
124
293
|
|
|
125
|
-
## 许可证
|
|
294
|
+
## 📄 许可证
|
|
126
295
|
|
|
127
296
|
MIT License
|
|
128
297
|
|
|
129
|
-
## 联系方式
|
|
298
|
+
## 📞 联系方式
|
|
130
299
|
|
|
131
|
-
|
|
132
|
-
- 问题反馈: [Issue Tracker]()
|
|
300
|
+
如有问题,请联系项目维护者。
|
|
133
301
|
|
|
134
|
-
## 致谢
|
|
302
|
+
## 🙏 致谢
|
|
135
303
|
|
|
136
304
|
- [commander](https://github.com/tj/commander.js) - 命令行解析
|
|
137
305
|
- [chalk](https://github.com/chalk/chalk) - 彩色输出
|
|
138
306
|
- [ora](https://github.com/sindresorhus/ora) - 加载动画
|
|
139
307
|
- [axios](https://github.com/axios/axios) - HTTP 客户端
|
|
308
|
+
- [tar](https://github.com/isaacs/node-tar) - tar 文件解压
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/box/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,UAAU,CAAA;AAqDhE,qBAAa,YAAY;IAIX,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAa;gBAEX,MAAM,EAAE,kBAAkB;IAI9C,cAAc,IAAI,IAAI;IAatB,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/box/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,UAAU,CAAA;AAqDhE,qBAAa,YAAY;IAIX,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAa;gBAEX,MAAM,EAAE,kBAAkB;IAI9C,cAAc,IAAI,IAAI;IAatB,OAAO,CAAC,QAAQ;IAiChB,OAAO,CAAC,aAAa;IAMrB,aAAa,IAAI,MAAM;IAIvB,OAAO,CAAC,cAAc;IAOhB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YA0BhB,eAAe;YA0Bf,iBAAiB;YAoHjB,cAAc;CAiR7B"}
|
|
@@ -21,6 +21,19 @@ function debugLog(...args) {
|
|
|
21
21
|
console.log(chalk.gray(`[DEBUG]`), ...args);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
function validateOpenclawPath(openclawPath) {
|
|
25
|
+
debugLog(`[路径验证] 开始验证路径: ${openclawPath}`);
|
|
26
|
+
if (!path.isAbsolute(openclawPath)) {
|
|
27
|
+
debugLog(`[路径验证] 失败: 路径不是绝对路径`);
|
|
28
|
+
throw new Error(`路径必须是绝对路径,当前输入: ${openclawPath}`);
|
|
29
|
+
}
|
|
30
|
+
const invalidChars = /[<>:"|?*]/.test(openclawPath);
|
|
31
|
+
if (invalidChars) {
|
|
32
|
+
debugLog(`[路径验证] 失败: 路径包含特殊字符`);
|
|
33
|
+
throw new Error('路径不能包含特殊字符: < > : " | ? *');
|
|
34
|
+
}
|
|
35
|
+
debugLog(`[路径验证] 通过: ${openclawPath}`);
|
|
36
|
+
}
|
|
24
37
|
const ERROR_CODES$1 = {
|
|
25
38
|
APP_KEY_REQUIRED: "APP_KEY_REQUIRED",
|
|
26
39
|
APP_SECRET_REQUIRED: "APP_SECRET_REQUIRED",
|
|
@@ -124,31 +137,17 @@ class BoxInstaller {
|
|
|
124
137
|
}
|
|
125
138
|
debugLog("[验证配置] 配置检查通过");
|
|
126
139
|
}
|
|
127
|
-
validateOpenclawPath(openclawPath) {
|
|
128
|
-
debugLog(`[路径验证] 开始验证路径: ${openclawPath}`);
|
|
129
|
-
if (!path.isAbsolute(openclawPath)) {
|
|
130
|
-
debugLog("[路径验证] 失败: 不是绝对路径");
|
|
131
|
-
throw new AppError$1(
|
|
132
|
-
ERROR_CODES$1.INVALID_OPENCLAW_PATH,
|
|
133
|
-
`路径必须是绝对路径,当前输入: ${openclawPath}`
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
const invalidChars = /[<>:"|?*]/.test(openclawPath);
|
|
137
|
-
if (invalidChars) {
|
|
138
|
-
debugLog("[路径验证] 失败: 包含非法字符");
|
|
139
|
-
throw new AppError$1(
|
|
140
|
-
ERROR_CODES$1.INVALID_OPENCLAW_PATH,
|
|
141
|
-
'路径不能包含特殊字符: < > : " | ? *'
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
debugLog("[路径验证] 通过");
|
|
145
|
-
}
|
|
146
140
|
getPaths() {
|
|
147
141
|
const config = getConfig(this.config.env);
|
|
148
142
|
let baseDir;
|
|
149
143
|
if (this.config.openclawPath) {
|
|
150
144
|
debugLog(`[路径验证] 验证自定义路径: ${this.config.openclawPath}`);
|
|
151
|
-
|
|
145
|
+
try {
|
|
146
|
+
validateOpenclawPath(this.config.openclawPath);
|
|
147
|
+
debugLog("[路径验证] 通过");
|
|
148
|
+
} catch (error) {
|
|
149
|
+
throw new AppError$1(ERROR_CODES$1.INVALID_OPENCLAW_PATH, error.message);
|
|
150
|
+
}
|
|
152
151
|
baseDir = this.config.openclawPath;
|
|
153
152
|
} else {
|
|
154
153
|
const home = getHomeDir$1();
|
|
@@ -4781,25 +4780,6 @@ class LocalInstaller {
|
|
|
4781
4780
|
}
|
|
4782
4781
|
debugLog("[验证配置] 配置验证通过");
|
|
4783
4782
|
}
|
|
4784
|
-
validateOpenclawPath(openclawPath) {
|
|
4785
|
-
debugLog(`[路径验证] 开始验证路径: ${openclawPath}`);
|
|
4786
|
-
if (!path.isAbsolute(openclawPath)) {
|
|
4787
|
-
debugLog("[路径验证] 失败: 不是绝对路径");
|
|
4788
|
-
throw new AppError2(
|
|
4789
|
-
ERROR_CODES.INVALID_OPENCLAW_PATH,
|
|
4790
|
-
`路径必须是绝对路径,当前输入: ${openclawPath}`
|
|
4791
|
-
);
|
|
4792
|
-
}
|
|
4793
|
-
const invalidChars = /[<>:"|?*]/.test(openclawPath);
|
|
4794
|
-
if (invalidChars) {
|
|
4795
|
-
debugLog("[路径验证] 失败: 包含非法字符");
|
|
4796
|
-
throw new AppError2(
|
|
4797
|
-
ERROR_CODES.INVALID_OPENCLAW_PATH,
|
|
4798
|
-
'路径不能包含特殊字符: < > : " | ? *'
|
|
4799
|
-
);
|
|
4800
|
-
}
|
|
4801
|
-
debugLog("[路径验证] 通过");
|
|
4802
|
-
}
|
|
4803
4783
|
async install() {
|
|
4804
4784
|
try {
|
|
4805
4785
|
debugLog("[安装开始]");
|
|
@@ -4809,7 +4789,12 @@ class LocalInstaller {
|
|
|
4809
4789
|
let baseDir;
|
|
4810
4790
|
if (this.config.openclawPath) {
|
|
4811
4791
|
debugLog(`[路径验证] 验证自定义路径: ${this.config.openclawPath}`);
|
|
4812
|
-
|
|
4792
|
+
try {
|
|
4793
|
+
validateOpenclawPath(this.config.openclawPath);
|
|
4794
|
+
debugLog("[路径验证] 通过");
|
|
4795
|
+
} catch (error) {
|
|
4796
|
+
throw new AppError2(ERROR_CODES.INVALID_OPENCLAW_PATH, error.message);
|
|
4797
|
+
}
|
|
4813
4798
|
baseDir = this.config.openclawPath;
|
|
4814
4799
|
} else {
|
|
4815
4800
|
const homeDir = getHomeDir();
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/local/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA6B,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAuD/E,qBAAa,cAAc;IAIb,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAa;gBAEX,MAAM,EAAE,oBAAoB;IAIhD,cAAc,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/local/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA6B,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAuD/E,qBAAa,cAAc;IAIb,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAa;gBAEX,MAAM,EAAE,oBAAoB;IAIhD,cAAc,IAAI,IAAI;IAYhB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkD9B,aAAa,IAAI,MAAM;IAIvB,OAAO,CAAC,cAAc;YAOR,OAAO;YAoBP,kBAAkB;YAalB,eAAe;YAmBf,iBAAiB;YAmHjB,cAAc;CA+M7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/path.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAiB/D"}
|