@opentrust/cli 7.3.35 → 7.3.36

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.35",
17
- "@opentrust/gateway": "^7.3.35",
18
- "@opentrust/dashboard": "^7.3.35",
16
+ "@opentrust/core": "^7.3.36",
17
+ "@opentrust/gateway": "^7.3.36",
18
+ "@opentrust/dashboard": "^7.3.36",
19
19
  },
20
20
  };
21
21
  const ENV_TEMPLATE = `# OpenTrust Configuration
@@ -305,10 +305,24 @@ function findOpenclawBin() {
305
305
  "/usr/local/bin/openclaw",
306
306
  path.join(os.homedir(), ".openclaw", "bin", "openclaw"),
307
307
  ];
308
+ // Try npm global bin path
309
+ try {
310
+ const npmPrefix = execSync("npm config get prefix", { encoding: "utf-8", timeout: 5_000 }).trim();
311
+ if (npmPrefix)
312
+ candidates.push(path.join(npmPrefix, "bin", "openclaw"));
313
+ }
314
+ catch { }
308
315
  for (const p of candidates) {
309
316
  if (fs.existsSync(p))
310
317
  return p;
311
318
  }
319
+ // Last resort: try `which openclaw`
320
+ try {
321
+ const w = execSync("which openclaw", { encoding: "utf-8", timeout: 5_000 }).trim();
322
+ if (w)
323
+ return w;
324
+ }
325
+ catch { }
312
326
  return "openclaw";
313
327
  }
314
328
  async function handleInstallOpenclaw(payload, progress) {
@@ -337,48 +351,62 @@ async function handleInstallOpenclaw(payload, progress) {
337
351
  });
338
352
  cmdLog(`Guards URLs → dashboardUrl=${gc.dashboardUrl}, coreUrl=${gc.coreUrl}`);
339
353
  }
340
- // Step 1: Install OpenClaw via curl
341
- cmdLog("[1/3] Installing OpenClaw (curl -fsSL https://openclaw.ai/install.sh | bash)...");
354
+ // Step 1: Write openclaw.json config FIRST (so install script detects it and skips onboarding)
355
+ cmdLog("[1/3] Writing ~/.openclaw/openclaw.json ...");
356
+ await sendProgress();
357
+ try {
358
+ const clawHome = path.join(os.homedir(), ".openclaw");
359
+ fs.mkdirSync(clawHome, { recursive: true });
360
+ const configFile = path.join(clawHome, "openclaw.json");
361
+ fs.writeFileSync(configFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
362
+ cmdLog(`[1/3] Config written to ${configFile}`);
363
+ }
364
+ catch (err) {
365
+ const msg = `Failed to write config: ${(err.message || String(err)).slice(0, 500)}`;
366
+ cmdLog(`[1/3] ${msg}`);
367
+ await sendProgress();
368
+ return { success: false, output: _cmdOutput.join("\n"), error: msg };
369
+ }
370
+ 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)...");
342
373
  await sendProgress();
343
374
  try {
344
375
  execSync("curl -fsSL https://openclaw.ai/install.sh | bash", {
345
376
  encoding: "utf-8",
346
- timeout: 180_000,
347
- stdio: ["pipe", "inherit", "inherit"],
377
+ timeout: 300_000,
378
+ stdio: ["ignore", "inherit", "inherit"],
348
379
  cwd: os.homedir(),
349
- env: { ...process.env, HOME: os.homedir() },
380
+ env: {
381
+ ...process.env,
382
+ HOME: os.homedir(),
383
+ CI: "1",
384
+ NONINTERACTIVE: "1",
385
+ OPENCLAW_ACCEPT_TOS: "1",
386
+ },
350
387
  shell: "/bin/bash",
351
388
  });
352
- cmdLog("[1/3] OpenClaw install script completed");
389
+ cmdLog("[2/3] OpenClaw install script completed");
353
390
  }
354
391
  catch (err) {
355
392
  const code = err.status;
356
393
  if (code === 0 || code === null) {
357
- cmdLog("[1/3] OpenClaw install script finished (exit code ignored)");
394
+ cmdLog("[2/3] OpenClaw install script finished (exit code ignored)");
358
395
  }
359
396
  else {
360
- cmdLog(`[1/3] Install script exited with code ${code}`);
397
+ cmdLog(`[2/3] Install script exited with code ${code}`);
361
398
  }
362
399
  }
363
400
  await sendProgress();
364
- // Step 2: Write openclaw.json config
365
- cmdLog("[2/3] Writing ~/.openclaw/openclaw.json ...");
366
- await sendProgress();
401
+ // Re-write config (install script may have overwritten it during setup)
367
402
  try {
368
- const clawHome = path.join(os.homedir(), ".openclaw");
369
- fs.mkdirSync(clawHome, { recursive: true });
370
- const configFile = path.join(clawHome, "openclaw.json");
403
+ const configFile = path.join(os.homedir(), ".openclaw", "openclaw.json");
371
404
  fs.writeFileSync(configFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
372
- cmdLog(`[2/3] Config written to ${configFile}`);
373
- }
374
- catch (err) {
375
- const msg = `Failed to write config: ${(err.message || String(err)).slice(0, 500)}`;
376
- cmdLog(`[2/3] ${msg}`);
377
- await sendProgress();
378
- return { success: false, output: _cmdOutput.join("\n"), error: msg };
405
+ cmdLog("[2/3] Config re-written (ensuring our template is used)");
379
406
  }
407
+ catch { }
380
408
  await sendProgress();
381
- // Step 3: Auto-install Guards plugin
409
+ // Step 3: Auto-install Guards plugin — resolve openclaw binary from multiple locations
382
410
  const clawBin = findOpenclawBin();
383
411
  cmdLog(`[3/3] Installing Guards plugin (${clawBin} plugins install @opentrust/guards)...`);
384
412
  await sendProgress();
@@ -387,14 +415,21 @@ async function handleInstallOpenclaw(payload, progress) {
387
415
  path.join(os.homedir(), ".local", "bin"),
388
416
  path.join(os.homedir(), ".openclaw", "bin"),
389
417
  "/usr/local/bin",
390
- ].join(":");
418
+ ];
419
+ // Also discover npm global bin directory
420
+ 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"));
424
+ }
425
+ catch { }
391
426
  const { OPENCLAW_HOME: _, ...restEnv } = process.env;
392
427
  execSync(`${clawBin} plugins install @opentrust/guards`, {
393
428
  encoding: "utf-8",
394
429
  timeout: 180_000,
395
430
  stdio: ["pipe", "pipe", "pipe"],
396
431
  cwd: os.homedir(),
397
- env: { ...restEnv, HOME: os.homedir(), PATH: `${extraPaths}:${process.env.PATH ?? ""}` },
432
+ env: { ...restEnv, HOME: os.homedir(), PATH: `${extraPaths.join(":")}:${process.env.PATH ?? ""}` },
398
433
  });
399
434
  cmdLog("[3/3] Guards plugin installed successfully");
400
435
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentrust/cli",
3
- "version": "7.3.35",
3
+ "version": "7.3.36",
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": {