fastgrc-openclaw 1.0.6 → 1.0.8
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/bin.js +74 -1
- package/dist/bin.mjs +74 -1
- package/openclaw.plugin.json +6 -6
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -120,13 +120,86 @@ if (cmd === "unset-key") {
|
|
|
120
120
|
process.stdout.write("FastGRC API key removed.\n");
|
|
121
121
|
process.exit(0);
|
|
122
122
|
}
|
|
123
|
+
if (cmd === "set-policy") {
|
|
124
|
+
if (!arg) {
|
|
125
|
+
process.stderr.write("Usage: fastgrc-hook set-policy <policy-id>\n");
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
writeConfig({ ...readConfig(), policyId: arg });
|
|
129
|
+
process.stdout.write(`\u2713 FastGRC policy ID saved to ${CONFIG_PATH}
|
|
130
|
+
`);
|
|
131
|
+
process.stdout.write(' Run "fastgrc-hook get-policy" to verify.\n');
|
|
132
|
+
process.exit(0);
|
|
133
|
+
}
|
|
134
|
+
if (cmd === "get-policy") {
|
|
135
|
+
const id = readConfig().policyId;
|
|
136
|
+
if (!id) {
|
|
137
|
+
process.stdout.write("No policy ID stored \u2014 org-wide default will be used.\n");
|
|
138
|
+
process.stdout.write("Run: fastgrc-hook set-policy <policy-id>\n");
|
|
139
|
+
} else {
|
|
140
|
+
process.stdout.write(`${id}
|
|
141
|
+
`);
|
|
142
|
+
}
|
|
143
|
+
process.exit(0);
|
|
144
|
+
}
|
|
145
|
+
if (cmd === "unset-policy") {
|
|
146
|
+
const cfg = readConfig();
|
|
147
|
+
delete cfg.policyId;
|
|
148
|
+
writeConfig(cfg);
|
|
149
|
+
process.stdout.write("FastGRC policy ID removed \u2014 org-wide default will be used.\n");
|
|
150
|
+
process.exit(0);
|
|
151
|
+
}
|
|
152
|
+
if (cmd === "install-hook") {
|
|
153
|
+
const targetDir = arg || process.cwd();
|
|
154
|
+
const hookMdPath = path.join(targetDir, "HOOK.md");
|
|
155
|
+
const homeDir = os.homedir();
|
|
156
|
+
const handlerStr = `HOME=${homeDir} fastgrc-hook`;
|
|
157
|
+
const HOOK_ENTRY = ` - matcher: PreToolUse
|
|
158
|
+
handler: "${handlerStr}"
|
|
159
|
+
`;
|
|
160
|
+
const HOOK_BLOCK = "---\nname: FastGRC Policy Check\ndescription: Evaluate every tool call against your FastGRC compliance policy\nhooks:\n" + HOOK_ENTRY + "---\n";
|
|
161
|
+
const hasKey = !!(readConfig().apiKey || process.env.FASTGRC_API_KEY);
|
|
162
|
+
if (!hasKey) {
|
|
163
|
+
process.stdout.write("\u26A0 No API key set yet. Run: fastgrc-hook set-key fgrc_k1_your_key\n\n");
|
|
164
|
+
}
|
|
165
|
+
if (!fs.existsSync(hookMdPath)) {
|
|
166
|
+
fs.writeFileSync(hookMdPath, HOOK_BLOCK, "utf8");
|
|
167
|
+
process.stdout.write(`\u2713 Created ${hookMdPath}
|
|
168
|
+
|
|
169
|
+
Restart OpenClaw \u2014 FastGRC will evaluate every tool call.
|
|
170
|
+
`);
|
|
171
|
+
process.exit(0);
|
|
172
|
+
}
|
|
173
|
+
const existing = fs.readFileSync(hookMdPath, "utf8");
|
|
174
|
+
if (existing.includes("fastgrc-hook")) {
|
|
175
|
+
process.stdout.write(`\u2713 FastGRC hook already present in ${hookMdPath}
|
|
176
|
+
`);
|
|
177
|
+
process.exit(0);
|
|
178
|
+
}
|
|
179
|
+
const fmEnd = existing.indexOf("\n---", 3);
|
|
180
|
+
let updated;
|
|
181
|
+
if (fmEnd !== -1) {
|
|
182
|
+
const hasHooksKey = existing.lastIndexOf("hooks:", fmEnd) !== -1;
|
|
183
|
+
const insertText = hasHooksKey ? HOOK_ENTRY : `hooks:
|
|
184
|
+
${HOOK_ENTRY}`;
|
|
185
|
+
updated = existing.slice(0, fmEnd) + "\n" + insertText + existing.slice(fmEnd);
|
|
186
|
+
} else {
|
|
187
|
+
updated = HOOK_BLOCK + "\n" + existing;
|
|
188
|
+
}
|
|
189
|
+
fs.writeFileSync(hookMdPath, updated, "utf8");
|
|
190
|
+
process.stdout.write(`\u2713 Updated ${hookMdPath} \u2014 FastGRC hook added.
|
|
191
|
+
|
|
192
|
+
Restart OpenClaw to activate.
|
|
193
|
+
`);
|
|
194
|
+
process.exit(0);
|
|
195
|
+
}
|
|
123
196
|
var apiKey = process.env.FASTGRC_API_KEY ?? readConfig().apiKey;
|
|
124
197
|
if (!apiKey) {
|
|
125
198
|
process.stderr.write("[fastgrc-hook] No API key configured \u2014 run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
126
199
|
process.exit(0);
|
|
127
200
|
}
|
|
128
201
|
var baseUrl = process.env.FASTGRC_BASE_URL ?? "https://app.fastgrc.ai";
|
|
129
|
-
var policyId = process.env.FASTGRC_POLICY_ID;
|
|
202
|
+
var policyId = process.env.FASTGRC_POLICY_ID ?? readConfig().policyId;
|
|
130
203
|
async function main() {
|
|
131
204
|
const chunks = [];
|
|
132
205
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
package/dist/bin.mjs
CHANGED
|
@@ -97,13 +97,86 @@ if (cmd === "unset-key") {
|
|
|
97
97
|
process.stdout.write("FastGRC API key removed.\n");
|
|
98
98
|
process.exit(0);
|
|
99
99
|
}
|
|
100
|
+
if (cmd === "set-policy") {
|
|
101
|
+
if (!arg) {
|
|
102
|
+
process.stderr.write("Usage: fastgrc-hook set-policy <policy-id>\n");
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
writeConfig({ ...readConfig(), policyId: arg });
|
|
106
|
+
process.stdout.write(`\u2713 FastGRC policy ID saved to ${CONFIG_PATH}
|
|
107
|
+
`);
|
|
108
|
+
process.stdout.write(' Run "fastgrc-hook get-policy" to verify.\n');
|
|
109
|
+
process.exit(0);
|
|
110
|
+
}
|
|
111
|
+
if (cmd === "get-policy") {
|
|
112
|
+
const id = readConfig().policyId;
|
|
113
|
+
if (!id) {
|
|
114
|
+
process.stdout.write("No policy ID stored \u2014 org-wide default will be used.\n");
|
|
115
|
+
process.stdout.write("Run: fastgrc-hook set-policy <policy-id>\n");
|
|
116
|
+
} else {
|
|
117
|
+
process.stdout.write(`${id}
|
|
118
|
+
`);
|
|
119
|
+
}
|
|
120
|
+
process.exit(0);
|
|
121
|
+
}
|
|
122
|
+
if (cmd === "unset-policy") {
|
|
123
|
+
const cfg = readConfig();
|
|
124
|
+
delete cfg.policyId;
|
|
125
|
+
writeConfig(cfg);
|
|
126
|
+
process.stdout.write("FastGRC policy ID removed \u2014 org-wide default will be used.\n");
|
|
127
|
+
process.exit(0);
|
|
128
|
+
}
|
|
129
|
+
if (cmd === "install-hook") {
|
|
130
|
+
const targetDir = arg || process.cwd();
|
|
131
|
+
const hookMdPath = path.join(targetDir, "HOOK.md");
|
|
132
|
+
const homeDir = os.homedir();
|
|
133
|
+
const handlerStr = `HOME=${homeDir} fastgrc-hook`;
|
|
134
|
+
const HOOK_ENTRY = ` - matcher: PreToolUse
|
|
135
|
+
handler: "${handlerStr}"
|
|
136
|
+
`;
|
|
137
|
+
const HOOK_BLOCK = "---\nname: FastGRC Policy Check\ndescription: Evaluate every tool call against your FastGRC compliance policy\nhooks:\n" + HOOK_ENTRY + "---\n";
|
|
138
|
+
const hasKey = !!(readConfig().apiKey || process.env.FASTGRC_API_KEY);
|
|
139
|
+
if (!hasKey) {
|
|
140
|
+
process.stdout.write("\u26A0 No API key set yet. Run: fastgrc-hook set-key fgrc_k1_your_key\n\n");
|
|
141
|
+
}
|
|
142
|
+
if (!fs.existsSync(hookMdPath)) {
|
|
143
|
+
fs.writeFileSync(hookMdPath, HOOK_BLOCK, "utf8");
|
|
144
|
+
process.stdout.write(`\u2713 Created ${hookMdPath}
|
|
145
|
+
|
|
146
|
+
Restart OpenClaw \u2014 FastGRC will evaluate every tool call.
|
|
147
|
+
`);
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
|
150
|
+
const existing = fs.readFileSync(hookMdPath, "utf8");
|
|
151
|
+
if (existing.includes("fastgrc-hook")) {
|
|
152
|
+
process.stdout.write(`\u2713 FastGRC hook already present in ${hookMdPath}
|
|
153
|
+
`);
|
|
154
|
+
process.exit(0);
|
|
155
|
+
}
|
|
156
|
+
const fmEnd = existing.indexOf("\n---", 3);
|
|
157
|
+
let updated;
|
|
158
|
+
if (fmEnd !== -1) {
|
|
159
|
+
const hasHooksKey = existing.lastIndexOf("hooks:", fmEnd) !== -1;
|
|
160
|
+
const insertText = hasHooksKey ? HOOK_ENTRY : `hooks:
|
|
161
|
+
${HOOK_ENTRY}`;
|
|
162
|
+
updated = existing.slice(0, fmEnd) + "\n" + insertText + existing.slice(fmEnd);
|
|
163
|
+
} else {
|
|
164
|
+
updated = HOOK_BLOCK + "\n" + existing;
|
|
165
|
+
}
|
|
166
|
+
fs.writeFileSync(hookMdPath, updated, "utf8");
|
|
167
|
+
process.stdout.write(`\u2713 Updated ${hookMdPath} \u2014 FastGRC hook added.
|
|
168
|
+
|
|
169
|
+
Restart OpenClaw to activate.
|
|
170
|
+
`);
|
|
171
|
+
process.exit(0);
|
|
172
|
+
}
|
|
100
173
|
var apiKey = process.env.FASTGRC_API_KEY ?? readConfig().apiKey;
|
|
101
174
|
if (!apiKey) {
|
|
102
175
|
process.stderr.write("[fastgrc-hook] No API key configured \u2014 run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
103
176
|
process.exit(0);
|
|
104
177
|
}
|
|
105
178
|
var baseUrl = process.env.FASTGRC_BASE_URL ?? "https://app.fastgrc.ai";
|
|
106
|
-
var policyId = process.env.FASTGRC_POLICY_ID;
|
|
179
|
+
var policyId = process.env.FASTGRC_POLICY_ID ?? readConfig().policyId;
|
|
107
180
|
async function main() {
|
|
108
181
|
const chunks = [];
|
|
109
182
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "fastgrc",
|
|
3
|
-
"name": "FastGRC Policy Router",
|
|
4
|
-
"description": "Evaluate every tool call against your FastGRC compliance policy before it executes. Blocks violations, flags drift, builds an audit trail.",
|
|
5
|
-
"extensions": ["./dist/plugin.js"]
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "fastgrc",
|
|
3
|
+
"name": "FastGRC Policy Router",
|
|
4
|
+
"description": "Evaluate every tool call against your FastGRC compliance policy before it executes. Blocks violations, flags drift, builds an audit trail.",
|
|
5
|
+
"extensions": ["./dist/plugin.js"]
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastgrc-openclaw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "FastGRC agent compliance plugin for OpenClaw — evaluates every tool call against your policy before it executes",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|