@opentrust/cli 7.3.25 → 7.3.26
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.
package/dist/commands/init.js
CHANGED
|
@@ -13,9 +13,9 @@ const SCAFFOLD_PKG = {
|
|
|
13
13
|
status: "opentrust status",
|
|
14
14
|
},
|
|
15
15
|
dependencies: {
|
|
16
|
-
"@opentrust/core": "^7.3.
|
|
17
|
-
"@opentrust/gateway": "^7.3.
|
|
18
|
-
"@opentrust/dashboard": "^7.3.
|
|
16
|
+
"@opentrust/core": "^7.3.26",
|
|
17
|
+
"@opentrust/gateway": "^7.3.26",
|
|
18
|
+
"@opentrust/dashboard": "^7.3.26",
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
const ENV_TEMPLATE = `# OpenTrust Configuration
|
|
@@ -42,6 +42,10 @@ export function executeHostCommand(cmd) {
|
|
|
42
42
|
return handleUninstallPlugin(payload);
|
|
43
43
|
case "update_config":
|
|
44
44
|
return handleUpdateConfig(payload);
|
|
45
|
+
case "install_guards":
|
|
46
|
+
return handleInstallGuards(payload);
|
|
47
|
+
case "upgrade_guards":
|
|
48
|
+
return handleUpgradeGuards(payload);
|
|
45
49
|
default:
|
|
46
50
|
return { success: false, error: `Unknown command type: ${cmd.type}` };
|
|
47
51
|
}
|
|
@@ -251,3 +255,27 @@ function handleUpdateConfig(payload) {
|
|
|
251
255
|
return { success: false, error: (err.message || String(err)).slice(0, 500) };
|
|
252
256
|
}
|
|
253
257
|
}
|
|
258
|
+
// ── Guards install / upgrade ─────────────────────────
|
|
259
|
+
function handleInstallGuards(payload) {
|
|
260
|
+
const version = payload.version || "latest";
|
|
261
|
+
const spec = version === "latest" ? "@opentrust/guards" : `@opentrust/guards@${version}`;
|
|
262
|
+
try {
|
|
263
|
+
const output = execSync(`openclaw plugins install ${spec}`, clawExecOpts(180_000));
|
|
264
|
+
return { success: true, output: output.trim().slice(-1000) };
|
|
265
|
+
}
|
|
266
|
+
catch (err) {
|
|
267
|
+
return { success: false, error: (err.stderr?.toString() || err.message || String(err)).slice(0, 1000) };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function handleUpgradeGuards(payload) {
|
|
271
|
+
const version = payload.version || "latest";
|
|
272
|
+
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
|
+
}
|
|
281
|
+
}
|
|
@@ -46,6 +46,30 @@ export async function getServicesSnapshot() {
|
|
|
46
46
|
}
|
|
47
47
|
return result;
|
|
48
48
|
}
|
|
49
|
+
function detectGuards() {
|
|
50
|
+
const openclawHome = process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw");
|
|
51
|
+
try {
|
|
52
|
+
const configPath = path.join(openclawHome, "openclaw.json");
|
|
53
|
+
if (!fs.existsSync(configPath))
|
|
54
|
+
return { installed: false };
|
|
55
|
+
const json = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
56
|
+
const entry = json?.plugins?.entries?.["opentrust-guard"];
|
|
57
|
+
if (!entry)
|
|
58
|
+
return { installed: false };
|
|
59
|
+
let version;
|
|
60
|
+
const pkgPath = path.join(entry.directory || "", "package.json");
|
|
61
|
+
if (fs.existsSync(pkgPath)) {
|
|
62
|
+
try {
|
|
63
|
+
version = JSON.parse(fs.readFileSync(pkgPath, "utf-8")).version;
|
|
64
|
+
}
|
|
65
|
+
catch { }
|
|
66
|
+
}
|
|
67
|
+
return { installed: true, version };
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return { installed: false };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
49
73
|
export function getSystemMetadata() {
|
|
50
74
|
const cpus = os.cpus();
|
|
51
75
|
return {
|
|
@@ -55,5 +79,6 @@ export function getSystemMetadata() {
|
|
|
55
79
|
freeMemMB: Math.round(os.freemem() / 1048576),
|
|
56
80
|
uptime: os.uptime(),
|
|
57
81
|
nodeVersion: process.version,
|
|
82
|
+
guards: detectGuards(),
|
|
58
83
|
};
|
|
59
84
|
}
|