openclawapi 1.3.13 → 1.3.14

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 (3) hide show
  1. package/README.md +87 -0
  2. package/cli.js +18 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -316,6 +316,82 @@ openclaw doctor
316
316
  openclaw gateway
317
317
  ```
318
318
 
319
+ ## 访问 Web Dashboard
320
+
321
+ ### 本地安装后访问
322
+
323
+ ```bash
324
+ # 方式1: 自动打开浏览器(推荐)
325
+ clawdbot dashboard
326
+
327
+ # 方式2: 仅显示 URL,手动复制到浏览器
328
+ clawdbot dashboard --no-open
329
+ ```
330
+
331
+ 访问地址格式:
332
+ ```
333
+ http://127.0.0.1:18789/?token=<你的token>
334
+ ```
335
+
336
+ > ⚠️ **必须带 `?token=` 参数访问**,否则页面会报错。
337
+
338
+ ### VPS 远程部署后访问(SSH 隧道)
339
+
340
+ 如果 OpenClaw 部署在 VPS 上,需要通过 SSH 隧道访问:
341
+
342
+ **步骤 1: 建立 SSH 隧道(保持终端运行)**
343
+ ```bash
344
+ ssh -N -L 18789:127.0.0.1:18789 -i <密钥路径> ubuntu@<服务器IP>
345
+ ```
346
+
347
+ **步骤 2: 浏览器访问**
348
+ ```
349
+ http://127.0.0.1:18789/?token=<token>
350
+ ```
351
+
352
+ **配置 SSH 快捷方式(推荐)**
353
+
354
+ 在 `~/.ssh/config` 添加:
355
+ ```
356
+ Host openclaw
357
+ HostName <服务器IP>
358
+ User ubuntu
359
+ IdentityFile ~/.ssh/openclaw-key
360
+ LocalForward 18789 localhost:18789
361
+ ```
362
+
363
+ 然后只需运行 `ssh openclaw -N` 即可建立隧道。
364
+
365
+ ### 其他访问方式
366
+
367
+ | 方式 | 命令/地址 | 适用场景 |
368
+ |------|----------|---------|
369
+ | TUI 终端界面 | `clawdbot tui` | 无图形界面环境 |
370
+ | 启动网关 | `clawdbot gateway` | 手动启动服务 |
371
+ | 查看状态 | `clawdbot status` | 检查服务状态 |
372
+ | 查看日志 | `clawdbot logs` | 排查问题 |
373
+
374
+ ### Dashboard 访问注意事项
375
+
376
+ | 事项 | 说明 |
377
+ |------|------|
378
+ | 必须带 Token | ❌ 不带 token 访问会报错 ✅ 正确: `http://127.0.0.1:18789/?token=xxx` |
379
+ | 获取 Token | 在服务器运行 `clawdbot dashboard --no-open` |
380
+ | 保持终端运行 | SSH 隧道断开则无法访问 |
381
+ | 安全设计 | Gateway 默认绑定 127.0.0.1,不直接暴露公网 |
382
+
383
+ ## Gateway API 端点
384
+
385
+ OpenClaw Gateway 支持以下 HTTP 端点(需在配置中启用):
386
+
387
+ | 端点 | 配置项 | 默认状态 |
388
+ |------|--------|---------|
389
+ | `/v1/chat/completions` | `gateway.http.endpoints.chatCompletions.enabled` | 关闭 |
390
+ | `/v1/responses` | `gateway.http.endpoints.responses.enabled` | 关闭 |
391
+ | `/tools/invoke` | - | 内部使用 |
392
+
393
+ > 注意:本工具的测试功能直接调用中转 API,不依赖 Gateway HTTP 端点。
394
+
319
395
  ## 故障排除
320
396
 
321
397
  ### 问题 1: 找不到配置文件
@@ -412,6 +488,17 @@ MIT
412
488
 
413
489
  ## 更新日志
414
490
 
