openclawapi 1.0.0 → 1.1.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.
Files changed (4) hide show
  1. package/README.md +120 -26
  2. package/cli.js +1241 -104
  3. package/lib/config-manager.js +405 -54
  4. package/package.json +3 -2
package/README.md CHANGED
@@ -4,11 +4,15 @@
4
4
 
5
5
  一个交互式命令行工具,用于管理 OpenClaw 的中转站配置、模型切换、API Keys 等设置。
6
6
 
7
+ > 说明:本工具默认只对 Claude / GPT 预设做优化与保障,其他模型保留入口但不保证可用,建议走 OpenClaw 配置页面或官方流程。
8
+
7
9
  ## 特性
8
10
 
9
11
  - ✅ **跨平台支持**: macOS、Linux、Windows 通用
10
12
  - 🔄 **中转站管理**: 添加、编辑、删除、切换中转站
11
13
  - 🤖 **模型配置**: 主模型切换、备用模型管理
14
+ - 🧭 **端点切换**: 一键切换中转 API 接入点
15
+ - 🧩 **模型切换**: 快速切换模型型号(仅 GPT/Claude 预设)
12
16
  - 🔑 **API Key 管理**: 安全地添加、查看、删除 API Keys
13
17
  - ⚙️ **高级设置**: 并发数、工作区路径等配置
14
18
  - 📋 **配置查看**: 一键查看当前完整配置
@@ -21,26 +25,26 @@
21
25
  无需安装,直接运行:
22
26
 
23
27
  ```bash
24
- npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
28
+ npx openclawapi
25
29
  ```
26
30
 
27
31
  ### 方式 2: 全局安装
28
32
 
29
33
  ```bash
30
- cd /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
34
+ cd /Users/mx/Documents/自动化/OpenClaw/Service/OpenClawApi
31
35
  npm install -g .
32
36
  ```
33
37
 
34
38
  然后运行:
35
39
 
36
40
  ```bash
37
- openclaw-config
41
+ openclawapi
38
42
  ```
39
43
 
40
44
  ### 方式 3: 本地运行
41
45
 
42
46
  ```bash
43
- cd /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
47
+ cd /Users/mx/Documents/自动化/OpenClaw/Service/OpenClawApi
44
48
  npm install
45
49
  npm start
46
50
  ```
@@ -48,25 +52,76 @@ npm start
48
52
  ## 前置要求
49
53
 
50
54
  - Node.js >= 14.0.0
51
- - 已安装并初始化 clawdbot (`clawdbot onboard`)
55
+ - 已安装并初始化 OpenClaw(`openclaw onboard`)或 Clawdbot(`clawdbot onboard`)
52
56
 
53
57
  ## 使用指南
54
58
 
55
59
  ### 启动工具
56
60
 
57
61
  ```bash
58
- npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
62
+ npx openclawapi
63
+ ```
64
+
65
+ ## 给客户看的:安装 OpenClaw 后如何接入我们的 API
66
+
67
+ > 建议优先用本工具配置(云逸 Claude/GPT 中转在网页端校验较严格,容易报 invalid config)。
68
+
69
+ ### 步骤 1:完成 OpenClaw 初始化
70
+
71
+ ```bash
72
+ openclaw onboard
73
+ ```
74
+
75
+ ### 步骤 2:运行本工具并选择快速配置向导
76
+
77
+ ```bash
78
+ npx openclawapi
79
+ ```
80
+
81
+ 进入后选择 **「🚀 快速配置向导」**,按提示填写:
82
+
83
+ **Claude(Anthropic Messages)**
84
+ - API:`anthropic-messages`
85
+ - Base URL(任选其一,必须完整路径)
86
+ `https://yunyi.skem.cn/claude/v1/messages`
87
+ `https://yunyi.cfd/claude/v1/messages`
88
+ - 模型:`claude-opus-4-5` / `claude-sonnet-4-5` / `claude-haiku-4-5`
89
+ - API Key:Claude 专用 Key(与 Codex 不通用)
90
+
91
+ **Codex / GPT(OpenAI Responses)**
92
+ - API:`openai-responses`
93
+ - Base URL(任选其一,必须完整路径)
94
+ `https://yunyi.skem.cn/codex/response`
95
+ `https://yunyi.cfd/codex/response`
96
+ - 模型:`gpt-5.2` / `gpt-5.2-codex`
97
+ - API Key:Codex 专用 Key(与 Claude 不通用)
98
+
99
+ > 需要多个节点可用时,可在向导里添加备用端点,或后续使用“端点切换/测速切换”。
100
+
101
+ ### 步骤 3:重启网关
102
+
103
+ ```bash
104
+ openclaw gateway restart
59
105
  ```
