openclawapi 1.0.0

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 ADDED
@@ -0,0 +1,328 @@
1
+ # OpenClaw Config Manager
2
+
3
+ 🔧 跨平台 OpenClaw/Clawdbot 配置管理工具
4
+
5
+ 一个交互式命令行工具,用于管理 OpenClaw 的中转站配置、模型切换、API Keys 等设置。
6
+
7
+ ## 特性
8
+
9
+ - ✅ **跨平台支持**: macOS、Linux、Windows 通用
10
+ - 🔄 **中转站管理**: 添加、编辑、删除、切换中转站
11
+ - 🤖 **模型配置**: 主模型切换、备用模型管理
12
+ - 🔑 **API Key 管理**: 安全地添加、查看、删除 API Keys
13
+ - ⚙️ **高级设置**: 并发数、工作区路径等配置
14
+ - 📋 **配置查看**: 一键查看当前完整配置
15
+ - 🎨 **友好界面**: 彩色交互式菜单
16
+
17
+ ## 安装
18
+
19
+ ### 方式 1: 使用 npx (推荐)
20
+
21
+ 无需安装,直接运行:
22
+
23
+ ```bash
24
+ npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
25
+ ```
26
+
27
+ ### 方式 2: 全局安装
28
+
29
+ ```bash
30
+ cd /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
31
+ npm install -g .
32
+ ```
33
+
34
+ 然后运行:
35
+
36
+ ```bash
37
+ openclaw-config
38
+ ```
39
+
40
+ ### 方式 3: 本地运行
41
+
42
+ ```bash
43
+ cd /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
44
+ npm install
45
+ npm start
46
+ ```
47
+
48
+ ## 前置要求
49
+
50
+ - Node.js >= 14.0.0
51
+ - 已安装并初始化 clawdbot (`clawdbot onboard`)
52
+
53
+ ## 使用指南
54
+
55
+ ### 启动工具
56
+
57
+ ```bash
58
+ npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
59
+ ```
60
+
61
+ ### 主菜单
62
+
63
+ ```
64
+ 🔧 OpenClaw 配置管理工具
65
+
66
+ ? 请选择操作:
67
+ 📡 管理中转站配置
68
+ 🤖 管理模型配置
69
+ 🔑 管理 API Keys
70
+ ⚙️ 高级设置
71
+ 📄 查看当前配置
72
+ ❌ 退出
73
+ ```
74
+
75
+ ### 1. 管理中转站配置
76
+
77
+ #### 添加新中转站
78
+
79
+ 1. 选择 "📡 管理中转站配置" → "➕ 添加新中转站"
80
+ 2. 输入中转站名称(例如:`claude-relay-1`)
81
+ 3. 输入 Base URL(例如:`https://yunyi.cfd/claude/v1`)
82
+ 4. 选择模型类型(Claude / GPT / Gemini / 其他)
83
+ 5. 选择或输入模型 ID
84
+ 6. 设置上下文窗口大小(默认 200000)
85
+ 7. 设置最大输出 tokens(默认 8192)
86
+
87
+ **示例配置:**
88
+
89
+ ```
90
+ 中转站名称: claude-relay-1
91
+ Base URL: https://yunyi.cfd/claude/v1
92
+ 模型类型: Claude (Anthropic)
93
+ 模型: Claude Sonnet 4.5
94
+ 上下文窗口: 200000
95
+ 最大输出: 8192
96
+ ```
97
+
98
+ #### 编辑中转站
99
+
100
+ 修改现有中转站的 URL、上下文窗口、最大输出等设置。
101
+
102
+ #### 删除中转站
103
+
104
+ 删除不再使用的中转站配置(会同时删除相关的 API Key)。
105
+
106
+ #### 切换主中转站
107
+
108
+ 快速切换当前使用的主中转站。
109
+
110
+ ### 2. 管理模型配置
111
+
112
+ #### 切换主模型
113
+
114
+ 从所有已配置的中转站中选择一个作为主模型。
115
+
116
+ #### 管理备用模型
117
+
118
+ 选择多个备用模型,按优先级排序。当主模型不可用时,系统会自动切换到备用模型。
119
+
120
+ ### 3. 管理 API Keys
121
+
122
+ #### 添加/更新 API Key
123
+
124
+ 1. 选择中转站
125
+ 2. 输入 API Key(输入时会隐藏显示)
126
+ 3. 自动保存到 `~/.clawdbot/agents/main/agent/auth-profiles.json`
127
+
128
+ #### 查看已配置的 Keys
129
+
130
+ 显示所有已配置的 API Keys(部分隐藏显示,例如:`sk-abc123...xyz789`)
131
+
132
+ #### 删除 API Key
133
+
134
+ 删除指定中转站的 API Key。
135
+
136
+ ### 4. 高级设置
137
+
138
+ 配置系统级参数:
139
+
140
+ - **最大并发任务数**: 同时运行的任务数量(默认 4)
141
+ - **子代理最大并发数**: 子代理的并发数量(默认 8)
142
+ - **工作区路径**: OpenClaw 工作区目录
143
+
144
+ ### 5. 查看当前配置
145
+
146
+ 显示完整的当前配置,包括:
147
+
148
+ - 主模型
149
+ - 备用模型列表
150
+ - 所有中转站详情
151
+ - 高级设置
152
+
153
+ ## 配置文件位置
154
+
155
+ ### macOS / Linux
156
+
157
+ - 主配置: `~/.clawdbot/openclaw.json`
158
+ - API Keys: `~/.clawdbot/agents/main/agent/auth-profiles.json`
159
+
160
+ ### Windows
161
+
162
+ - 主配置: `C:\Users\<用户名>\.clawdbot\openclaw.json`
163
+ - API Keys: `C:\Users\<用户名>\.clawdbot\agents\main\agent\auth-profiles.json`
164
+
165
+ ## 常见使用场景
166
+
167
+ ### 场景 1: 添加 Claude 中转站
168
+
169
+ ```bash
170
+ # 运行工具
171
+ npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
172
+
173
+ # 选择: 📡 管理中转站配置 → ➕ 添加新中转站
174
+ # 输入:
175
+ # 名称: claude-relay-1
176
+ # URL: https://yunyi.cfd/claude/v1
177
+ # 模型: Claude Sonnet 4.5
178
+ # 上下文: 200000
179
+ # 最大输出: 8192
180
+
181
+ # 然后: 🔑 管理 API Keys → ➕ 添加/更新 API Key
182
+ # 选择: claude-relay-1
183
+ # 输入: sk-your-api-key-here
184
+ ```
185
+
186
+ ### 场景 2: 配置主备中转站
187
+
188
+ ```bash
189
+ # 1. 添加主中转站
190
+ # 名称: claude-main
191
+ # URL: https://yunyi.cfd/claude/v1
192
+
193
+ # 2. 添加备用中转站
194
+ # 名称: claude-backup
195
+ # URL: https://yunyi.skem.cn/claude/v1
196
+
197
+ # 3. 设置主模型
198
+ # 选择: 🤖 管理模型配置 → 🔄 切换主模型
199
+ # 选择: claude-main
200
+
201
+ # 4. 设置备用模型
202
+ # 选择: 🤖 管理模型配置 → 📋 管理备用模型
203
+ # 勾选: claude-backup
204
+ ```
205
+
206
+ ### 场景 3: 切换到不同的模型
207
+
208
+ ```bash
209
+ # 选择: 🤖 管理模型配置 → 🔄 切换主模型
210
+ # 从列表中选择新的模型
211
+ ```
212
+
213
+ ## 验证配置
214
+
215
+ 配置完成后,运行以下命令验证:
216
+
217
+ ```bash
218
+ # 检查配置
219
+ clawdbot doctor
220
+
221
+ # 启动服务
222
+ clawdbot gateway
223
+ ```
224
+
225
+ ## 故障排除
226
+
227
+ ### 问题 1: 找不到配置文件
228
+
229
+ **错误**: `配置文件不存在: ~/.clawdbot/openclaw.json`
230
+
231
+ **解决**: 先运行 `clawdbot onboard` 初始化配置
232
+
233
+ ### 问题 2: 权限错误
234
+
235
+ **错误**: `EACCES: permission denied`
236
+
237
+ **解决**:
238
+ ```bash
239
+ # macOS/Linux
240
+ chmod 755 ~/.clawdbot
241
+
242
+ # 或使用 sudo
243
+ sudo npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
244
+ ```
245
+
246
+ ### 问题 3: Node.js 版本过低
247
+
248
+ **错误**: `Requires Node.js >= 14.0.0`
249
+
250
+ **解决**: 升级 Node.js
251
+ ```bash
252
+ # 使用 nvm
253
+ nvm install 18
254
+ nvm use 18
255
+ ```
256
+
257
+ ## 技术栈
258
+
259
+ - **inquirer**: 交互式命令行界面
260
+ - **chalk**: 彩色终端输出
261
+ - **fs-extra**: 增强的文件系统操作
262
+
263
+ ## 开发
264
+
265
+ ### 项目结构
266
+
267
+ ```
268
+ openclaw-config-manager/
269
+ ├── package.json # 项目配置
270
+ ├── cli.js # 主程序入口
271
+ ├── lib/
272
+ │ ├── config-manager.js # 配置文件管理
273
+ │ └── ui.js # 界面工具函数
274
+ └── README.md # 使用文档
275
+ ```
276
+
277
+ ### 本地开发
278
+
279
+ ```bash
280
+ cd /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
281
+ npm install
282
+ node cli.js
283
+ ```
284
+
285
+ ### 调试
286
+
287
+ ```bash
288
+ # 查看配置文件
289
+ cat ~/.clawdbot/openclaw.json
290
+
291
+ # 查看 API Keys
292
+ cat ~/.clawdbot/agents/main/agent/auth-profiles.json
293
+
294
+ # 备份配置
295
+ cp ~/.clawdbot/openclaw.json ~/.clawdbot/openclaw.json.backup
296
+ ```
297
+
298
+ ## 安全提示
299
+
300
+ - ⚠️ API Keys 以明文存储在 `auth-profiles.json` 中
301
+ - ⚠️ 不要将 `auth-profiles.json` 提交到版本控制
302
+ - ⚠️ 定期更换 API Keys
303
+ - ⚠️ 使用 `chmod 600` 限制文件权限
304
+
305
+ ```bash
306
+ chmod 600 ~/.clawdbot/agents/main/agent/auth-profiles.json
307
+ ```
308
+
309
+ ## 许可证
310
+
311
+ MIT
312
+
313
+ ## 支持
314
+
315
+ 如有问题,请查看:
316
+ - [OpenClaw 文档](../docs/OPENCLAW.md)
317
+ - [Clawdbot 官方文档](https://yunwu.apifox.cn/)
318
+
319
+ ## 更新日志
320
+
321
+ ### v1.0.0 (2026-02-01)
322
+
323
+ - ✅ 初始版本发布
324
+ - ✅ 支持中转站管理
325
+ - ✅ 支持模型配置
326
+ - ✅ 支持 API Key 管理
327
+ - ✅ 支持高级设置
328
+ - ✅ 跨平台支持(macOS/Linux/Windows)