traderclaw-cli 1.0.70 → 1.0.73

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.
@@ -442,12 +442,55 @@ function runCommandWithEvents(cmd, args = [], opts = {}) {
442
442
  });
443
443
  }
444
444
 
445
+ function getGlobalOpenClawPackageDir() {
446
+ const root = getCommandOutput("npm root -g");
447
+ if (!root) return null;
448
+ const dir = join(root.trim(), "openclaw");
449
+ return existsSync(join(dir, "package.json")) ? dir : null;
450
+ }
451
+
452
+ /**
453
+ * Re-run `npm install` inside the global OpenClaw package tree. Some hosts end up with an
454
+ * incomplete `node_modules` after `npm install -g` (hoisting, optional deps, or interrupted
455
+ * installs). OpenClaw then fails at runtime with `Cannot find module 'grammy'` while loading
456
+ * config. Installing from the package directory restores declared dependencies.
457
+ */
458
+ /** Runs `npm install` in the global `openclaw` package directory (fixes missing `grammy` etc.). */
459
+ export async function ensureOpenClawGlobalPackageDependencies() {
460
+ const dir = getGlobalOpenClawPackageDir();
461
+ if (!dir) {
462
+ return { skipped: true, reason: "global_openclaw_dir_not_found" };
463
+ }
464
+ await runCommandWithEvents("npm", ["install", "--omit=dev", "--registry", "https://registry.npmjs.org/"], {
465
+ cwd: dir,
466
+ shell: false,
467
+ });
468
+ return { repaired: true, dir };
469
+ }
470
+
471
+ /**
472
+ * Install or upgrade the global OpenClaw CLI. We always run npm even when `openclaw` is already
473
+ * on PATH: bundled plugin manifests track a minimum OpenClaw version (e.g. >=2026.4.8). A stale
474
+ * global from an older install causes `openclaw plugins install` to fail config validation with
475
+ * "plugin requires OpenClaw >=… but this host is …".
476
+ */
445
477
  async function installOpenClawPlatform() {
446
- if (commandExists("openclaw")) {
447
- return { alreadyInstalled: true, version: getCommandOutput("openclaw --version") };
478
+ const hadOpenclaw = commandExists("openclaw");
479
+ const previousVersion = hadOpenclaw ? getCommandOutput("openclaw --version") : null;
480
+ await runCommandWithEvents("npm", ["install", "-g", "--registry", "https://registry.npmjs.org/", "openclaw@latest"]);
481
+ const available = commandExists("openclaw");
482
+ const version = available ? getCommandOutput("openclaw --version") : null;
483
+ if (!available) {
484
+ throw new Error("npm install -g openclaw@latest finished but `openclaw` is not available on PATH");
448
485
  }
449
- await runCommandWithEvents("npm", ["install", "-g", "openclaw"]);
450
- return { alreadyInstalled: false, installed: true, available: commandExists("openclaw") };
486
+ return {
487
+ alreadyInstalled: hadOpenclaw,
488
+ installed: true,
489
+ upgraded: hadOpenclaw,
490
+ previousVersion,
491
+ version,
492
+ available: true,
493
+ };
451
494
  }
452
495
 
453
496
  function isNpmGlobalBinConflict(err, cliName) {
@@ -1961,7 +2004,7 @@ export class InstallerStepEngine {
1961
2004
  }
1962
2005
 
1963
2006
  if (!this.options.skipInstallOpenClaw) {
1964
- await this.runStep("install_openclaw", "Installing OpenClaw platform", async () => installOpenClawPlatform());
2007
+ await this.runStep("install_openclaw", "Installing or upgrading OpenClaw platform", async () => installOpenClawPlatform());
1965
2008
  }
1966
2009
  await this.runStep("configure_llm", "Configuring required OpenClaw LLM provider", async () => this.configureLlmStep());
1967
2010
  if (!this.options.skipInstallPlugin) {
@@ -1970,6 +2013,9 @@ export class InstallerStepEngine {
1970
2013
  this.modeConfig,
1971
2014
  (evt) => this.emitLog("install_plugin_package", evt.type === "stderr" ? "warn" : "info", evt.text, evt.urls || []),
1972
2015
  ));
2016
+ await this.runStep("openclaw_global_deps", "Ensuring OpenClaw global package dependencies", async () =>
2017
+ ensureOpenClawGlobalPackageDependencies(),
2018
+ );
1973
2019
  await this.runStep(
1974
2020
  "activate_openclaw_plugin",
1975
2021
  "Installing and enabling TraderClaw inside OpenClaw",
@@ -1807,7 +1807,7 @@ async function cmdPrecheck(args) {
1807
1807
  } else if (opts.mode === "allow-install") {
1808
1808
  log.info("Installing openclaw (allow-install mode)");
1809
1809
  try {
1810
- execSync("npm install -g openclaw", { stdio: "ignore" });
1810
+ execSync("npm install -g --registry https://registry.npmjs.org/ openclaw@latest", { stdio: "ignore" });
1811
1811
  if (commandExists("openclaw")) log.pass("openclaw installed successfully");
1812
1812
  else log.fail("openclaw install completed but command is still missing");
1813
1813
  } catch {
@@ -3204,6 +3204,7 @@ Commands:
3204
3204
  signup Create a new account (alias for: setup --signup; run locally, not via the agent)
3205
3205
  precheck Run environment checks (dry-run or allow-install)
3206
3206
  install Launch installer flows (--wizard for localhost GUI)
3207
+ repair-openclaw Re-run npm install in the global openclaw package (fixes missing grammy after upgrade)
3207
3208
  gateway Gateway helpers (see subcommands below)
3208
3209
  login Re-authenticate (uses refresh token when valid; full challenge only if needed)
3209
3210
  logout Revoke current session and clear tokens
@@ -3248,6 +3249,7 @@ Examples:
3248
3249
  traderclaw precheck --allow-install
3249
3250
  traderclaw install --wizard
3250
3251
  traderclaw install --wizard --lane quick-local
3252
+ traderclaw repair-openclaw
3251
3253
  traderclaw gateway ensure-persistent
3252
3254
  traderclaw setup --signup --user-id my_agent_001 --referral-code ABCD1234
3253
3255
  traderclaw setup --api-key oc_xxx --url https://api.traderclaw.ai
@@ -3264,6 +3266,18 @@ Examples:
3264
3266
  `);
3265
3267
  }
3266
3268
 
3269
+ async function cmdRepairOpenclaw() {
3270
+ const { ensureOpenClawGlobalPackageDependencies } = await import("./installer-step-engine.mjs");
3271
+ printInfo("Repairing global OpenClaw npm dependencies (fixes missing grammy / MODULE_NOT_FOUND)...");
3272
+ const r = await ensureOpenClawGlobalPackageDependencies();
3273
+ if (r.skipped) {
3274
+ printError(`Could not find global OpenClaw package (${r.reason}). Install or upgrade: npm install -g openclaw@latest`);
3275
+ process.exit(1);
3276
+ }
3277
+ printSuccess(`Dependencies refreshed under ${r.dir}`);
3278
+ printInfo("Next: openclaw gateway restart");
3279
+ }
3280
+
3267
3281
  async function main() {
3268
3282
  const args = process.argv.slice(2);
3269
3283
  const command = args[0];
@@ -3295,6 +3309,9 @@ async function main() {
3295
3309
  case "install":
3296
3310
  await cmdInstall(args.slice(1));
3297
3311
  break;
3312
+ case "repair-openclaw":
3313
+ await cmdRepairOpenclaw();
3314
+ break;
3298
3315
  case "gateway":
3299
3316
  await cmdGateway(args.slice(1));
3300
3317
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "traderclaw-cli",
3
- "version": "1.0.70",
3
+ "version": "1.0.73",
4
4
  "description": "Global TraderClaw CLI (install --wizard, setup, precheck). Installs solana-traderclaw as a dependency for OpenClaw plugin files.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "node": ">=22"
18
18
  },
19
19
  "dependencies": {
20
- "solana-traderclaw": "^1.0.70"
20
+ "solana-traderclaw": "^1.0.73"
21
21
  },
22
22
  "keywords": [
23
23
  "traderclaw",