@agenshield/broker 0.4.2 → 0.4.4
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/handlers/skill-install.d.ts.map +1 -1
- package/index.js +33 -0
- package/main.js +51 -3
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-install.d.ts","sourceRoot":"","sources":["../../src/handlers/skill-install.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAEb,kBAAkB,EAElB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA4CtD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"skill-install.d.ts","sourceRoot":"","sources":["../../src/handlers/skill-install.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAEb,kBAAkB,EAElB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA4CtD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CA+I5C;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAiF9C"}
|
package/index.js
CHANGED
|
@@ -595,6 +595,7 @@ async function handlePing(params, context, deps) {
|
|
|
595
595
|
|
|
596
596
|
// libs/shield-broker/src/handlers/skill-install.ts
|
|
597
597
|
import * as fs2 from "node:fs/promises";
|
|
598
|
+
import * as fsSync from "node:fs";
|
|
598
599
|
import * as path3 from "node:path";
|
|
599
600
|
import { execSync } from "node:child_process";
|
|
600
601
|
function isValidSlug(slug) {
|
|
@@ -684,6 +685,26 @@ async function handleSkillInstall(params, context, deps) {
|
|
|
684
685
|
} catch (err) {
|
|
685
686
|
console.warn(`[SkillInstall] chown failed (may be expected in dev): ${err.message}`);
|
|
686
687
|
}
|
|
688
|
+
const openclawConfigPath = path3.join(agentHome, ".openclaw", "openclaw.json");
|
|
689
|
+
try {
|
|
690
|
+
let openclawConfig = {};
|
|
691
|
+
try {
|
|
692
|
+
const raw = fsSync.readFileSync(openclawConfigPath, "utf-8");
|
|
693
|
+
openclawConfig = JSON.parse(raw);
|
|
694
|
+
} catch {
|
|
695
|
+
}
|
|
696
|
+
if (!openclawConfig.skills) {
|
|
697
|
+
openclawConfig.skills = {};
|
|
698
|
+
}
|
|
699
|
+
const skills = openclawConfig.skills;
|
|
700
|
+
if (!skills.entries) {
|
|
701
|
+
skills.entries = {};
|
|
702
|
+
}
|
|
703
|
+
skills.entries[slug] = { enabled: true };
|
|
704
|
+
fsSync.writeFileSync(openclawConfigPath, JSON.stringify(openclawConfig, null, 2), "utf-8");
|
|
705
|
+
} catch (err) {
|
|
706
|
+
console.warn(`[SkillInstall] openclaw.json update failed: ${err.message}`);
|
|
707
|
+
}
|
|
687
708
|
let wrapperPath;
|
|
688
709
|
if (createWrapper) {
|
|
689
710
|
wrapperPath = path3.join(binDir, slug);
|
|
@@ -744,6 +765,18 @@ async function handleSkillUninstall(params, context, deps) {
|
|
|
744
765
|
if (skillExists) {
|
|
745
766
|
await fs2.rm(skillDir, { recursive: true, force: true });
|
|
746
767
|
}
|
|
768
|
+
const openclawConfigPath = path3.join(agentHome, ".openclaw", "openclaw.json");
|
|
769
|
+
try {
|
|
770
|
+
const raw = fsSync.readFileSync(openclawConfigPath, "utf-8");
|
|
771
|
+
const openclawConfig = JSON.parse(raw);
|
|
772
|
+
const skills = openclawConfig.skills;
|
|
773
|
+
const entries = skills?.entries;
|
|
774
|
+
if (entries?.[slug]) {
|
|
775
|
+
delete entries[slug];
|
|
776
|
+
fsSync.writeFileSync(openclawConfigPath, JSON.stringify(openclawConfig, null, 2), "utf-8");
|
|
777
|
+
}
|
|
778
|
+
} catch {
|
|
779
|
+
}
|
|
747
780
|
let wrapperRemoved = false;
|
|
748
781
|
if (removeWrapper) {
|
|
749
782
|
try {
|
package/main.js
CHANGED
|
@@ -597,6 +597,7 @@ async function handlePing(params, context, deps) {
|
|
|
597
597
|
|
|
598
598
|
// libs/shield-broker/src/handlers/skill-install.ts
|
|
599
599
|
import * as fs2 from "node:fs/promises";
|
|
600
|
+
import * as fsSync from "node:fs";
|
|
600
601
|
import * as path3 from "node:path";
|
|
601
602
|
import { execSync } from "node:child_process";
|
|
602
603
|
function isValidSlug(slug) {
|
|
@@ -686,6 +687,26 @@ async function handleSkillInstall(params, context, deps) {
|
|
|
686
687
|
} catch (err) {
|
|
687
688
|
console.warn(`[SkillInstall] chown failed (may be expected in dev): ${err.message}`);
|
|
688
689
|
}
|
|
690
|
+
const openclawConfigPath = path3.join(agentHome, ".openclaw", "openclaw.json");
|
|
691
|
+
try {
|
|
692
|
+
let openclawConfig = {};
|
|
693
|
+
try {
|
|
694
|
+
const raw = fsSync.readFileSync(openclawConfigPath, "utf-8");
|
|
695
|
+
openclawConfig = JSON.parse(raw);
|
|
696
|
+
} catch {
|
|
697
|
+
}
|
|
698
|
+
if (!openclawConfig.skills) {
|
|
699
|
+
openclawConfig.skills = {};
|
|
700
|
+
}
|
|
701
|
+
const skills = openclawConfig.skills;
|
|
702
|
+
if (!skills.entries) {
|
|
703
|
+
skills.entries = {};
|
|
704
|
+
}
|
|
705
|
+
skills.entries[slug] = { enabled: true };
|
|
706
|
+
fsSync.writeFileSync(openclawConfigPath, JSON.stringify(openclawConfig, null, 2), "utf-8");
|
|
707
|
+
} catch (err) {
|
|
708
|
+
console.warn(`[SkillInstall] openclaw.json update failed: ${err.message}`);
|
|
709
|
+
}
|
|
689
710
|
let wrapperPath;
|
|
690
711
|
if (createWrapper) {
|
|
691
712
|
wrapperPath = path3.join(binDir, slug);
|
|
@@ -746,6 +767,18 @@ async function handleSkillUninstall(params, context, deps) {
|
|
|
746
767
|
if (skillExists) {
|
|
747
768
|
await fs2.rm(skillDir, { recursive: true, force: true });
|
|
748
769
|
}
|
|
770
|
+
const openclawConfigPath = path3.join(agentHome, ".openclaw", "openclaw.json");
|
|
771
|
+
try {
|
|
772
|
+
const raw = fsSync.readFileSync(openclawConfigPath, "utf-8");
|
|
773
|
+
const openclawConfig = JSON.parse(raw);
|
|
774
|
+
const skills = openclawConfig.skills;
|
|
775
|
+
const entries = skills?.entries;
|
|
776
|
+
if (entries?.[slug]) {
|
|
777
|
+
delete entries[slug];
|
|
778
|
+
fsSync.writeFileSync(openclawConfigPath, JSON.stringify(openclawConfig, null, 2), "utf-8");
|
|
779
|
+
}
|
|
780
|
+
} catch {
|
|
781
|
+
}
|
|
749
782
|
let wrapperRemoved = false;
|
|
750
783
|
if (removeWrapper) {
|
|
751
784
|
try {
|
|
@@ -2077,14 +2110,29 @@ function ensureDirectories(config) {
|
|
|
2077
2110
|
}
|
|
2078
2111
|
}
|
|
2079
2112
|
async function main() {
|
|
2080
|
-
console.log(
|
|
2113
|
+
console.log(`AgenShield Broker starting at ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
2114
|
+
console.log(`PID: ${process.pid}, UID: ${process.getuid?.()}, GID: ${process.getgid?.()}`);
|
|
2115
|
+
console.log(`Node: ${process.version}, Platform: ${process.platform}`);
|
|
2081
2116
|
console.log("========================");
|
|
2082
|
-
|
|
2117
|
+
let config;
|
|
2118
|
+
try {
|
|
2119
|
+
config = loadConfig();
|
|
2120
|
+
} catch (err) {
|
|
2121
|
+
console.error("FATAL: Failed to load configuration:", err);
|
|
2122
|
+
process.exit(1);
|
|
2123
|
+
}
|
|
2124
|
+
console.log(`Config: ${config.configPath}`);
|
|
2083
2125
|
console.log(`Socket: ${config.socketPath}`);
|
|
2126
|
+
console.log(`Socket owner: ${config.socketOwner}, group: ${config.socketGroup}`);
|
|
2084
2127
|
console.log(`HTTP Fallback: ${config.httpEnabled ? `${config.httpHost}:${config.httpPort}` : "disabled"}`);
|
|
2085
2128
|
console.log(`Policies: ${config.policiesPath}`);
|
|
2086
2129
|
console.log(`Log Level: ${config.logLevel}`);
|
|
2087
|
-
|
|
2130
|
+
try {
|
|
2131
|
+
ensureDirectories(config);
|
|
2132
|
+
} catch (err) {
|
|
2133
|
+
console.error("FATAL: Failed to ensure directories:", err);
|
|
2134
|
+
process.exit(1);
|
|
2135
|
+
}
|
|
2088
2136
|
const auditLogger = new AuditLogger({
|
|
2089
2137
|
logPath: config.auditLogPath,
|
|
2090
2138
|
logLevel: config.logLevel
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenshield/broker",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AgenShield broker daemon with Unix socket and HTTP fallback",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@agenshield/ipc": "0.4.
|
|
27
|
+
"@agenshield/ipc": "0.4.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^24.0.0",
|