@opentrust/cli 7.3.36 → 7.3.37

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.
@@ -13,9 +13,9 @@ const SCAFFOLD_PKG = {
13
13
  status: "opentrust status",
14
14
  },
15
15
  dependencies: {
16
- "@opentrust/core": "^7.3.36",
17
- "@opentrust/gateway": "^7.3.36",
18
- "@opentrust/dashboard": "^7.3.36",
16
+ "@opentrust/core": "^7.3.37",
17
+ "@opentrust/gateway": "^7.3.37",
18
+ "@opentrust/dashboard": "^7.3.37",
19
19
  },
20
20
  };
21
21
  const ENV_TEMPLATE = `# OpenTrust Configuration
@@ -282,13 +282,13 @@ function runClawPluginCmd(cmd, timeoutMs = 180_000) {
282
282
  }
283
283
  function handleInstallGuards(payload) {
284
284
  const version = payload.version || "latest";
285
- const spec = version === "latest" ? "@opentrust/guards" : `@opentrust/guards@${version}`;
285
+ const spec = version === "latest" ? "@opentrust/opentrust-guard" : `@opentrust/opentrust-guard@${version}`;
286
286
  return runClawPluginCmd(`openclaw plugins install ${spec}`);
287
287
  }
288
288
  function handleUpgradeGuards(payload) {
289
289
  const version = payload.version || "latest";
290
- const spec = version === "latest" ? "@opentrust/guards" : `@opentrust/guards@${version}`;
291
- const uninstall = runClawPluginCmd("openclaw plugins uninstall @opentrust/guards --force", 60_000);
290
+ const spec = version === "latest" ? "@opentrust/opentrust-guard" : `@opentrust/opentrust-guard@${version}`;
291
+ const uninstall = runClawPluginCmd("openclaw plugins uninstall @opentrust/opentrust-guard --force", 60_000);
292
292
  if (!uninstall.success)
293
293
  return uninstall;
294
294
  const install = runClawPluginCmd(`openclaw plugins install ${spec}`);
@@ -351,25 +351,52 @@ async function handleInstallOpenclaw(payload, progress) {
351
351
  });
352
352
  cmdLog(`Guards URLs → dashboardUrl=${gc.dashboardUrl}, coreUrl=${gc.coreUrl}`);
353
353
  }
354
- // Step 1: Write openclaw.json config FIRST (so install script detects it and skips onboarding)
355
- cmdLog("[1/3] Writing ~/.openclaw/openclaw.json ...");
354
+ // Ensure plugins.allow includes opentrust-guard
355
+ if (!config.plugins)
356
+ config.plugins = {};
357
+ if (!Array.isArray(config.plugins.allow))
358
+ config.plugins.allow = [];
359
+ if (!config.plugins.allow.includes("opentrust-guard")) {
360
+ config.plugins.allow.push("opentrust-guard");
361
+ }
362
+ const clawHome = path.join(os.homedir(), ".openclaw");
363
+ const configFile = path.join(clawHome, "openclaw.json");
364
+ // Helper: resolve openclaw binary with extra PATH entries
365
+ const resolveExtraPaths = () => {
366
+ const extra = [
367
+ path.join(os.homedir(), ".local", "bin"),
368
+ path.join(os.homedir(), ".openclaw", "bin"),
369
+ "/usr/local/bin",
370
+ ];
371
+ try {
372
+ const npmPrefix = execSync("npm config get prefix", { encoding: "utf-8", timeout: 5_000 }).trim();
373
+ if (npmPrefix)
374
+ extra.push(path.join(npmPrefix, "bin"));
375
+ }
376
+ catch { }
377
+ return extra;
378
+ };
379
+ const makeEnv = (extraPaths) => {
380
+ const { OPENCLAW_HOME: _, ...rest } = process.env;
381
+ return { ...rest, HOME: os.homedir(), PATH: `${extraPaths.join(":")}:${process.env.PATH ?? ""}` };
382
+ };
383
+ // Step 1: Write initial config (so install script detects it and skips interactive setup)
384
+ cmdLog("[1/5] Writing ~/.openclaw/openclaw.json ...");
356
385
  await sendProgress();
357
386
  try {
358
- const clawHome = path.join(os.homedir(), ".openclaw");
359
387
  fs.mkdirSync(clawHome, { recursive: true });
360
- const configFile = path.join(clawHome, "openclaw.json");
361
388
  fs.writeFileSync(configFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
362
- cmdLog(`[1/3] Config written to ${configFile}`);
389
+ cmdLog(`[1/5] Config written to ${configFile}`);
363
390
  }
364
391
  catch (err) {
365
392
  const msg = `Failed to write config: ${(err.message || String(err)).slice(0, 500)}`;
366
- cmdLog(`[1/3] ${msg}`);
393
+ cmdLog(`[1/5] ${msg}`);
367
394
  await sendProgress();
368
395
  return { success: false, output: _cmdOutput.join("\n"), error: msg };
369
396
  }
370
397
  await sendProgress();
371
- // Step 2: Install OpenClaw via curl (non-interactive: CI=1, pipe stdin to /dev/null)
372
- cmdLog("[2/3] Installing OpenClaw (curl -fsSL https://openclaw.ai/install.sh | bash)...");
398
+ // Step 2: Install OpenClaw via curl (non-interactive)
399
+ cmdLog("[2/5] Installing OpenClaw (curl -fsSL https://openclaw.ai/install.sh | bash)...");
373
400
  await sendProgress();
374
401
  try {
375
402
  execSync("curl -fsSL https://openclaw.ai/install.sh | bash", {
@@ -386,62 +413,90 @@ async function handleInstallOpenclaw(payload, progress) {
386
413
  },
387
414
  shell: "/bin/bash",
388
415
  });
389
- cmdLog("[2/3] OpenClaw install script completed");
416
+ cmdLog("[2/5] OpenClaw install script completed");
390
417
  }
391
418
  catch (err) {
392
419
  const code = err.status;
393
420
  if (code === 0 || code === null) {
394
- cmdLog("[2/3] OpenClaw install script finished (exit code ignored)");
421
+ cmdLog("[2/5] OpenClaw install script finished (exit code ignored)");
395
422
  }
396
423
  else {
397
- cmdLog(`[2/3] Install script exited with code ${code}`);
424
+ cmdLog(`[2/5] Install script exited with code ${code}`);
398
425
  }
399
426
  }
400
427
  await sendProgress();
401
- // Re-write config (install script may have overwritten it during setup)
428
+ // Step 3: Non-interactive onboarding + daemon install
429
+ const clawBin = findOpenclawBin();
430
+ cmdLog(`[3/5] Running onboarding (${clawBin} onboard --non-interactive --install-daemon)...`);
431
+ await sendProgress();
402
432
  try {
403
- const configFile = path.join(os.homedir(), ".openclaw", "openclaw.json");
404
- fs.writeFileSync(configFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
405
- cmdLog("[2/3] Config re-written (ensuring our template is used)");
433
+ const extraPaths = resolveExtraPaths();
434
+ execSync(`${clawBin} onboard --non-interactive --install-daemon`, {
435
+ encoding: "utf-8",
436
+ timeout: 120_000,
437
+ stdio: ["ignore", "inherit", "inherit"],
438
+ cwd: os.homedir(),
439
+ env: {
440
+ ...makeEnv(extraPaths),
441
+ CI: "1",
442
+ NONINTERACTIVE: "1",
443
+ OPENCLAW_ACCEPT_TOS: "1",
444
+ OPENCLAW_ACCEPT_RISK: "1",
445
+ },
446
+ });
447
+ cmdLog("[3/5] Onboarding completed");
448
+ }
449
+ catch (err) {
450
+ const code = err.status;
451
+ cmdLog(`[3/5] Onboarding exited with code ${code ?? "unknown"} (continuing)`);
406
452
  }
407
- catch { }
408
453
  await sendProgress();
409
- // Step 3: Auto-install Guards plugin resolve openclaw binary from multiple locations
410
- const clawBin = findOpenclawBin();
411
- cmdLog(`[3/3] Installing Guards plugin (${clawBin} plugins install @opentrust/guards)...`);
454
+ // Step 4: Re-write config (onboarding may have overwritten our template)
455
+ cmdLog("[4/5] Re-writing config (ensuring our template + plugins.allow)...");
412
456
  await sendProgress();
413
457
  try {
414
- const extraPaths = [
415
- path.join(os.homedir(), ".local", "bin"),
416
- path.join(os.homedir(), ".openclaw", "bin"),
417
- "/usr/local/bin",
418
- ];
419
- // Also discover npm global bin directory
458
+ // Merge: read current config from disk (onboarding may have added fields), overlay our template
459
+ let merged = config;
420
460
  try {
421
- const npmBin = execSync("npm config get prefix", { encoding: "utf-8", timeout: 5_000 }).trim();
422
- if (npmBin)
423
- extraPaths.push(path.join(npmBin, "bin"));
461
+ const diskConfig = JSON.parse(fs.readFileSync(configFile, "utf-8"));
462
+ merged = { ...diskConfig, ...config, plugins: { ...diskConfig.plugins, ...config.plugins } };
463
+ // Re-ensure plugins.allow
464
+ if (!Array.isArray(merged.plugins.allow))
465
+ merged.plugins.allow = [];
466
+ if (!merged.plugins.allow.includes("opentrust-guard"))
467
+ merged.plugins.allow.push("opentrust-guard");
424
468
  }
425
469
  catch { }
426
- const { OPENCLAW_HOME: _, ...restEnv } = process.env;
427
- execSync(`${clawBin} plugins install @opentrust/guards`, {
470
+ fs.writeFileSync(configFile, JSON.stringify(merged, null, 2) + "\n", "utf-8");
471
+ cmdLog("[4/5] Config written with plugins.allow: " + JSON.stringify(merged.plugins.allow));
472
+ }
473
+ catch (err) {
474
+ cmdLog(`[4/5] Config re-write failed: ${(err.message || String(err)).slice(0, 200)}`);
475
+ }
476
+ await sendProgress();
477
+ // Step 5: Auto-install Guards plugin
478
+ cmdLog(`[5/5] Installing Guards plugin (${clawBin} plugins install @opentrust/opentrust-guard)...`);
479
+ await sendProgress();
480
+ try {
481
+ const extraPaths = resolveExtraPaths();
482
+ execSync(`${clawBin} plugins install @opentrust/opentrust-guard`, {
428
483
  encoding: "utf-8",
429
484
  timeout: 180_000,
430
485
  stdio: ["pipe", "pipe", "pipe"],
431
486
  cwd: os.homedir(),
432
- env: { ...restEnv, HOME: os.homedir(), PATH: `${extraPaths.join(":")}:${process.env.PATH ?? ""}` },
487
+ env: makeEnv(extraPaths),
433
488
  });
434
- cmdLog("[3/3] Guards plugin installed successfully");
489
+ cmdLog("[5/5] Guards plugin installed successfully");
435
490
  }
436
491
  catch (err) {
437
492
  const stderr = err.stderr?.toString() || "";
438
493
  const stdout = err.stdout?.toString() || "";
439
494
  if (isOnlyWarnings(stderr) || isOnlyWarnings(stdout + stderr)) {
440
- cmdLog("[3/3] Guards plugin installed (with warnings)");
495
+ cmdLog("[5/5] Guards plugin installed (with warnings)");
441
496
  }
442
497
  else {
443
498
  const errMsg = (stderr || err.message || String(err)).slice(0, 300);
444
- cmdLog(`[3/3] Guards plugin install failed: ${errMsg}`);
499
+ cmdLog(`[5/5] Guards plugin install failed: ${errMsg}`);
445
500
  }
446
501
  }
447
502
  cmdLog("install_openclaw complete");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentrust/cli",
3
- "version": "7.3.36",
3
+ "version": "7.3.37",
4
4
  "description": "CLI tool to manage OpenTrust AI Agent Runtime Security Platform — setup, start, stop, status, logs",
5
5
  "type": "module",
6
6
  "bin": {