openclawapi 1.3.5 → 1.3.7
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/cli.js +15 -12
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -415,37 +415,40 @@ async function testConnection(paths) {
|
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
console.log(chalk.gray(
|
|
418
|
+
console.log(chalk.gray(`当前激活: ${typeLabel}`));
|
|
419
419
|
console.log(chalk.gray(`节点: ${provider.baseUrl}`));
|
|
420
420
|
console.log(chalk.gray(`模型: ${provider.models?.[0]?.id || 'N/A'}\n`));
|
|
421
421
|
|
|
422
|
+
// 直接测试中转 API
|
|
423
|
+
console.log(chalk.cyan(`正在测试 ${typeLabel} API...`));
|
|
424
|
+
|
|
422
425
|
try {
|
|
423
426
|
const startTime = Date.now();
|
|
424
427
|
|
|
425
428
|
if (type === 'claude') {
|
|
426
|
-
// Claude API 测试
|
|
427
429
|
const result = await testClaudeApi(provider.baseUrl, provider.apiKey, provider.models?.[0]?.id);
|
|
428
430
|
const latency = Date.now() - startTime;
|
|
429
431
|
|
|
430
432
|
if (result.success) {
|
|
431
|
-
console.log(chalk.green(
|
|
433
|
+
console.log(chalk.green(`\n✅ ${typeLabel} API 连接成功!`));
|
|
432
434
|
console.log(chalk.cyan(` 响应时间: ${latency}ms`));
|
|
433
|
-
console.log(chalk.
|
|
435
|
+
console.log(chalk.yellow(` 模型回复: ${result.message}`));
|
|
436
|
+
console.log(chalk.gray(`\n💡 配置已生效,OpenClaw 的所有对话渠道(Telegram/Discord/Web等)都将使用此模型。`));
|
|
434
437
|
} else {
|
|
435
|
-
console.log(chalk.red(
|
|
438
|
+
console.log(chalk.red(`\n❌ ${typeLabel} API 连接失败`));
|
|
436
439
|
console.log(chalk.red(` 错误: ${result.error}`));
|
|
437
440
|
}
|
|
438
441
|
} else {
|
|
439
|
-
// Codex API 测试
|
|
440
442
|
const result = await testCodexApi(provider.baseUrl, provider.apiKey, provider.models?.[0]?.id);
|
|
441
443
|
const latency = Date.now() - startTime;
|
|
442
444
|
|
|
443
445
|
if (result.success) {
|
|
444
|
-
console.log(chalk.green(
|
|
446
|
+
console.log(chalk.green(`\n✅ ${typeLabel} API 连接成功!`));
|
|
445
447
|
console.log(chalk.cyan(` 响应时间: ${latency}ms`));
|
|
446
|
-
console.log(chalk.
|
|
448
|
+
console.log(chalk.yellow(` 模型回复: ${result.message}`));
|
|
449
|
+
console.log(chalk.gray(`\n💡 配置已生效,OpenClaw 的所有对话渠道(Telegram/Discord/Web等)都将使用此模型。`));
|
|
447
450
|
} else {
|
|
448
|
-
console.log(chalk.red(
|
|
451
|
+
console.log(chalk.red(`\n❌ ${typeLabel} API 连接失败`));
|
|
449
452
|
console.log(chalk.red(` 错误: ${result.error}`));
|
|
450
453
|
}
|
|
451
454
|
}
|
|
@@ -462,8 +465,8 @@ function testClaudeApi(baseUrl, apiKey, model) {
|
|
|
462
465
|
|
|
463
466
|
const postData = JSON.stringify({
|
|
464
467
|
model: model || 'claude-sonnet-4-5',
|
|
465
|
-
max_tokens:
|
|
466
|
-
messages: [{ role: 'user', content: '
|
|
468
|
+
max_tokens: 100,
|
|
469
|
+
messages: [{ role: 'user', content: '你是什么模型?请简短回答。' }]
|
|
467
470
|
});
|
|
468
471
|
|
|
469
472
|
const options = {
|
|
@@ -522,7 +525,7 @@ function testCodexApi(baseUrl, apiKey, model) {
|
|
|
522
525
|
|
|
523
526
|
const postData = JSON.stringify({
|
|
524
527
|
model: model || 'gpt-5.2',
|
|
525
|
-
input: '
|
|
528
|
+
input: '你是什么模型?请简短回答。'
|
|
526
529
|
});
|
|
527
530
|
|
|
528
531
|
const options = {
|