491
+ ### v1.3.14 (2026-02-03)
492
+
493
+ - ✅ 测试连接改为通过 Gateway API 端点测试(与 Web Dashboard 使用相同端点)
494
+ - ✅ 测试成功即表示 Web Dashboard 可正常对话
495
+
496
+ ### v1.3.13 (2026-02-03)
497
+
498
+ - ✅ 测试连接改为:先重启 Gateway,再测试中转 API
499
+ - ✅ 修复 Gateway 重启命令兼容性(支持 openclaw/clawdbot/npx)
500
+ - ✅ 测试问题改为"你是什么模型?"获取更详细回复
501
+
415
502
  ### v1.0.0 (2026-02-01)
416
503
 
417
504
  - ✅ 初始版本发布
package/cli.js CHANGED
@@ -423,32 +423,38 @@ async function testConnection(paths) {
423
423
  console.log(chalk.gray(`模型: ${primary}`));
424
424
  console.log(chalk.gray(`Gateway: http://localhost:${gatewayPort}\n`));
425
425
 
426
+ // 获取 Gateway token
427
+ const gatewayToken = config.gateway?.auth?.token;
428
+ if (!gatewayToken) {
429
+ console.log(chalk.yellow('⚠️ Gateway token 未配置'));
430
+ return;
431
+ }
432
+
426
433
  // 步骤1: 先重启 Gateway 使配置生效
427
434
  console.log(chalk.cyan('步骤 1/2: 重启 Gateway 使配置生效...'));
428
435
  await restartGateway();
429
436
 
430
- // 步骤2: 直接测试中转 API 验证配置
431
- console.log(chalk.cyan(`\n步骤 2/2: 测试 ${typeLabel} 中转 API...`));
437
+ // 等待 Gateway 启动
438
+ console.log(chalk.gray(' 等待 Gateway 启动...'));
439
+ await new Promise(resolve => setTimeout(resolve, 2000));
440
+
441
+ // 步骤2: 通过 Gateway 端点测试(与 Web Dashboard 使用相同端点)
442
+ console.log(chalk.cyan(`\n步骤 2/2: 测试 Gateway API 端点 (与 Web Dashboard 相同)...`));
443
+ console.log(chalk.gray(` 端点: http://localhost:${gatewayPort}/v1/chat/completions`));
432
444
 
433
445
  try {
434
446
  const startTime = Date.now();
435
- let result;
436
-
437
- if (type === 'claude') {
438
- result = await testClaudeApi(provider.baseUrl, provider.apiKey, provider.models?.[0]?.id);
439
- } else {
440
- result = await testCodexApi(provider.baseUrl, provider.apiKey, provider.models?.[0]?.id);
441
- }
442
-
447
+ const result = await testGatewayApi(gatewayPort, gatewayToken, primary);
443
448
  const latency = Date.now() - startTime;
444
449
 
445
450
  if (result.success) {
446
- console.log(chalk.green(`\n✅ 测试成功!配置已生效`));
451
+ console.log(chalk.green(`\n✅ Gateway 测试成功!Web Dashboard 可正常使用`));
447
452
  console.log(chalk.cyan(` 响应时间: ${latency}ms`));
448
453
  console.log(chalk.yellow(` 模型回复: ${result.message}`));
449
454
  } else {
450
- console.log(chalk.red(`\n❌ ${typeLabel} API 连接失败`));
455
+ console.log(chalk.red(`\n❌ Gateway API 连接失败`));
451
456
  console.log(chalk.red(` 错误: ${result.error}`));
457
+ console.log(chalk.gray(`\n 提示: 如果 Gateway 未运行,请执行: openclaw gateway`));
452
458
  }
453
459
  } catch (error) {
454
460
  console.log(chalk.red(`❌ 测试失败: ${error.message}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawapi",
3
- "version": "1.3.13",
3
+ "version": "1.3.14",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "cli.js",
6
6
  "bin": {