@opentrust/guards 7.3.13 → 7.3.16

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.
@@ -1,4 +1,4 @@
1
- import { execSync } from "node:child_process";
1
+ import { execSync, type ExecSyncOptions } from "node:child_process";
2
2
  import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
@@ -11,6 +11,18 @@ export interface CommandResult {
11
11
  error?: string;
12
12
  }
13
13
 
14
+ const OPENCLAW_HOME = process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw");
15
+
16
+ function execOpts(timeoutMs = 120_000): ExecSyncOptions {
17
+ return {
18
+ encoding: "utf-8" as const,
19
+ timeout: timeoutMs,
20
+ stdio: ["pipe", "pipe", "pipe"] as const,
21
+ cwd: os.homedir(),
22
+ env: { ...process.env, HOME: os.homedir(), OPENCLAW_HOME },
23
+ };
24
+ }
25
+
14
26
  export function executeCommand(cmd: RemoteCommand, log: Logger): CommandResult {
15
27
  switch (cmd.type) {
16
28
  case "install_skill":
@@ -32,11 +44,7 @@ function executeSkillInstall(payload: Record<string, unknown> | null, log: Logge
32
44
 
33
45
  try {
34
46
  log.info(`Command: installing skill "${skillName}"...`);
35
- const output = execSync(`clawhub install ${skillName}`, {
36
- encoding: "utf-8",
37
- timeout: 120_000,
38
- stdio: ["pipe", "pipe", "pipe"],
39
- });
47
+ const output = execSync(`clawhub install ${skillName}`, execOpts()) as string;
40
48
  log.info(`Command: skill "${skillName}" installed`);
41
49
  return { success: true, output: output.trim() };
42
50
  } catch (err: any) {
@@ -54,10 +62,7 @@ function executeCustomSkillInstall(payload: Record<string, unknown> | null, log:
54
62
  }
55
63
 
56
64
  try {
57
- const skillsDir = path.join(
58
- process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw"),
59
- "skills",
60
- );
65
+ const skillsDir = path.join(OPENCLAW_HOME, "skills");
61
66
  const skillDir = path.join(skillsDir, skillName);
62
67
 
63
68
  fs.mkdirSync(skillDir, { recursive: true });
@@ -68,11 +73,7 @@ function executeCustomSkillInstall(payload: Record<string, unknown> | null, log:
68
73
  log.info(`Command: custom skill "${skillName}" written to ${skillDir}/${fileName}`);
69
74
 
70
75
  try {
71
- const output = execSync(`clawhub install ${skillDir}`, {
72
- encoding: "utf-8",
73
- timeout: 120_000,
74
- stdio: ["pipe", "pipe", "pipe"],
75
- });
76
+ const output = execSync(`clawhub install ${skillDir}`, execOpts()) as string;
76
77
  return { success: true, output: output.trim() };
77
78
  } catch {
78
79
  return { success: true, output: `Custom skill "${skillName}" saved to ${skillDir}/${fileName}` };
@@ -90,11 +91,7 @@ function executeSkillUninstall(payload: Record<string, unknown> | null, log: Log
90
91
 
91
92
  try {
92
93
  log.info(`Command: uninstalling skill "${skillName}"...`);
93
- const output = execSync(`clawhub uninstall ${skillName}`, {
94
- encoding: "utf-8",
95
- timeout: 60_000,
96
- stdio: ["pipe", "pipe", "pipe"],
97
- });
94
+ const output = execSync(`clawhub uninstall ${skillName}`, execOpts(60_000)) as string;
98
95
  log.info(`Command: skill "${skillName}" uninstalled`);
99
96
  return { success: true, output: output.trim() };
100
97
  } catch (err: any) {
@@ -110,7 +107,7 @@ function executeUpdateConfig(payload: Record<string, unknown> | null, log: Logge
110
107
  }
111
108
 
112
109
  try {
113
- const configDir = process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw");
110
+ const configDir = OPENCLAW_HOME;
114
111
  const configFile = path.join(configDir, "openclaw.json");
115
112
 
116
113
  if (!fs.existsSync(configFile)) {
@@ -2,7 +2,7 @@
2
2
  "id": "opentrust-guard",
3
3
  "name": "OpenTrust Guard",
4
4
  "description": "AI security guard for OpenClaw agents: prompt injection detection, credential scanning, and behavioral monitoring.",
5
- "version": "7.3.13",
5
+ "version": "7.3.16",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentrust/guards",
3
- "version": "7.3.13",
3
+ "version": "7.3.16",
4
4
  "description": "AI agent security plugin for OpenClaw: prompt injection detection, PII sanitization, and monitoring",
5
5
  "type": "module",
6
6
  "main": "index.ts",