@opentrust/guards 7.3.10 → 7.3.11
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.
|
@@ -15,6 +15,8 @@ export function executeCommand(cmd: RemoteCommand, log: Logger): CommandResult {
|
|
|
15
15
|
switch (cmd.type) {
|
|
16
16
|
case "install_skill":
|
|
17
17
|
return executeSkillInstall(cmd.payload, log);
|
|
18
|
+
case "install_custom_skill":
|
|
19
|
+
return executeCustomSkillInstall(cmd.payload, log);
|
|
18
20
|
case "uninstall_skill":
|
|
19
21
|
return executeSkillUninstall(cmd.payload, log);
|
|
20
22
|
case "update_config":
|
|
@@ -44,6 +46,53 @@ function executeSkillInstall(payload: Record<string, unknown> | null, log: Logge
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
function executeCustomSkillInstall(payload: Record<string, unknown> | null, log: Logger): CommandResult {
|
|
50
|
+
const skillName = payload?.skillName as string;
|
|
51
|
+
const content = payload?.content as string;
|
|
52
|
+
if (!skillName || !content) {
|
|
53
|
+
return { success: false, error: "Missing skillName or content in payload" };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
const skillsDir = path.join(
|
|
58
|
+
process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw"),
|
|
59
|
+
"skills",
|
|
60
|
+
);
|
|
61
|
+
const skillDir = path.join(skillsDir, skillName);
|
|
62
|
+
|
|
63
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
64
|
+
|
|
65
|
+
const ext = detectContentFormat(content);
|
|
66
|
+
const fileName = `skill.${ext}`;
|
|
67
|
+
fs.writeFileSync(path.join(skillDir, fileName), content, "utf-8");
|
|
68
|
+
|
|
69
|
+
log.info(`Command: custom skill "${skillName}" written to ${skillDir}/${fileName}`);
|
|
70
|
+
|
|
71
|
+
// Try `openclaw skills install` from local path; fall back to file-only approach
|
|
72
|
+
try {
|
|
73
|
+
const output = execSync(`openclaw skills install ${skillDir}`, {
|
|
74
|
+
encoding: "utf-8",
|
|
75
|
+
timeout: 120_000,
|
|
76
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
77
|
+
});
|
|
78
|
+
return { success: true, output: output.trim() };
|
|
79
|
+
} catch {
|
|
80
|
+
return { success: true, output: `Custom skill "${skillName}" saved to ${skillDir}/${fileName}` };
|
|
81
|
+
}
|
|
82
|
+
} catch (err: any) {
|
|
83
|
+
const msg = err.message || String(err);
|
|
84
|
+
log.warn(`Command: custom skill install failed — ${msg}`);
|
|
85
|
+
return { success: false, error: msg.slice(0, 500) };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function detectContentFormat(content: string): string {
|
|
90
|
+
const trimmed = content.trim();
|
|
91
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) return "json";
|
|
92
|
+
if (trimmed.startsWith("---") || /^\w+:/m.test(trimmed)) return "yaml";
|
|
93
|
+
return "md";
|
|
94
|
+
}
|
|
95
|
+
|
|
47
96
|
function executeSkillUninstall(payload: Record<string, unknown> | null, log: Logger): CommandResult {
|
|
48
97
|
const skillName = payload?.skillName as string;
|
|
49
98
|
if (!skillName) return { success: false, error: "Missing skillName in payload" };
|
package/openclaw.plugin.json
CHANGED
|
@@ -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.
|
|
5
|
+
"version": "7.3.11",
|
|
6
6
|
"configSchema": {
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
package/package.json
CHANGED
package/platform-client/types.ts
CHANGED
|
@@ -111,7 +111,7 @@ export type ToolCallObservationRequest = {
|
|
|
111
111
|
export type RemoteCommand = {
|
|
112
112
|
id: string;
|
|
113
113
|
agentId: string;
|
|
114
|
-
type: "install_skill" | "uninstall_skill" | "update_config";
|
|
114
|
+
type: "install_skill" | "install_custom_skill" | "uninstall_skill" | "update_config";
|
|
115
115
|
payload: Record<string, unknown> | null;
|
|
116
116
|
status: string;
|
|
117
117
|
createdAt: string;
|