@opentrust/cli 7.3.28 → 7.3.29

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.28",
17
- "@opentrust/gateway": "^7.3.28",
18
- "@opentrust/dashboard": "^7.3.28",
16
+ "@opentrust/core": "^7.3.29",
17
+ "@opentrust/gateway": "^7.3.29",
18
+ "@opentrust/dashboard": "^7.3.29",
19
19
  },
20
20
  };
21
21
  const ENV_TEMPLATE = `# OpenTrust Configuration
@@ -7,12 +7,13 @@ import { paths, projectRoot, projectMode } from "./paths.js";
7
7
  const SERVICE_KEYS = Object.keys(SERVICES);
8
8
  const OPENCLAW_HOME = process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw");
9
9
  function clawExecOpts(timeoutMs = 120_000) {
10
+ const { OPENCLAW_HOME: _, ...restEnv } = process.env;
10
11
  return {
11
12
  encoding: "utf-8",
12
13
  timeout: timeoutMs,
13
14
  stdio: ["pipe", "pipe", "pipe"],
14
15
  cwd: os.homedir(),
15
- env: { ...process.env, HOME: os.homedir(), OPENCLAW_HOME },
16
+ env: { ...restEnv, HOME: os.homedir() },
16
17
  };
17
18
  }
18
19
  export function executeHostCommand(cmd) {
@@ -216,25 +217,13 @@ function handleInstallPlugin(payload) {
216
217
  const spec = payload.spec;
217
218
  if (!spec)
218
219
  return { success: false, error: "Missing spec in payload" };
219
- try {
220
- const output = execSync(`openclaw plugins install ${spec}`, clawExecOpts(180_000));
221
- return { success: true, output: output.trim().slice(-500) };
222
- }
223
- catch (err) {
224
- return { success: false, error: (err.stderr?.toString() || err.message || String(err)).slice(0, 500) };
225
- }
220
+ return runClawPluginCmd(`openclaw plugins install ${spec}`);
226
221
  }
227
222
  function handleUninstallPlugin(payload) {
228
223
  const pluginId = payload.pluginId;
229
224
  if (!pluginId)
230
225
  return { success: false, error: "Missing pluginId in payload" };
231
- try {
232
- const output = execSync(`openclaw plugins uninstall ${pluginId} --force`, clawExecOpts(60_000));
233
- return { success: true, output: output.trim().slice(-500) };
234
- }
235
- catch (err) {
236
- return { success: false, error: (err.stderr?.toString() || err.message || String(err)).slice(0, 500) };
237
- }
226
+ return runClawPluginCmd(`openclaw plugins uninstall ${pluginId} --force`, 60_000);
238
227
  }
239
228
  function handleUpdateConfig(payload) {
240
229
  if (Object.keys(payload).length === 0)
@@ -256,26 +245,44 @@ function handleUpdateConfig(payload) {
256
245
  }
257
246
  }
258
247
  // ── Guards install / upgrade ─────────────────────────
259
- function handleInstallGuards(payload) {
260
- const version = payload.version || "latest";
261
- const spec = version === "latest" ? "@opentrust/guards" : `@opentrust/guards@${version}`;
248
+ function isOnlyWarnings(text) {
249
+ const lines = text.split("\n").map((l) => l.replace(/\x1b\[[0-9;]*m/g, "").trim()).filter(Boolean);
250
+ return lines.every((l) => l.startsWith("Config warnings") ||
251
+ l.startsWith("- plugins.") ||
252
+ l.includes("plugins.allow is empty") ||
253
+ l.startsWith("[plugins]") ||
254
+ l.startsWith("duplicate plugin") ||
255
+ l.includes("plugin id mismatch"));
256
+ }
257
+ function runClawPluginCmd(cmd, timeoutMs = 180_000) {
262
258
  try {
263
- const output = execSync(`openclaw plugins install ${spec}`, clawExecOpts(180_000));
259
+ const output = execSync(cmd, clawExecOpts(timeoutMs));
264
260
  return { success: true, output: output.trim().slice(-1000) };
265
261
  }
266
262
  catch (err) {
267
- return { success: false, error: (err.stderr?.toString() || err.message || String(err)).slice(0, 1000) };
263
+ const stderr = err.stderr?.toString() || "";
264
+ const stdout = err.stdout?.toString() || "";
265
+ if (isOnlyWarnings(stderr) || isOnlyWarnings(stdout + stderr)) {
266
+ return { success: true, output: `Done (with warnings):\n${(stdout + stderr).trim()}`.slice(-1000) };
267
+ }
268
+ return { success: false, error: (stderr || err.message || String(err)).slice(0, 1000) };
268
269
  }
269
270
  }
271
+ function handleInstallGuards(payload) {
272
+ const version = payload.version || "latest";
273
+ const spec = version === "latest" ? "@opentrust/guards" : `@opentrust/guards@${version}`;
274
+ return runClawPluginCmd(`openclaw plugins install ${spec}`);
275
+ }
270
276
  function handleUpgradeGuards(payload) {
271
277
  const version = payload.version || "latest";
272
278
  const spec = version === "latest" ? "@opentrust/guards" : `@opentrust/guards@${version}`;
273
- try {
274
- const uninstallOut = execSync("openclaw plugins uninstall @opentrust/guards --force", clawExecOpts(60_000));
275
- const installOut = execSync(`openclaw plugins install ${spec}`, clawExecOpts(180_000));
276
- return { success: true, output: `Uninstall: ${uninstallOut.trim()}\nInstall: ${installOut.trim()}`.slice(-1000) };
277
- }
278
- catch (err) {
279
- return { success: false, error: (err.stderr?.toString() || err.message || String(err)).slice(0, 1000) };
280
- }
279
+ const uninstall = runClawPluginCmd("openclaw plugins uninstall @opentrust/guards --force", 60_000);
280
+ if (!uninstall.success)
281
+ return uninstall;
282
+ const install = runClawPluginCmd(`openclaw plugins install ${spec}`);
283
+ return {
284
+ success: install.success,
285
+ output: `Uninstall: ${uninstall.output ?? "ok"}\nInstall: ${install.output ?? "ok"}`.slice(-1000),
286
+ error: install.error,
287
+ };
281
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentrust/cli",
3
- "version": "7.3.28",
3
+ "version": "7.3.29",
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": {