60
106
 
107
+ ### 步骤 4:验证
108
+
109
+ - 打开 OpenClaw 网页端 Chat 测试
110
+ - 或执行 `openclaw doctor`
111
+
61
112
  ### 主菜单
62
113
 
63
114
  ```
64
115
  🔧 OpenClaw 配置管理工具
65
116
 
66
117
  ? 请选择操作:
118
+ 🚀 快速配置向导 (URL/Key/Token/Workspace)
67
119
  📡 管理中转站配置
120
+ 🧭 快速切换中转端点
68
121
  🤖 管理模型配置
69
- 🔑 管理 API Keys
122
+ 🧩 快速切换模型
123
+ 🔑 管理 API Keys / Tokens
124
+ ⚡ 测速并切换中转站
70
125
  ⚙️ 高级设置
71
126
  📄 查看当前配置
72
127
  ❌ 退出
@@ -78,8 +133,8 @@ npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
78
133
 
79
134
  1. 选择 "📡 管理中转站配置" → "➕ 添加新中转站"
80
135
  2. 输入中转站名称(例如:`claude-relay-1`)
81
- 3. 输入 Base URL(例如:`https://yunyi.cfd/claude/v1`)
82
- 4. 选择模型类型(Claude / GPT / Gemini / 其他)
136
+ 3. 输入 Base URL(例如:`https://yunyi.cfd/claude/v1/messages`)
137
+ 4. 选择模型类型(Claude / Codex / 其他)
83
138
  5. 选择或输入模型 ID
84
139
  6. 设置上下文窗口大小(默认 200000)
85
140
  7. 设置最大输出 tokens(默认 8192)
@@ -88,7 +143,7 @@ npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
88
143
 
89
144
  ```
90
145
  中转站名称: claude-relay-1
91
- Base URL: https://yunyi.cfd/claude/v1
146
+ Base URL: https://yunyi.cfd/claude/v1/messages
92
147
  模型类型: Claude (Anthropic)
93
148
  模型: Claude Sonnet 4.5
94
149
  上下文窗口: 200000
@@ -123,7 +178,7 @@ Base URL: https://yunyi.cfd/claude/v1
123
178
 
124
179
  1. 选择中转站
125
180
  2. 输入 API Key(输入时会隐藏显示)
126
- 3. 自动保存到 `~/.clawdbot/agents/main/agent/auth-profiles.json`
181
+ 3. 自动保存到 `~/.openclaw/agents/main/agent/auth-profiles.json`(或旧版 `~/.clawdbot/agent/auth-profiles.json`)
127
182
 
128
183
  #### 查看已配置的 Keys
129
184
 
@@ -152,15 +207,54 @@ Base URL: https://yunyi.cfd/claude/v1
152
207
 
153
208
  ## 配置文件位置
154
209
 
155
- ### macOS / Linux
210
+ ### OpenClaw (macOS / Linux / Windows)
211
+
212
+ - 主配置: `~/.openclaw/openclaw.json`(JSON5)
213
+ - API Keys: `~/.openclaw/agents/<agent>/agent/auth-profiles.json`(默认 `main`)
214
+
215
+ ### Clawdbot 兼容 (旧版)
216
+
217
+ - 主配置: `~/.clawdbot/clawdbot.json`
218
+ - API Keys: `~/.clawdbot/agent/auth-profiles.json`
219
+
220
+ ### 环境变量覆盖
221
+
222
+ ```bash
223
+ # OpenClaw
224
+ OPENCLAW_CONFIG_PATH=/path/to/openclaw.json
225
+ OPENCLAW_STATE_DIR=/path/to/.openclaw
226
+ OPENCLAW_AGENT_DIR=/path/to/agents/main/agent
227
+ OPENCLAW_AGENT=main
228
+ OPENCLAW_PROFILE=default
229
+
230
+ # Clawdbot
231
+ CLAWDBOT_CONFIG_PATH=/path/to/clawdbot.json
232
+ CLAWDBOT_STATE_DIR=/path/to/.clawdbot
233
+ CLAWDBOT_AGENT_DIR=/path/to/agent
234
+ CLAWDBOT_AGENT=main
235
+ ```
236
+
237
+ ## 支持范围(本工具预设)
238
+
239
+ - Claude:`claude-opus-4-5` / `claude-sonnet-4-5` / `claude-haiku-4-5`
240
+ - GPT:`gpt-5.2` / `gpt-5.2-codex`
241
+ - Claude 与 GPT 的 API Key **互不通用**,需要分别配置
242
+
243
+ ## 云逸节点与路径规则
244
+
245
+ **基础域名(任选其一)**
156
246
 
157
- - 主配置: `~/.clawdbot/openclaw.json`
158
- - API Keys: `~/.clawdbot/agents/main/agent/auth-profiles.json`
247
+ - `https://yunyi.skem.cn`
248
+ - `https://yunyi.cfd`
249
+ - `https://cdn1.yunyi.cfd`
250
+ - `https://cdn2.yunyi.cfd`
251
+ - `http://47.99.42.193`
252
+ - `http://47.97.100.10`
159
253
 
