galaxy-opc 0.3.3 → 0.3.5
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 +75 -26
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -128,8 +128,6 @@ const HOME = os.homedir();
|
|
|
128
128
|
const STATE_DIR = path.join(HOME, ".openclaw");
|
|
129
129
|
const CONFIG_PATH = path.join(STATE_DIR, "openclaw.json");
|
|
130
130
|
const ENV_PATH = path.join(STATE_DIR, ".env");
|
|
131
|
-
// 插件由 openclaw plugins install 写入 ~/.openclaw/extensions/galaxy-opc-plugin
|
|
132
|
-
const PLUGIN_INSTALL_DIR = path.join(STATE_DIR, "extensions", "galaxy-opc-plugin");
|
|
133
131
|
|
|
134
132
|
// ─── 命令路由 ───────────────────────────────────────────────────────────────
|
|
135
133
|
const args = process.argv.slice(2);
|
|
@@ -208,8 +206,9 @@ ${bold(cyan(" ╚════════════════════
|
|
|
208
206
|
console.log(bold(" 步骤 3 / 4 安装 OPC Platform 插件"));
|
|
209
207
|
separator();
|
|
210
208
|
|
|
211
|
-
|
|
212
|
-
|
|
209
|
+
const pluginInstallDir = path.join(STATE_DIR, "extensions", "galaxy-opc-plugin");
|
|
210
|
+
if (fs.existsSync(pluginInstallDir)) {
|
|
211
|
+
console.log(yellow(` 检测到插件已存在: ${pluginInstallDir}`));
|
|
213
212
|
const update = await askYesNo(" 更新到最新版本?", true);
|
|
214
213
|
if (!update) {
|
|
215
214
|
console.log(green(" ✓ 跳过,使用现有版本"));
|
|
@@ -225,6 +224,25 @@ ${bold(cyan(" ╚════════════════════
|
|
|
225
224
|
}
|
|
226
225
|
|
|
227
226
|
async function installPlugin() {
|
|
227
|
+
// 清理可能残留的旧插件路径配置,否则 openclaw 会因路径不存在而拒绝启动
|
|
228
|
+
const cfg = readJson(CONFIG_PATH);
|
|
229
|
+
let dirty = false;
|
|
230
|
+
if (cfg.plugins?.load?.paths?.length) {
|
|
231
|
+
delete cfg.plugins.load.paths;
|
|
232
|
+
dirty = true;
|
|
233
|
+
}
|
|
234
|
+
if (cfg.plugins?.load && Object.keys(cfg.plugins.load).length === 0) {
|
|
235
|
+
delete cfg.plugins.load;
|
|
236
|
+
}
|
|
237
|
+
if (cfg.plugins?.entries?.["opc-platform"]) {
|
|
238
|
+
delete cfg.plugins.entries["opc-platform"];
|
|
239
|
+
dirty = true;
|
|
240
|
+
}
|
|
241
|
+
if (dirty) {
|
|
242
|
+
writeJson(CONFIG_PATH, cfg);
|
|
243
|
+
console.log(dim(" 已清理旧插件配置"));
|
|
244
|
+
}
|
|
245
|
+
|
|
228
246
|
console.log(dim(" 正在通过 OpenClaw 安装插件...\n"));
|
|
229
247
|
try {
|
|
230
248
|
await runCommand("openclaw", ["plugins", "install", "galaxy-opc-plugin"]);
|
|
@@ -246,19 +264,14 @@ async function cmdSetup() {
|
|
|
246
264
|
let newConfig = readJson(CONFIG_PATH);
|
|
247
265
|
let newEnv = readEnv(ENV_PATH);
|
|
248
266
|
|
|
249
|
-
//
|
|
250
|
-
const existingPaths = newConfig.plugins?.load?.paths ?? [];
|
|
251
|
-
const mergedPaths = Array.from(new Set([...existingPaths, PLUGIN_INSTALL_DIR]));
|
|
267
|
+
// gateway.mode 必须设置否则无法启动
|
|
252
268
|
newConfig = deepMerge(newConfig, {
|
|
253
269
|
gateway: { mode: "local" },
|
|
254
|
-
plugins: { load: { paths: mergedPaths } },
|
|
255
270
|
});
|
|
256
271
|
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
if (newConfig.plugins?.entries?.["opc-platform"])
|
|
260
|
-
delete newConfig.plugins.entries["opc-platform"];
|
|
261
|
-
}
|
|
272
|
+
// 清理残留的旧插件路径(由旧版向导写入,openclaw 会因路径不存在报错)
|
|
273
|
+
if (newConfig.plugins?.load?.paths) delete newConfig.plugins.load.paths;
|
|
274
|
+
if (newConfig.plugins?.entries?.["opc-platform"]) delete newConfig.plugins.entries["opc-platform"];
|
|
262
275
|
|
|
263
276
|
const regionIdx = await askChoice("选择 AI 模型地区", [
|
|
264
277
|
{ label: "国产模型", desc: "通义千问 / MiniMax / 豆包 / Kimi / DeepSeek", recommended: true },
|
|
@@ -294,11 +307,19 @@ async function cmdSetup() {
|
|
|
294
307
|
console.log(yellow("\n ! 稍后可手动运行: openclaw models auth login --provider qwen-portal"));
|
|
295
308
|
}
|
|
296
309
|
}
|
|
297
|
-
defaultModel = "qwen-max";
|
|
298
|
-
newConfig = deepMerge(newConfig, { agents: { defaults: { model:
|
|
310
|
+
defaultModel = "qwen-portal/qwen-max";
|
|
311
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: "qwen-portal/qwen-max" } } } });
|
|
299
312
|
} else {
|
|
300
313
|
const key = await ask("\n 请输入 DashScope API Key (sk-...): ");
|
|
301
|
-
if (key) {
|
|
314
|
+
if (key) {
|
|
315
|
+
newEnv["DASHSCOPE_API_KEY"] = key;
|
|
316
|
+
defaultModel = "dashscope/qwen-plus";
|
|
317
|
+
newConfig = deepMerge(newConfig, {
|
|
318
|
+
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 }] } } },
|
|
319
|
+
agents: { defaults: { model: { primary: "dashscope/qwen-plus" } } },
|
|
320
|
+
});
|
|
321
|
+
console.log(green(" ✓ 已保存"));
|
|
322
|
+
}
|
|
302
323
|
}
|
|
303
324
|
} else if (cnIdx === 1) {
|
|
304
325
|
// MiniMax
|
|
@@ -316,11 +337,19 @@ async function cmdSetup() {
|
|
|
316
337
|
console.log(yellow("\n ! 稍后可手动运行: openclaw models auth login --provider minimax"));
|
|
317
338
|
}
|
|
318
339
|
}
|
|
319
|
-
defaultModel = "MiniMax-M2.
|
|
320
|
-
newConfig = deepMerge(newConfig, { agents: { defaults: { model: "MiniMax-M2.
|
|
340
|
+
defaultModel = "minimax/MiniMax-M2.5";
|
|
341
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: "minimax/MiniMax-M2.5" } } } });
|
|
321
342
|
} else {
|
|
322
343
|
const key = await ask("\n 请输入 MiniMax API Key: ");
|
|
323
|
-
if (key) {
|
|
344
|
+
if (key) {
|
|
345
|
+
newEnv["MINIMAX_API_KEY"] = key;
|
|
346
|
+
defaultModel = "minimax/MiniMax-M2.5";
|
|
347
|
+
newConfig = deepMerge(newConfig, {
|
|
348
|
+
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 }] } } },
|
|
349
|
+
agents: { defaults: { model: { primary: "minimax/MiniMax-M2.5" } } },
|
|
350
|
+
});
|
|
351
|
+
console.log(green(" ✓ 已保存"));
|
|
352
|
+
}
|
|
324
353
|
}
|
|
325
354
|
} else if (cnIdx === 2) {
|
|
326
355
|
// Doubao
|
|
@@ -331,15 +360,30 @@ async function cmdSetup() {
|
|
|
331
360
|
]);
|
|
332
361
|
const modelMap = ["doubao-seed-1-8-251228", "glm-4-7-251222", "kimi-k2-5-260127"];
|
|
333
362
|
const key = await ask("\n 请输入火山引擎 API Key (console.volcengine.com): ");
|
|
334
|
-
if (key) {
|
|
363
|
+
if (key) {
|
|
364
|
+
newEnv["VOLC_ACCESSKEY"] = key;
|
|
365
|
+
defaultModel = `volcengine/${modelMap[modelIdx]}`;
|
|
366
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: defaultModel } } } });
|
|
367
|
+
console.log(green(" ✓ 已保存"));
|
|
368
|
+
}
|
|
335
369
|
} else if (cnIdx === 3) {
|
|
336
370
|
// Kimi
|
|
337
371
|
const key = await ask("\n 请输入 Moonshot API Key (platform.moonshot.ai): ");
|
|
338
|
-
if (key) {
|
|
372
|
+
if (key) {
|
|
373
|
+
newEnv["MOONSHOT_API_KEY"] = key;
|
|
374
|
+
defaultModel = "moonshot/moonshot-v1-8k";
|
|
375
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: defaultModel } } } });
|
|
376
|
+
console.log(green(" ✓ 已保存"));
|
|
377
|
+
}
|
|
339
378
|
} else {
|
|
340
379
|
// DeepSeek
|
|
341
380
|
const key = await ask("\n 请输入 DeepSeek API Key (platform.deepseek.com): ");
|
|
342
|
-
if (key) {
|
|
381
|
+
if (key) {
|
|
382
|
+
newEnv["DEEPSEEK_API_KEY"] = key;
|
|
383
|
+
defaultModel = "deepseek/deepseek-chat";
|
|
384
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: defaultModel } } } });
|
|
385
|
+
console.log(green(" ✓ 已保存"));
|
|
386
|
+
}
|
|
343
387
|
}
|
|
344
388
|
|
|
345
389
|
} else if (regionIdx === 1) {
|
|
@@ -349,13 +393,18 @@ async function cmdSetup() {
|
|
|
349
393
|
{ label: "OpenRouter", desc: "聚合多家,一个 Key — openrouter.ai" },
|
|
350
394
|
]);
|
|
351
395
|
const cfgs = [
|
|
352
|
-
{ env: "OPENAI_API_KEY", model: "gpt-4o-mini",
|
|
353
|
-
{ env: "ANTHROPIC_API_KEY", model: "claude-3-5-haiku-latest",
|
|
354
|
-
{ env: "OPENROUTER_API_KEY", model: "openai/gpt-4o-mini",
|
|
396
|
+
{ env: "OPENAI_API_KEY", model: "openai/gpt-4o-mini", prompt: "OpenAI API Key (sk-...)" },
|
|
397
|
+
{ env: "ANTHROPIC_API_KEY", model: "anthropic/claude-3-5-haiku-latest", prompt: "Anthropic API Key (sk-ant-...)" },
|
|
398
|
+
{ env: "OPENROUTER_API_KEY", model: "openrouter/openai/gpt-4o-mini", prompt: "OpenRouter API Key (sk-or-...)" },
|
|
355
399
|
];
|
|
356
400
|
const cfg = cfgs[intlIdx];
|
|
357
401
|
const key = await ask(`\n 请输入 ${cfg.prompt}: `);
|
|
358
|
-
if (key) {
|
|
402
|
+
if (key) {
|
|
403
|
+
newEnv[cfg.env] = key;
|
|
404
|
+
defaultModel = cfg.model;
|
|
405
|
+
newConfig = deepMerge(newConfig, { agents: { defaults: { model: { primary: defaultModel } } } });
|
|
406
|
+
console.log(green(" ✓ 已保存"));
|
|
407
|
+
}
|
|
359
408
|
} else {
|
|
360
409
|
console.log(yellow(`\n 已跳过,稍后手动编辑: ${gray(CONFIG_PATH)}`));
|
|
361
410
|
}
|