@workclaw/cli 1.0.329 → 1.0.331
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/dist/box/configs/index.d.ts +2 -0
- package/dist/box/configs/index.d.ts.map +1 -0
- package/dist/box/configs/model.d.ts +13 -0
- package/dist/box/configs/model.d.ts.map +1 -0
- package/dist/box/constants/index.d.ts +2 -0
- package/dist/box/constants/index.d.ts.map +1 -0
- package/dist/box/constants/model.d.ts +9 -0
- package/dist/box/constants/model.d.ts.map +1 -0
- package/dist/box/index.d.ts.map +1 -1
- package/dist/box/installer/installer.d.ts.map +1 -1
- package/dist/box/src/box.d.ts.map +1 -1
- package/dist/box/types/index.d.ts +14 -0
- package/dist/box/types/index.d.ts.map +1 -1
- package/dist/{index-CG5v9o0c.js → index-b2rw2uLv.js} +108 -43
- package/dist/index.js +1 -1
- package/dist/local/configs/index.d.ts +2 -0
- package/dist/local/configs/index.d.ts.map +1 -0
- package/dist/local/configs/model.d.ts +13 -0
- package/dist/local/configs/model.d.ts.map +1 -0
- package/dist/local/constants/index.d.ts +2 -0
- package/dist/local/constants/index.d.ts.map +1 -0
- package/dist/local/constants/model.d.ts +4 -0
- package/dist/local/constants/model.d.ts.map +1 -0
- package/dist/local/index.d.ts.map +1 -1
- package/dist/local/installer/installer.d.ts.map +1 -1
- package/dist/local/src/local.d.ts.map +1 -1
- package/dist/local/types/index.d.ts +6 -0
- package/dist/local/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/box/configs/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const MODEL_GENERAL_CONFIG: {
|
|
2
|
+
reasoning: boolean;
|
|
3
|
+
input: string[];
|
|
4
|
+
cost: {
|
|
5
|
+
input: number;
|
|
6
|
+
output: number;
|
|
7
|
+
cacheRead: number;
|
|
8
|
+
cacheWrite: number;
|
|
9
|
+
};
|
|
10
|
+
contextWindow: number;
|
|
11
|
+
maxTokens: number;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/box/configs/model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAMhC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/box/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const SUPPORTED_MODELS: readonly ["gpt-4.1-mini", "gpt-4o-mini", "gpt-5-chat", "gpt-5-mini"];
|
|
2
|
+
export type ModelType = typeof SUPPORTED_MODELS[number];
|
|
3
|
+
export declare const DEFAULT_MODEL: ModelType;
|
|
4
|
+
export declare const MODEL_ID_MAP: Record<ModelType, {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const DEFAULT_PROVIDER = "siliconflow-minimax";
|
|
9
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/box/constants/model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,sEAKnB,CAAA;AAEV,MAAM,MAAM,SAAS,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,aAAa,EAAE,SAAwB,CAAA;AAEpD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAKxE,CAAA;AAED,eAAO,MAAM,gBAAgB,wBAAwB,CAAA"}
|
package/dist/box/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/box/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/box/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAIxC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAcvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/box/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/box/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,UAAU,CAAA;AAiFhE,qBAAa,YAAY;IAIX,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAa;gBAEX,MAAM,EAAE,kBAAkB;IAI9C,cAAc,IAAI,IAAI;IAyBtB,OAAO,CAAC,QAAQ;IAoChB,OAAO,CAAC,aAAa;IAMrB,aAAa,IAAI,MAAM;IAIvB,OAAO,CAAC,cAAc;IAOhB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YA0BhB,eAAe;YA0Bf,iBAAiB;YAoHjB,cAAc;CA6R7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../../src/box/src/box.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../../src/box/src/box.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAU1C;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA+KzE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ModelType } from '../constants';
|
|
2
3
|
export interface BoxOptions {
|
|
3
4
|
env?: string;
|
|
4
5
|
appKey?: string;
|
|
@@ -8,6 +9,8 @@ export interface BoxOptions {
|
|
|
8
9
|
pluginVersion?: string;
|
|
9
10
|
openclawPath?: string;
|
|
10
11
|
debug?: boolean;
|
|
12
|
+
model?: ModelType;
|
|
13
|
+
mergeMode?: 'merge' | 'replace' | 'reset-keys';
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* BoxInstaller 配置验证 schema
|
|
@@ -25,6 +28,17 @@ export declare const BoxInstallerConfigSchema: z.ZodObject<{
|
|
|
25
28
|
appSecret: z.ZodString;
|
|
26
29
|
pluginVersion: z.ZodOptional<z.ZodString>;
|
|
27
30
|
openclawPath: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodString>>;
|
|
31
|
+
model: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
32
|
+
"gpt-4.1-mini": "gpt-4.1-mini";
|
|
33
|
+
"gpt-4o-mini": "gpt-4o-mini";
|
|
34
|
+
"gpt-5-chat": "gpt-5-chat";
|
|
35
|
+
"gpt-5-mini": "gpt-5-mini";
|
|
36
|
+
}>>>;
|
|
37
|
+
mergeMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
38
|
+
merge: "merge";
|
|
39
|
+
replace: "replace";
|
|
40
|
+
"reset-keys": "reset-keys";
|
|
41
|
+
}>>>;
|
|
28
42
|
}, z.core.$strip>;
|
|
29
43
|
export type BoxInstallerConfig = z.infer<typeof BoxInstallerConfigSchema>;
|
|
30
44
|
export interface InstallResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/box/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/box/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,YAAY,CAAA;CAC/C;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;iBAqBpC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb"}
|
|
@@ -193,6 +193,27 @@ class AppError2 extends Error {
|
|
|
193
193
|
function getHomeDir$1() {
|
|
194
194
|
return process$1.env.HOME || process$1.env.USERPROFILE || "";
|
|
195
195
|
}
|
|
196
|
+
const SUPPORTED_MODELS = [
|
|
197
|
+
"gpt-4.1-mini",
|
|
198
|
+
"gpt-4o-mini",
|
|
199
|
+
"gpt-5-chat",
|
|
200
|
+
"gpt-5-mini"
|
|
201
|
+
];
|
|
202
|
+
const DEFAULT_MODEL = "gpt-5-mini";
|
|
203
|
+
const MODEL_ID_MAP = {
|
|
204
|
+
"gpt-4.1-mini": { id: "gpt-4.1-mini", name: "GPT-4.1-Mini" },
|
|
205
|
+
"gpt-4o-mini": { id: "gpt-4o-mini", name: "GPT-4o-Mini" },
|
|
206
|
+
"gpt-5-chat": { id: "gpt-5-chat", name: "GPT-5-Chat" },
|
|
207
|
+
"gpt-5-mini": { id: "gpt-5-mini", name: "GPT-5-Mini" }
|
|
208
|
+
};
|
|
209
|
+
const DEFAULT_PROVIDER$1 = "siliconflow-minimax";
|
|
210
|
+
const MODEL_GENERAL_CONFIG$1 = {
|
|
211
|
+
reasoning: false,
|
|
212
|
+
input: ["text"],
|
|
213
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
214
|
+
contextWindow: 2e5,
|
|
215
|
+
maxTokens: 65536
|
|
216
|
+
};
|
|
196
217
|
const PLUGIN_PACKAGE_NAME$1 = "@workclaw/openclaw-workclaw";
|
|
197
218
|
function execAsync$1(command, options) {
|
|
198
219
|
return new Promise((resolve2, reject) => {
|
|
@@ -459,7 +480,24 @@ class BoxInstaller {
|
|
|
459
480
|
} catch {
|
|
460
481
|
debug.log("[更新配置] 无原有配置");
|
|
461
482
|
}
|
|
483
|
+
const mergeMode = this.config.mergeMode || "merge";
|
|
484
|
+
const resetKeys = ["models", "agents", "bindings", "channels", "plugins"];
|
|
485
|
+
if (mergeMode === "replace") {
|
|
486
|
+
debug.log("[更新配置] 合并模式: replace(完全重置,忽略原有配置)");
|
|
487
|
+
originalConfig = {};
|
|
488
|
+
} else if (mergeMode === "reset-keys") {
|
|
489
|
+
debug.log("[更新配置] 合并模式: reset-keys(清除关键字段后合并)");
|
|
490
|
+
for (const key of resetKeys) {
|
|
491
|
+
if (originalConfig[key]) {
|
|
492
|
+
delete originalConfig[key];
|
|
493
|
+
debug.log(`[更新配置] 清除原有 ${key} 配置`);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
} else {
|
|
497
|
+
debug.log("[更新配置] 合并模式: merge(完整保留原有配置后合并)");
|
|
498
|
+
}
|
|
462
499
|
const config = getConfig(this.config.env || "test", this.config.customIp);
|
|
500
|
+
const modelInfo = MODEL_ID_MAP[this.config.model];
|
|
463
501
|
const newConfig = {
|
|
464
502
|
// diagnostics: 诊断配置
|
|
465
503
|
diagnostics: {
|
|
@@ -478,7 +516,7 @@ class BoxInstaller {
|
|
|
478
516
|
// 配置合并模式:'merge' 合并 | 'replace' 替换
|
|
479
517
|
mode: "replace",
|
|
480
518
|
providers: {
|
|
481
|
-
|
|
519
|
+
[DEFAULT_PROVIDER$1]: {
|
|
482
520
|
// 模型 API 基础地址
|
|
483
521
|
baseUrl: config.MODEL_BASE_URL,
|
|
484
522
|
// API 密钥(留空,由外部提供)
|
|
@@ -489,19 +527,11 @@ class BoxInstaller {
|
|
|
489
527
|
authHeader: true,
|
|
490
528
|
models: [{
|
|
491
529
|
// 模型 ID(provider/model 格式)
|
|
492
|
-
id:
|
|
530
|
+
id: modelInfo.id,
|
|
493
531
|
// 模型显示名称
|
|
494
|
-
name:
|
|
495
|
-
//
|
|
496
|
-
|
|
497
|
-
// 支持的输入类型:['text'] | ['text', 'image']
|
|
498
|
-
input: ["text"],
|
|
499
|
-
// 价格(0 表示免费或未设置)
|
|
500
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
501
|
-
// 上下文窗口大小(token)
|
|
502
|
-
contextWindow: 2e5,
|
|
503
|
-
// 最大输出 token 数
|
|
504
|
-
maxTokens: 65536
|
|
532
|
+
name: modelInfo.name,
|
|
533
|
+
// 模型通用配置
|
|
534
|
+
...MODEL_GENERAL_CONFIG$1
|
|
505
535
|
}]
|
|
506
536
|
}
|
|
507
537
|
}
|
|
@@ -510,13 +540,7 @@ class BoxInstaller {
|
|
|
510
540
|
agents: {
|
|
511
541
|
defaults: {
|
|
512
542
|
// 默认使用的模型
|
|
513
|
-
model: { primary:
|
|
514
|
-
models: {
|
|
515
|
-
"siliconflow-minimax/Pro/MiniMaxAI/MiniMax-M2.5": {
|
|
516
|
-
// 模型别名,用于显示
|
|
517
|
-
alias: "Pro/MiniMaxAI/MiniMax-M2.5"
|
|
518
|
-
}
|
|
519
|
-
},
|
|
543
|
+
model: { primary: `${DEFAULT_PROVIDER$1}/${modelInfo.id}` },
|
|
520
544
|
// 工作区目录路径
|
|
521
545
|
workspace: paths.workspace,
|
|
522
546
|
// 会话压缩模式:'safeguard' 保守模式
|
|
@@ -696,7 +720,7 @@ class BoxInstaller {
|
|
|
696
720
|
};
|
|
697
721
|
const finalConfig = deepMerge$1(originalConfig, newConfig);
|
|
698
722
|
this.updateSpinner("正在写入配置...");
|
|
699
|
-
debug.log("[更新配置]
|
|
723
|
+
debug.log("[更新配置] 合并配置并写入文件(保留其他初始化数据)...");
|
|
700
724
|
await fs.writeFile(paths.config, JSON.stringify(finalConfig, null, 2), "utf-8");
|
|
701
725
|
this.prefixText += chalk.green(` ✓ 配置文件更新成功
|
|
702
726
|
`);
|
|
@@ -714,6 +738,7 @@ async function createBoxCommand(options) {
|
|
|
714
738
|
let appKey = options.appKey;
|
|
715
739
|
let appSecret = options.appSecret;
|
|
716
740
|
let customIp = options.customIp;
|
|
741
|
+
let model = options.model;
|
|
717
742
|
const questions = [];
|
|
718
743
|
if (!env) {
|
|
719
744
|
debug.log("[盒子安装] 需要选择环境");
|
|
@@ -765,6 +790,21 @@ async function createBoxCommand(options) {
|
|
|
765
790
|
} else {
|
|
766
791
|
debug.log("[盒子安装] 使用命令行参数: appSecret");
|
|
767
792
|
}
|
|
793
|
+
if (!model) {
|
|
794
|
+
debug.log("[盒子安装] 需要选择模型");
|
|
795
|
+
questions.push({
|
|
796
|
+
type: "list",
|
|
797
|
+
name: "model",
|
|
798
|
+
message: chalk.cyan("请选择模型:"),
|
|
799
|
+
default: DEFAULT_MODEL,
|
|
800
|
+
choices: SUPPORTED_MODELS.map((m) => ({
|
|
801
|
+
name: m === DEFAULT_MODEL ? `${chalk.green(m)} ${chalk.dim("(默认)")}` : m,
|
|
802
|
+
value: m
|
|
803
|
+
}))
|
|
804
|
+
});
|
|
805
|
+
} else {
|
|
806
|
+
debug.log(`[盒子安装] 使用命令行参数: model=${model}`);
|
|
807
|
+
}
|
|
768
808
|
if (questions.length > 0) {
|
|
769
809
|
debug.log(`[盒子安装] 开始交互式问答,共 ${questions.length} 个问题`);
|
|
770
810
|
const answers = await inquirer.prompt(questions);
|
|
@@ -772,7 +812,9 @@ async function createBoxCommand(options) {
|
|
|
772
812
|
env = env || answers.env || "test";
|
|
773
813
|
appKey = appKey || answers.appKey;
|
|
774
814
|
appSecret = appSecret || answers.appSecret;
|
|
815
|
+
model = model || answers.model || DEFAULT_MODEL;
|
|
775
816
|
}
|
|
817
|
+
model = model || DEFAULT_MODEL;
|
|
776
818
|
if (env === "custom" && !customIp) {
|
|
777
819
|
debug.log("[盒子安装] 自定义环境需要输入后端 IP");
|
|
778
820
|
const answer = await inquirer.prompt([{
|
|
@@ -796,7 +838,8 @@ async function createBoxCommand(options) {
|
|
|
796
838
|
} else if (env === "custom" && customIp) {
|
|
797
839
|
debug.log(`[盒子安装] 使用命令行参数: customIp=${customIp}`);
|
|
798
840
|
}
|
|
799
|
-
|
|
841
|
+
const mergeMode = options.mergeMode || "merge";
|
|
842
|
+
debug.log(`[盒子安装] 最终参数: env=${env}, customIp=${customIp}, openclawPath=${options.openclawPath}, model=${model}, mergeMode=${mergeMode}`);
|
|
800
843
|
debug.log("[盒子安装] 创建 BoxInstaller 实例...");
|
|
801
844
|
const installer = new BoxInstaller({
|
|
802
845
|
appKey,
|
|
@@ -805,7 +848,9 @@ async function createBoxCommand(options) {
|
|
|
805
848
|
customIp,
|
|
806
849
|
wsUrl: options.wsUrl,
|
|
807
850
|
pluginVersion: options.pluginVersion,
|
|
808
|
-
openclawPath: options.openclawPath
|
|
851
|
+
openclawPath: options.openclawPath,
|
|
852
|
+
model,
|
|
853
|
+
mergeMode
|
|
809
854
|
});
|
|
810
855
|
debug.log("[盒子安装] 开始安装...");
|
|
811
856
|
await installer.install();
|
|
@@ -840,7 +885,7 @@ async function createBoxCommand(options) {
|
|
|
840
885
|
}
|
|
841
886
|
}
|
|
842
887
|
function registerCommands$1(program2) {
|
|
843
|
-
program2.command("box").description("盒子设备安装(无需登录)").option("-e, --env <env>", "环境 (test/prod/custom)").option("--app-key <appKey>", "App Key").option("--app-secret <appSecret>", "App Secret").option("--customIp <ip>", "自定义后端 IP(仅 custom 环境生效)").option("--ws-url <url>", "自定义 WebSocket URL(仅 custom 环境生效,默认自动生成)").option("--plugin-version <plugin-version>", "插件版本号(默认最新版)").option("--openclaw-path <path>", "OpenClaw 安装目录路径(默认 ~/.openclaw)").option("--debug", "开启调试日志").action(createBoxCommand);
|
|
888
|
+
program2.command("box").description("盒子设备安装(无需登录)").option("-e, --env <env>", "环境 (test/prod/custom)").option("--app-key <appKey>", "App Key").option("--app-secret <appSecret>", "App Secret").option("--customIp <ip>", "自定义后端 IP(仅 custom 环境生效)").option("--ws-url <url>", "自定义 WebSocket URL(仅 custom 环境生效,默认自动生成)").option("--plugin-version <plugin-version>", "插件版本号(默认最新版)").option("--openclaw-path <path>", "OpenClaw 安装目录路径(默认 ~/.openclaw)").option("--model <model>", `选择模型 (${SUPPORTED_MODELS.join("/")}),默认 ${DEFAULT_MODEL}`).option("--merge-mode <mode>", "配置合并模式 (merge: 保留旧配置合并 / replace: 完全重置 / reset-keys: 清除关键字段后合并),默认 reset-keys").option("--debug", "开启调试日志").action(createBoxCommand);
|
|
844
889
|
}
|
|
845
890
|
function createHttpClient(baseURL) {
|
|
846
891
|
return axios.create({
|
|
@@ -971,7 +1016,8 @@ const LocalInstallerConfigSchema = z$1.object({
|
|
|
971
1016
|
phone: phoneSchema,
|
|
972
1017
|
userPass: userPassSchema,
|
|
973
1018
|
pluginVersion: pluginVersionSchema,
|
|
974
|
-
openclawPath: openclawPathSchema.optional()
|
|
1019
|
+
openclawPath: openclawPathSchema.optional(),
|
|
1020
|
+
mergeMode: z$1.enum(["merge", "replace", "reset-keys"]).optional().default("merge")
|
|
975
1021
|
}).refine(
|
|
976
1022
|
(data) => {
|
|
977
1023
|
if (data.env === "custom") {
|
|
@@ -4908,6 +4954,16 @@ function buildLocalCode(phone, machineId) {
|
|
|
4908
4954
|
function getHomeDir() {
|
|
4909
4955
|
return process$1.env.HOME || process$1.env.USERPROFILE || "";
|
|
4910
4956
|
}
|
|
4957
|
+
const DEFAULT_PROVIDER = "siliconflow-minimax";
|
|
4958
|
+
const DEFAULT_MODEL_ID = "MiniMax-M2.5";
|
|
4959
|
+
const DEFAULT_MODEL_NAME = "MiniMax-M2.5";
|
|
4960
|
+
const MODEL_GENERAL_CONFIG = {
|
|
4961
|
+
reasoning: false,
|
|
4962
|
+
input: ["text"],
|
|
4963
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
4964
|
+
contextWindow: 2e5,
|
|
4965
|
+
maxTokens: 65536
|
|
4966
|
+
};
|
|
4911
4967
|
const PLUGIN_PACKAGE_NAME = "@workclaw/openclaw-workclaw";
|
|
4912
4968
|
function execAsync(command, options) {
|
|
4913
4969
|
return new Promise((resolve2, reject) => {
|
|
@@ -5226,6 +5282,22 @@ class LocalInstaller {
|
|
|
5226
5282
|
} catch {
|
|
5227
5283
|
debug.log("[更新配置] 无原有配置");
|
|
5228
5284
|
}
|
|
5285
|
+
const mergeMode = this.config.mergeMode || "merge";
|
|
5286
|
+
const resetKeys = ["models", "agents", "bindings", "channels", "plugins"];
|
|
5287
|
+
if (mergeMode === "replace") {
|
|
5288
|
+
debug.log("[更新配置] 合并模式: replace(完全重置,忽略原有配置)");
|
|
5289
|
+
originalConfig = {};
|
|
5290
|
+
} else if (mergeMode === "reset-keys") {
|
|
5291
|
+
debug.log("[更新配置] 合并模式: reset-keys(清除关键字段后合并)");
|
|
5292
|
+
for (const key of resetKeys) {
|
|
5293
|
+
if (originalConfig[key]) {
|
|
5294
|
+
delete originalConfig[key];
|
|
5295
|
+
debug.log(`[更新配置] 清除原有 ${key} 配置`);
|
|
5296
|
+
}
|
|
5297
|
+
}
|
|
5298
|
+
} else {
|
|
5299
|
+
debug.log("[更新配置] 合并模式: merge(完整保留原有配置后合并)");
|
|
5300
|
+
}
|
|
5229
5301
|
const config = this.envConfig;
|
|
5230
5302
|
const newConfig = {
|
|
5231
5303
|
// diagnostics: 诊断配置
|
|
@@ -5241,19 +5313,15 @@ class LocalInstaller {
|
|
|
5241
5313
|
models: {
|
|
5242
5314
|
mode: "replace",
|
|
5243
5315
|
providers: {
|
|
5244
|
-
|
|
5316
|
+
[DEFAULT_PROVIDER]: {
|
|
5245
5317
|
baseUrl: boundConfig.modelApiBaseUrl || config.MODEL_BASE_URL,
|
|
5246
5318
|
apiKey: boundConfig.modelApiKey,
|
|
5247
5319
|
api: "openai-completions",
|
|
5248
5320
|
authHeader: true,
|
|
5249
5321
|
models: [{
|
|
5250
|
-
id:
|
|
5251
|
-
name:
|
|
5252
|
-
|
|
5253
|
-
input: ["text"],
|
|
5254
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
5255
|
-
contextWindow: 2e5,
|
|
5256
|
-
maxTokens: 65536
|
|
5322
|
+
id: DEFAULT_MODEL_ID,
|
|
5323
|
+
name: DEFAULT_MODEL_NAME,
|
|
5324
|
+
...MODEL_GENERAL_CONFIG
|
|
5257
5325
|
}]
|
|
5258
5326
|
}
|
|
5259
5327
|
}
|
|
@@ -5261,12 +5329,7 @@ class LocalInstaller {
|
|
|
5261
5329
|
// agents: 代理配置
|
|
5262
5330
|
agents: {
|
|
5263
5331
|
defaults: {
|
|
5264
|
-
model: { primary:
|
|
5265
|
-
models: {
|
|
5266
|
-
"siliconflow-minimax/Pro/MiniMaxAI/MiniMax-M2.5": {
|
|
5267
|
-
alias: "Pro/MiniMaxAI/MiniMax-M2.5"
|
|
5268
|
-
}
|
|
5269
|
-
},
|
|
5332
|
+
model: { primary: `${DEFAULT_PROVIDER}/${DEFAULT_MODEL_ID}` },
|
|
5270
5333
|
workspace: paths.workspace,
|
|
5271
5334
|
compaction: { mode: "safeguard" },
|
|
5272
5335
|
verboseDefault: "full",
|
|
@@ -5393,7 +5456,7 @@ class LocalInstaller {
|
|
|
5393
5456
|
const finalConfig = deepMerge(originalConfig, newConfig);
|
|
5394
5457
|
this.spinner.prefixText = this.prefixText;
|
|
5395
5458
|
this.spinner.text = chalk.cyan("正在写入配置...");
|
|
5396
|
-
debug.log("[更新配置]
|
|
5459
|
+
debug.log("[更新配置] 合并配置并写入文件(保留其他初始化数据)...");
|
|
5397
5460
|
await fs.writeFile(paths.config, JSON.stringify(finalConfig, null, 2), "utf-8");
|
|
5398
5461
|
this.prefixText += chalk.green(` ✓ 配置更新完成
|
|
5399
5462
|
`);
|
|
@@ -5496,7 +5559,8 @@ async function createLocalCommand(options) {
|
|
|
5496
5559
|
} else if (env === "custom" && customIp) {
|
|
5497
5560
|
debug.log(`[初始化] 使用命令行参数: customIp=${customIp}`);
|
|
5498
5561
|
}
|
|
5499
|
-
|
|
5562
|
+
const mergeMode = options.mergeMode || "merge";
|
|
5563
|
+
debug.log(`[初始化] 最终参数: env=${env}, phone=${phone}, customIp=${customIp}, pluginVersion=${options.pluginVersion}, openclawPath=${options.openclawPath}, mergeMode=${mergeMode}`);
|
|
5500
5564
|
debug.log("[初始化] 创建 LocalInstaller 实例...");
|
|
5501
5565
|
const installer = new LocalInstaller({
|
|
5502
5566
|
phone,
|
|
@@ -5505,7 +5569,8 @@ async function createLocalCommand(options) {
|
|
|
5505
5569
|
customIp,
|
|
5506
5570
|
wsUrl: options.wsUrl,
|
|
5507
5571
|
pluginVersion: options.pluginVersion,
|
|
5508
|
-
openclawPath: options.openclawPath
|
|
5572
|
+
openclawPath: options.openclawPath,
|
|
5573
|
+
mergeMode
|
|
5509
5574
|
});
|
|
5510
5575
|
debug.log("[初始化] 开始安装...");
|
|
5511
5576
|
await installer.install();
|
|
@@ -5545,7 +5610,7 @@ ${chalk.cyan("Token: ")}${token}`);
|
|
|
5545
5610
|
}
|
|
5546
5611
|
}
|
|
5547
5612
|
function registerCommands(program2) {
|
|
5548
|
-
program2.command("local").description("本地账户安装(需要登录)").option("-e, --env <env>", "环境 (test/prod/custom)").option("--phone <phone>", "手机号码").option("--user-pass <userPass>", "用户密码").option("--custom-ip <ip>", "自定义后端 IP(仅 custom 环境生效)").option("--ws-url <url>", "自定义 WebSocket URL(仅 custom 环境生效,默认自动生成)").option("--plugin-version <plugin-version>", "插件版本号(默认最新版)").option("--openclaw-path <path>", "OpenClaw 安装目录路径(默认 ~/.openclaw)").option("--debug", "开启调试日志").action(createLocalCommand);
|
|
5613
|
+
program2.command("local").description("本地账户安装(需要登录)").option("-e, --env <env>", "环境 (test/prod/custom)").option("--phone <phone>", "手机号码").option("--user-pass <userPass>", "用户密码").option("--custom-ip <ip>", "自定义后端 IP(仅 custom 环境生效)").option("--ws-url <url>", "自定义 WebSocket URL(仅 custom 环境生效,默认自动生成)").option("--plugin-version <plugin-version>", "插件版本号(默认最新版)").option("--openclaw-path <path>", "OpenClaw 安装目录路径(默认 ~/.openclaw)").option("--merge-mode <mode>", "配置合并模式 (merge: 保留旧配置合并 / replace: 完全重置 / reset-keys: 清除关键字段后合并),默认 reset-keys").option("--debug", "开启调试日志").action(createLocalCommand);
|
|
5549
5614
|
}
|
|
5550
5615
|
const __filename$1 = fileURLToPath(import.meta.url);
|
|
5551
5616
|
const __dirname$1 = dirname(__filename$1);
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/local/configs/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const MODEL_GENERAL_CONFIG: {
|
|
2
|
+
reasoning: boolean;
|
|
3
|
+
input: string[];
|
|
4
|
+
cost: {
|
|
5
|
+
input: number;
|
|
6
|
+
output: number;
|
|
7
|
+
cacheRead: number;
|
|
8
|
+
cacheWrite: number;
|
|
9
|
+
};
|
|
10
|
+
contextWindow: number;
|
|
11
|
+
maxTokens: number;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/local/configs/model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAMhC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/local/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/local/constants/model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,wBAAwB,CAAA;AAErD,eAAO,MAAM,gBAAgB,iBAAiB,CAAA;AAE9C,eAAO,MAAM,kBAAkB,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/local/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/local/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAavD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/local/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA6B,oBAAoB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/local/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA6B,oBAAoB,EAAE,MAAM,UAAU,CAAA;AA+F/E;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,KAAK,CAAa;IAE1B;;OAEG;gBACS,MAAM,EAAE,oBAAoB;IAOxC;;OAEG;IACH,cAAc,IAAI,IAAI;IAUtB;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgE9B;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;YACW,OAAO;IAoBrB;;OAEG;YACW,kBAAkB;IAchC;;OAEG;YACW,eAAe;IAmB7B;;OAEG;YACW,iBAAiB;IAoH/B;;OAEG;YACW,cAAc;CA+N7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/local/src/local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAQ5C;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/local/src/local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAQ5C;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiK7E"}
|
|
@@ -9,6 +9,7 @@ export interface LocalOptions {
|
|
|
9
9
|
openclawPath?: string;
|
|
10
10
|
debug?: boolean;
|
|
11
11
|
printToken?: boolean;
|
|
12
|
+
mergeMode?: 'merge' | 'replace' | 'reset-keys';
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* LocalInstaller 配置验证 schema
|
|
@@ -26,6 +27,11 @@ export declare const LocalInstallerConfigSchema: z.ZodObject<{
|
|
|
26
27
|
userPass: z.ZodString;
|
|
27
28
|
pluginVersion: z.ZodOptional<z.ZodString>;
|
|
28
29
|
openclawPath: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodString>>;
|
|
30
|
+
mergeMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
merge: "merge";
|
|
32
|
+
replace: "replace";
|
|
33
|
+
"reset-keys": "reset-keys";
|
|
34
|
+
}>>>;
|
|
29
35
|
}, z.core.$strip>;
|
|
30
36
|
export type LocalInstallerConfig = z.infer<typeof LocalInstallerConfigSchema>;
|
|
31
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/local/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/local/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,YAAY,CAAA;CAC/C;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;iBAoBtC,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;iBAO5B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb"}
|