160
- ### Windows
254
+ **路径**
161
255
 
162
- - 主配置: `C:\Users\<用户名>\.clawdbot\openclaw.json`
163
- - API Keys: `C:\Users\<用户名>\.clawdbot\agents\main\agent\auth-profiles.json`
256
+ - Claude:`/claude/v1/messages`
257
+ - Codex:`/codex/response`
164
258
 
165
259
  ## 常见使用场景
166
260
 
@@ -168,12 +262,12 @@ Base URL: https://yunyi.cfd/claude/v1
168
262
 
169
263
  ```bash
170
264
  # 运行工具
171
- npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
265
+ npx openclawapi
172
266
 
173
267
  # 选择: 📡 管理中转站配置 → ➕ 添加新中转站
174
268
  # 输入:
175
269
  # 名称: claude-relay-1
176
- # URL: https://yunyi.cfd/claude/v1
270
+ # URL: https://yunyi.cfd/claude/v1/messages
177
271
  # 模型: Claude Sonnet 4.5
178
272
  # 上下文: 200000
179
273
  # 最大输出: 8192
@@ -188,11 +282,11 @@ npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
188
282
  ```bash
189
283
  # 1. 添加主中转站
190
284
  # 名称: claude-main
191
- # URL: https://yunyi.cfd/claude/v1
285
+ # URL: https://yunyi.cfd/claude/v1/messages
192
286
 
193
287
  # 2. 添加备用中转站
194
288
  # 名称: claude-backup
195
- # URL: https://yunyi.skem.cn/claude/v1
289
+ # URL: https://yunyi.skem.cn/claude/v1/messages
196
290
 
197
291
  # 3. 设置主模型
198
292
  # 选择: 🤖 管理模型配置 → 🔄 切换主模型
@@ -216,10 +310,10 @@ npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
216
310
 
217
311
  ```bash
218
312
  # 检查配置
219
- clawdbot doctor
313
+ openclaw doctor
220
314
 
221
315
  # 启动服务
222
- clawdbot gateway
316
+ openclaw gateway
223
317
  ```
224
318
 
225
319
  ## 故障排除
@@ -240,7 +334,7 @@ clawdbot gateway
240
334
  chmod 755 ~/.clawdbot
241
335
 
242
336
  # 或使用 sudo
243
- sudo npx /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
337
+ sudo npx openclawapi
244
338
  ```
245
339
 
246
340
  ### 问题 3: Node.js 版本过低
@@ -265,7 +359,7 @@ nvm use 18
265
359
  ### 项目结构
266
360
 
267
361
  ```
268
- openclaw-config-manager/
362
+ Service/OpenClawApi/
269
363
  ├── package.json # 项目配置
270
364
  ├── cli.js # 主程序入口
271
365
  ├── lib/
@@ -277,7 +371,7 @@ openclaw-config-manager/
277
371
  ### 本地开发
278
372
 
279
373
  ```bash
280
- cd /Users/mx/Documents/自动化/OpenClaw/openclaw-config-manager
374
+ cd /Users/mx/Documents/自动化/OpenClaw/Service/OpenClawApi
281
375
  npm install
282
376
  node cli.js
283
377
  ```