@workclaw/cli 1.0.333 → 1.0.335

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.
@@ -1,9 +1,9 @@
1
1
  import { BoxInstallerConfig } from '../types';
2
2
  export declare class BoxInstaller {
3
- private config;
3
+ private installOptions;
4
4
  private spinner;
5
5
  private prefixText;
6
- constructor(config: BoxInstallerConfig);
6
+ constructor(installOptions: BoxInstallerConfig);
7
7
  validateConfig(): void;
8
8
  private getPaths;
9
9
  private updateSpinner;
@@ -1 +1 @@
1
- {"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../../src/commands/box/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,UAAU,CAAA;AA4BhE,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
+ {"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../../src/commands/box/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,UAAU,CAAA;AA4BhE,qBAAa,YAAY;IAIX,OAAO,CAAC,cAAc;IAHlC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAa;gBAEX,cAAc,EAAE,kBAAkB;IAItD,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"}
@@ -6,13 +6,13 @@ import { LocalInstallerConfig } from '../types';
6
6
  export declare class LocalInstaller {
7
7
  private spinner;
8
8
  private prefixText;
9
- private readonly config;
9
+ private readonly installOptions;
10
10
  private readonly envConfig;
11
11
  private token;
12
12
  /**
13
13
  * 构造函数
14
14
  */
15
- constructor(config: LocalInstallerConfig);
15
+ constructor(installOptions: LocalInstallerConfig);
16
16
  /**
17
17
  * 验证安装配置
18
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../../src/commands/local/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA6B,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAwC/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;CAiO7B"}
1
+ {"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../../src/commands/local/installer/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA6B,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAwC/E;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsB;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,KAAK,CAAa;IAE1B;;OAEG;gBACS,cAAc,EAAE,oBAAoB;IAOhD;;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;CAiO7B"}
@@ -251,26 +251,26 @@ function execAsync$1(command, options) {
251
251
  });
252
252
  }
253
253
  class BoxInstaller {
254
- constructor(config) {
255
- this.config = config;
254
+ constructor(installOptions) {
255
+ this.installOptions = installOptions;
256
256
  this.spinner = ora({ color: "cyan" }).start();
257
257
  }
258
258
  spinner;
259
259
  prefixText = "";
260
260
  validateConfig() {
261
261
  debug.log("[验证配置] 检查 appKey 和 appSecret...");
262
- if (!this.config.appKey) {
262
+ if (!this.installOptions.appKey) {
263
263
  throw new AppError2(ERROR_CODES.APP_KEY_REQUIRED, "AppKey 不能为空,请使用 --app-key 参数");
264
264
  }
265
- if (!this.config.appSecret) {
265
+ if (!this.installOptions.appSecret) {
266
266
  throw new AppError2(ERROR_CODES.APP_SECRET_REQUIRED, "AppSecret 不能为空,请使用 --app-secret 参数");
267
267
  }
268
- if (this.config.env === "custom") {
268
+ if (this.installOptions.env === "custom") {
269
269
  debug.log("[验证配置] 检查自定义环境 IP...");
270
- if (!this.config.customIp) {
270
+ if (!this.installOptions.customIp) {
271
271
  throw new AppError2(ERROR_CODES.INVALID_ARGUMENT, "自定义环境必须提供 --customIp 参数");
272
272
  }
273
- const result = ipv4Schema.safeParse(this.config.customIp);
273
+ const result = ipv4Schema.safeParse(this.installOptions.customIp);
274
274
  if (!result.success) {
275
275
  throw new AppError2(ERROR_CODES.INVALID_ARGUMENT, result.error.issues[0].message);
276
276
  }
@@ -279,28 +279,28 @@ class BoxInstaller {
279
279
  debug.log("[验证配置] 配置检查通过");
280
280
  }
281
281
  getPaths() {
282
- const env = this.config.env || "test";
283
- debug.log(`[getConfig] env=${env}, customIp=${this.config.customIp}`);
284
- const config = getConfig(env, this.config.customIp);
282
+ const env = this.installOptions.env || "test";
283
+ debug.log(`[getConfig] env=${env}, customIp=${this.installOptions.customIp}`);
284
+ const envConfig = getConfig(env, this.installOptions.customIp);
285
285
  let baseDir;
286
- if (this.config.openclawPath) {
287
- debug.log(`[路径验证] 验证自定义路径: ${this.config.openclawPath}`);
286
+ if (this.installOptions.openclawPath) {
287
+ debug.log(`[路径验证] 验证自定义路径: ${this.installOptions.openclawPath}`);
288
288
  try {
289
- validateOpenclawPath(this.config.openclawPath);
289
+ validateOpenclawPath(this.installOptions.openclawPath);
290
290
  debug.log("[路径验证] 通过");
291
291
  } catch (error) {
292
292
  throw new AppError2(ERROR_CODES.INVALID_OPENCLAW_PATH, error.message);
293
293
  }
294
- baseDir = normalizePath(this.config.openclawPath);
294
+ baseDir = normalizePath(this.installOptions.openclawPath);
295
295
  } else {
296
296
  const home = getHomeDir();
297
- baseDir = path.join(home, config.DIRS.OPENCLAW);
297
+ baseDir = path.join(home, envConfig.DIRS.OPENCLAW);
298
298
  }
299
- const extensionsDir = path.join(baseDir, config.DIRS.EXTENSIONS);
300
- const targetDir = path.join(extensionsDir, config.PLUGIN_NAME);
301
- const configFile = path.join(baseDir, config.DIRS.CONFIG_FILE);
302
- const workspaceDir = path.join(baseDir, config.DIRS.WORKSPACE);
303
- const tempDir = path.join(baseDir, config.DIRS.TEMP);
299
+ const extensionsDir = path.join(baseDir, envConfig.DIRS.EXTENSIONS);
300
+ const targetDir = path.join(extensionsDir, envConfig.PLUGIN_NAME);
301
+ const configFile = path.join(baseDir, envConfig.DIRS.CONFIG_FILE);
302
+ const workspaceDir = path.join(baseDir, envConfig.DIRS.WORKSPACE);
303
+ const tempDir = path.join(baseDir, envConfig.DIRS.TEMP);
304
304
  return {
305
305
  home: baseDir,
306
306
  extensions: extensionsDir,
@@ -319,8 +319,8 @@ class BoxInstaller {
319
319
  return this.prefixText;
320
320
  }
321
321
  getPackageName() {
322
- if (this.config.pluginVersion) {
323
- return `${PLUGIN_PACKAGE_NAME$1}@${this.config.pluginVersion}`;
322
+ if (this.installOptions.pluginVersion) {
323
+ return `${PLUGIN_PACKAGE_NAME$1}@${this.installOptions.pluginVersion}`;
324
324
  }
325
325
  return PLUGIN_PACKAGE_NAME$1;
326
326
  }
@@ -474,7 +474,7 @@ class BoxInstaller {
474
474
  } catch {
475
475
  debug.log("[更新配置] 无原有配置");
476
476
  }
477
- const mergeMode = this.config.mergeMode || "merge";
477
+ const mergeMode = this.installOptions.mergeMode || "merge";
478
478
  const resetKeys = ["models", "agents", "bindings", "channels", "plugins"];
479
479
  if (mergeMode === "replace") {
480
480
  debug.log("[更新配置] 合并模式: replace(完全重置,忽略原有配置)");
@@ -490,8 +490,8 @@ class BoxInstaller {
490
490
  } else {
491
491
  debug.log("[更新配置] 合并模式: merge(完整保留原有配置后合并)");
492
492
  }
493
- const config = getConfig(this.config.env || "test", this.config.customIp);
494
- const model = this.config.model ?? DEFAULT_MODEL$1;
493
+ const envConfig = getConfig(this.installOptions.env || "test", this.installOptions.customIp);
494
+ const model = this.installOptions.model ?? DEFAULT_MODEL$1;
495
495
  const newConfig = {
496
496
  // diagnostics: 诊断配置
497
497
  diagnostics: {
@@ -512,7 +512,7 @@ class BoxInstaller {
512
512
  providers: {
513
513
  [DEFAULT_PROVIDER$1]: {
514
514
  // 模型 API 基础地址
515
- baseUrl: config.MODEL_BASE_URL,
515
+ baseUrl: envConfig.MODEL_BASE_URL,
516
516
  // API 密钥(留空,由外部提供)
517
517
  apiKey: "",
518
518
  // API 类型:'openai-completions' | 'openai-chat' 等
@@ -613,13 +613,13 @@ class BoxInstaller {
613
613
  // 启用通道
614
614
  enabled: true,
615
615
  // 应用密钥
616
- appKey: this.config.appKey,
616
+ appKey: this.installOptions.appKey,
617
617
  // 应用密钥
618
- appSecret: this.config.appSecret,
618
+ appSecret: this.installOptions.appSecret,
619
619
  // API 基础 URL
620
- baseUrl: this.config.customIp ? `http://${this.config.customIp}` : config.DEFAULT_BASE_URL,
620
+ baseUrl: this.installOptions.customIp ? `http://${this.installOptions.customIp}` : envConfig.DEFAULT_BASE_URL,
621
621
  // WebSocket URL
622
- websocketUrl: this.config.wsUrl || config.DEFAULT_WS_URL,
622
+ websocketUrl: this.installOptions.wsUrl || envConfig.DEFAULT_WS_URL,
623
623
  // 允许不安全的 TLS 连接
624
624
  allowInsecureTls: true,
625
625
  // 允许原始 JSON 载荷
@@ -699,16 +699,16 @@ class BoxInstaller {
699
699
  load: {
700
700
  paths: [paths.extensions]
701
701
  },
702
- allow: [config.PLUGIN_NAME],
702
+ allow: [envConfig.PLUGIN_NAME],
703
703
  installs: {
704
- [config.PLUGIN_NAME]: {
704
+ [envConfig.PLUGIN_NAME]: {
705
705
  source: "npm",
706
706
  spec: PLUGIN_PACKAGE_NAME$1,
707
707
  installPath: paths.target
708
708
  }
709
709
  },
710
710
  entries: {
711
- [config.PLUGIN_NAME]: { enabled: true }
711
+ [envConfig.PLUGIN_NAME]: { enabled: true }
712
712
  }
713
713
  }
714
714
  };
@@ -4984,16 +4984,16 @@ function execAsync(command, options) {
4984
4984
  class LocalInstaller {
4985
4985
  spinner;
4986
4986
  prefixText = "";
4987
- config;
4987
+ installOptions;
4988
4988
  envConfig;
4989
4989
  token = "";
4990
4990
  /**
4991
4991
  * 构造函数
4992
4992
  */
4993
- constructor(config) {
4994
- this.config = config;
4995
- const env = this.config.env || "test";
4996
- this.envConfig = getConfig(env, this.config.customIp);
4993
+ constructor(installOptions) {
4994
+ this.installOptions = installOptions;
4995
+ const env = this.installOptions.env || "test";
4996
+ this.envConfig = getConfig(env, this.installOptions.customIp);
4997
4997
  this.spinner = ora({ color: "cyan" }).start();
4998
4998
  }
4999
4999
  /**
@@ -5001,7 +5001,7 @@ class LocalInstaller {
5001
5001
  */
5002
5002
  validateConfig() {
5003
5003
  debug.log("[验证配置] 检查配置...");
5004
- const result = LocalInstallerConfigSchema.safeParse(this.config);
5004
+ const result = LocalInstallerConfigSchema.safeParse(this.installOptions);
5005
5005
  if (!result.success) {
5006
5006
  debug.log(`[验证配置] 验证失败: ${result.error.issues[0].message}`);
5007
5007
  throw new AppError$1(ERROR_CODES$1.INVALID_ARGUMENT, result.error.issues[0].message);
@@ -5016,15 +5016,15 @@ class LocalInstaller {
5016
5016
  debug.log("[安装开始]");
5017
5017
  this.validateConfig();
5018
5018
  let baseDir;
5019
- if (this.config.openclawPath) {
5020
- debug.log(`[路径验证] 验证自定义路径: ${this.config.openclawPath}`);
5019
+ if (this.installOptions.openclawPath) {
5020
+ debug.log(`[路径验证] 验证自定义路径: ${this.installOptions.openclawPath}`);
5021
5021
  try {
5022
- validateOpenclawPath(this.config.openclawPath);
5022
+ validateOpenclawPath(this.installOptions.openclawPath);
5023
5023
  debug.log("[路径验证] 通过");
5024
5024
  } catch (error) {
5025
5025
  throw new AppError$1(ERROR_CODES$1.INVALID_OPENCLAW_PATH, error.message);
5026
5026
  }
5027
- baseDir = normalizePath(this.config.openclawPath);
5027
+ baseDir = normalizePath(this.installOptions.openclawPath);
5028
5028
  } else {
5029
5029
  const homeDir = getHomeDir();
5030
5030
  baseDir = path.join(homeDir, this.envConfig.DIRS.OPENCLAW);
@@ -5043,7 +5043,7 @@ class LocalInstaller {
5043
5043
  debug.log(`[路径配置] config=${paths.config}`);
5044
5044
  debug.log(`[路径配置] workspace=${paths.workspace}`);
5045
5045
  const machineId = generateMachineId();
5046
- const localCode = buildLocalCode(this.config.phone, machineId);
5046
+ const localCode = buildLocalCode(this.installOptions.phone, machineId);
5047
5047
  debug.log(`[机器码] machineId=${machineId}`);
5048
5048
  debug.log(`[机器码] localCode=${localCode}`);
5049
5049
  const token = await this.doLogin();
@@ -5080,8 +5080,8 @@ class LocalInstaller {
5080
5080
  * 获取完整的 npm 包名(包含版本号)
5081
5081
  */
5082
5082
  getPackageName() {
5083
- if (this.config.pluginVersion) {
5084
- return `${PLUGIN_PACKAGE_NAME}@${this.config.pluginVersion}`;
5083
+ if (this.installOptions.pluginVersion) {
5084
+ return `${PLUGIN_PACKAGE_NAME}@${this.installOptions.pluginVersion}`;
5085
5085
  }
5086
5086
  return PLUGIN_PACKAGE_NAME;
5087
5087
  }
@@ -5091,15 +5091,15 @@ class LocalInstaller {
5091
5091
  async doLogin() {
5092
5092
  this.spinner.prefixText = this.prefixText;
5093
5093
  this.spinner.text = chalk.cyan("正在验证账号...");
5094
- debug.log(`[用户登录] 手机号: ${this.config.phone}`);
5094
+ debug.log(`[用户登录] 手机号: ${this.installOptions.phone}`);
5095
5095
  debug.log("[用户登录] RSA 加密密码...");
5096
- const encryptedPassword = rsaEncrypt(this.config.userPass);
5096
+ const encryptedPassword = rsaEncrypt(this.installOptions.userPass);
5097
5097
  if (!encryptedPassword) {
5098
5098
  throw new AppError$1(ERROR_CODES$1.LOGIN_FAILED, "密码加密失败");
5099
5099
  }
5100
5100
  debug.log("[用户登录] 密码加密成功");
5101
5101
  debug.log("[用户登录] 调用登录接口...");
5102
- const token = await login(this.config.phone, encryptedPassword, this.envConfig);
5102
+ const token = await login(this.installOptions.phone, encryptedPassword, this.envConfig);
5103
5103
  this.prefixText += chalk.green(` ✓ 账号验证成功
5104
5104
  `);
5105
5105
  debug.log("[用户登录] 登录成功");
@@ -5113,7 +5113,7 @@ class LocalInstaller {
5113
5113
  this.spinner.text = chalk.cyan("正在获取绑定信息...");
5114
5114
  debug.log("[获取配置] 调用绑定配置接口...");
5115
5115
  debug.log(`[获取配置] localCode=${localCode}`);
5116
- const boundConfig = await fetchBoundConfig(token, this.config.phone, localCode, this.envConfig);
5116
+ const boundConfig = await fetchBoundConfig(token, this.installOptions.phone, localCode, this.envConfig);
5117
5117
  debug.log(`[获取配置] agentId=${boundConfig.agentId}, appKey=${boundConfig.appKey?.slice(0, 8)}...`);
5118
5118
  this.prefixText += chalk.green(` ✓ 绑定信息获取成功
5119
5119
  `);
@@ -5257,7 +5257,7 @@ class LocalInstaller {
5257
5257
  } catch {
5258
5258
  debug.log("[更新配置] 无原有配置");
5259
5259
  }
5260
- const mergeMode = this.config.mergeMode || "merge";
5260
+ const mergeMode = this.installOptions.mergeMode || "merge";
5261
5261
  const resetKeys = ["models", "agents", "bindings", "channels", "plugins"];
5262
5262
  if (mergeMode === "replace") {
5263
5263
  debug.log("[更新配置] 合并模式: replace(完全重置,忽略原有配置)");
@@ -5273,8 +5273,8 @@ class LocalInstaller {
5273
5273
  } else {
5274
5274
  debug.log("[更新配置] 合并模式: merge(完整保留原有配置后合并)");
5275
5275
  }
5276
- const config = this.envConfig;
5277
- const model = this.config.model || DEFAULT_MODEL;
5276
+ const envConfig = this.envConfig;
5277
+ const model = this.installOptions.model || DEFAULT_MODEL;
5278
5278
  const newConfig = {
5279
5279
  // diagnostics: 诊断配置
5280
5280
  diagnostics: {
@@ -5290,7 +5290,7 @@ class LocalInstaller {
5290
5290
  mode: "replace",
5291
5291
  providers: {
5292
5292
  [DEFAULT_PROVIDER]: {
5293
- baseUrl: boundConfig.modelApiBaseUrl || config.MODEL_BASE_URL,
5293
+ baseUrl: boundConfig.modelApiBaseUrl || envConfig.MODEL_BASE_URL,
5294
5294
  apiKey: boundConfig.modelApiKey,
5295
5295
  api: "openai-completions",
5296
5296
  authHeader: true,
@@ -5360,8 +5360,8 @@ class LocalInstaller {
5360
5360
  enabled: true,
5361
5361
  appKey: boundConfig.appKey,
5362
5362
  appSecret: boundConfig.appSecret,
5363
- baseUrl: this.config.customIp ? `http://${this.config.customIp}` : config.DEFAULT_BASE_URL,
5364
- websocketUrl: this.config.wsUrl || config.DEFAULT_WS_URL,
5363
+ baseUrl: this.installOptions.customIp ? `http://${this.installOptions.customIp}` : envConfig.DEFAULT_BASE_URL,
5364
+ websocketUrl: this.installOptions.wsUrl || envConfig.DEFAULT_WS_URL,
5365
5365
  allowInsecureTls: true,
5366
5366
  allowRawJsonPayload: true,
5367
5367
  userId: boundConfig.userId,
@@ -5416,17 +5416,17 @@ class LocalInstaller {
5416
5416
  load: {
5417
5417
  paths: [paths.extensions]
5418
5418
  },
5419
- allow: [config.PLUGIN_NAME],
5419
+ allow: [envConfig.PLUGIN_NAME],
5420
5420
  installs: {
5421
- [config.PLUGIN_NAME]: {
5421
+ [envConfig.PLUGIN_NAME]: {
5422
5422
  source: "npm",
5423
5423
  spec: PLUGIN_PACKAGE_NAME,
5424
5424
  installPath: paths.target,
5425
- scene: this.config.scene || "test"
5425
+ scene: this.installOptions.scene || "test"
5426
5426
  }
5427
5427
  },
5428
5428
  entries: {
5429
- [config.PLUGIN_NAME]: { enabled: true }
5429
+ [envConfig.PLUGIN_NAME]: { enabled: true }
5430
5430
  }
5431
5431
  }
5432
5432
  };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import("./index-B2GxnJ-9.js").then((cli) => {
2
+ import("./index-B7APqmMJ.js").then((cli) => {
3
3
  cli.default();
4
4
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workclaw/cli",
3
3
  "type": "module",
4
- "version": "1.0.333",
4
+ "version": "1.0.335",
5
5
  "description": "WorkClaw CLI 工具 - 用于初始化和配置 WorkClaw 插件",
6
6
  "license": "MIT",
7
7
  "keywords": [