galaxy-opc 0.5.5 → 0.5.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/bin/cli.mjs +73 -17
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -55,6 +55,14 @@ async function askYesNo(question, defaultYes = true) {
|
|
|
55
55
|
return ans.toLowerCase().startsWith("y");
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
function printQwenCodingPlanGuide() {
|
|
59
|
+
console.log(dim("\n 推荐路径:阿里通义千问(Coding Plan)"));
|
|
60
|
+
console.log(dim(" 1) 注册/登录阿里云账号:https://www.aliyun.com"));
|
|
61
|
+
console.log(dim(" 2) 开通 DashScope(百炼)服务:https://dashscope.aliyun.com"));
|
|
62
|
+
console.log(dim(" 3) 完成实名认证与套餐购买(按量或套餐包)"));
|
|
63
|
+
console.log(dim(" 4) 回到安装向导,选择「Qwen OAuth 扫码登录」即可使用\n"));
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
function separator(char = "─", len = 60) { console.log(gray(char.repeat(len))); }
|
|
59
67
|
|
|
60
68
|
// ─── 工具函数 ───────────────────────────────────────────────────────────────
|
|
@@ -416,8 +424,9 @@ async function cmdSetup() {
|
|
|
416
424
|
let defaultModel = null;
|
|
417
425
|
|
|
418
426
|
if (regionIdx === 0) {
|
|
427
|
+
printQwenCodingPlanGuide();
|
|
419
428
|
const cnIdx = await askChoice("选择国产模型", [
|
|
420
|
-
{ label: "通义千问 Qwen",
|
|
429
|
+
{ label: "通义千问 Qwen(推荐)", desc: "最稳妥:阿里 Coding Plan 路径,支持 OAuth 扫码", recommended: true },
|
|
421
430
|
{ label: "MiniMax", desc: "MiniMax-M2.1 — 200K 上下文,支持 OAuth 扫码" },
|
|
422
431
|
{ label: "豆包 Doubao(火山引擎)", desc: "doubao-seed-1-8 / GLM-4.7 / Kimi-K2.5" },
|
|
423
432
|
{ label: "Kimi(Moonshot AI)", desc: "kimi-k2.5 — 256K 上下文" },
|
|
@@ -431,28 +440,50 @@ async function cmdSetup() {
|
|
|
431
440
|
{ label: "DashScope API Key", desc: "从 dashscope.aliyun.com 获取" },
|
|
432
441
|
]);
|
|
433
442
|
if (m === 0) {
|
|
434
|
-
console.log(gray("\n
|
|
443
|
+
console.log(gray("\n 浏览器即将打开,扫码登录通义千问(qwen-portal)...\n"));
|
|
435
444
|
const doLogin = await askYesNo(" 现在执行登录?", true);
|
|
436
445
|
if (doLogin) {
|
|
437
446
|
try {
|
|
438
447
|
await runCommand("openclaw", ["models", "auth", "login", "--provider", "qwen-portal"]);
|
|
439
448
|
console.log(green("\n ✓ Qwen OAuth 登录成功"));
|
|
449
|
+
defaultModel = "qwen-portal/qwen-max";
|
|
450
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: "qwen-portal/qwen-max" } } } });
|
|
440
451
|
} catch {
|
|
441
|
-
console.log(yellow("\n !
|
|
452
|
+
console.log(yellow("\n ! Qwen OAuth 登录失败"));
|
|
453
|
+
console.log(gray(" 你可以稍后手动运行: openclaw models auth login --provider qwen-portal"));
|
|
454
|
+
const useKey = await askYesNo(" 改用 DashScope API Key 方式继续配置?", true);
|
|
455
|
+
if (useKey) {
|
|
456
|
+
const key = await ask("\n 请输入 DashScope API Key (sk-...): ");
|
|
457
|
+
if (key) {
|
|
458
|
+
newEnv["DASHSCOPE_API_KEY"] = key;
|
|
459
|
+
defaultModel = "dashscope/qwen-plus";
|
|
460
|
+
newConfig = deepMerge(newConfig, {
|
|
461
|
+
models: { providers: { dashscope: { baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1", apiKey: key, api: "openai-completions", models: [{ id: "qwen-plus", name: "Qwen Plus", contextWindow: 128000, maxTokens: 8192 }] } } },
|
|
462
|
+
agents: { defaults: { model: { primary: "dashscope/qwen-plus" } } },
|
|
463
|
+
});
|
|
464
|
+
console.log(green(" ✓ 已保存"));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
442
467
|
}
|
|
468
|
+
} else {
|
|
469
|
+
console.log(dim(" 已跳过 OAuth 登录,可稍后执行:openclaw models auth login --provider qwen-portal"));
|
|
443
470
|
}
|
|
444
|
-
defaultModel = "qwen-portal/qwen-max";
|
|
445
|
-
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: "qwen-portal/qwen-max" } } } });
|
|
446
471
|
} else {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
472
|
+
printQwenCodingPlanGuide();
|
|
473
|
+
const hasKey = await askYesNo(" 你已经拿到 DashScope API Key 了吗?", false);
|
|
474
|
+
if (!hasKey) {
|
|
475
|
+
console.log(dim(" 已跳过 API Key 输入,稍后可运行 npx galaxy-opc setup 继续配置。"));
|
|
476
|
+
} else {
|
|
477
|
+
const key = await ask("\n 请输入 DashScope API Key (sk-...): ");
|
|
478
|
+
if (key) {
|
|
479
|
+
newEnv["DASHSCOPE_API_KEY"] = key;
|
|
480
|
+
defaultModel = "dashscope/qwen-plus";
|
|
481
|
+
newConfig = deepMerge(newConfig, {
|
|
482
|
+
models: { providers: { dashscope: { baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1", apiKey: key, api: "openai-completions", models: [{ id: "qwen-plus", name: "Qwen Plus", contextWindow: 128000, maxTokens: 8192 }] } } },
|
|
483
|
+
agents: { defaults: { model: { primary: "dashscope/qwen-plus" } } },
|
|
484
|
+
});
|
|
485
|
+
console.log(green(" ✓ 已保存"));
|
|
486
|
+
}
|
|
456
487
|
}
|
|
457
488
|
}
|
|
458
489
|
} else if (cnIdx === 1) {
|
|
@@ -467,12 +498,37 @@ async function cmdSetup() {
|
|
|
467
498
|
try {
|
|
468
499
|
await runCommand("openclaw", ["models", "auth", "login", "--provider", "minimax"]);
|
|
469
500
|
console.log(green("\n ✓ MiniMax OAuth 登录成功"));
|
|
501
|
+
defaultModel = "minimax/MiniMax-M2.5";
|
|
502
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: "minimax/MiniMax-M2.5" } } } });
|
|
470
503
|
} catch {
|
|
471
|
-
console.log(yellow("\n !
|
|
504
|
+
console.log(yellow("\n ! MiniMax OAuth 登录失败"));
|
|
505
|
+
const fallbackIdx = await askChoice("请选择后续处理", [
|
|
506
|
+
{ label: "切换到 Qwen(推荐)", desc: "按阿里 Coding Plan 路径继续,成功率更高", recommended: true },
|
|
507
|
+
{ label: "改用 MiniMax API Key", desc: "手动填写 API Key 继续配置" },
|
|
508
|
+
{ label: "稍后手动处理", desc: "先完成安装,后续再配置模型" },
|
|
509
|
+
]);
|
|
510
|
+
if (fallbackIdx === 0) {
|
|
511
|
+
printQwenCodingPlanGuide();
|
|
512
|
+
defaultModel = "qwen-portal/qwen-max";
|
|
513
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: "qwen-portal/qwen-max" } } } });
|
|
514
|
+
} else if (fallbackIdx === 1) {
|
|
515
|
+
const key = await ask("\n 请输入 MiniMax API Key: ");
|
|
516
|
+
if (key) {
|
|
517
|
+
newEnv["MINIMAX_API_KEY"] = key;
|
|
518
|
+
defaultModel = "minimax/MiniMax-M2.5";
|
|
519
|
+
newConfig = deepMerge(newConfig, {
|
|
520
|
+
models: { providers: { minimax: { baseUrl: "https://api.minimax.chat/v1", apiKey: key, api: "openai-completions", models: [{ id: "MiniMax-M2.5", name: "MiniMax M2.5", contextWindow: 200000, maxTokens: 16384 }] } } },
|
|
521
|
+
agents: { defaults: { model: { primary: "minimax/MiniMax-M2.5" } } },
|
|
522
|
+
});
|
|
523
|
+
console.log(green(" ✓ 已保存"));
|
|
524
|
+
}
|
|
525
|
+
} else {
|
|
526
|
+
console.log(dim(" 已跳过模型配置,可稍后执行:openclaw models auth login --provider minimax"));
|
|
527
|
+
}
|
|
472
528
|
}
|
|
529
|
+
} else {
|
|
530
|
+
console.log(dim(" 已跳过 MiniMax 登录,可稍后执行:openclaw models auth login --provider minimax"));
|
|
473
531
|
}
|
|
474
|
-
defaultModel = "minimax/MiniMax-M2.5";
|
|
475
|
-
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: "minimax/MiniMax-M2.5" } } } });
|
|
476
532
|
} else {
|
|
477
533
|
const key = await ask("\n 请输入 MiniMax API Key: ");
|
|
478
534
|
if (key) {
|