fastgrc-openclaw 1.0.25 → 1.0.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/bin.js +32 -18
- package/dist/bin.mjs +32 -18
- package/dist/index.js +2 -1
- package/dist/index.mjs +2 -1
- package/dist/plugin.js +2 -1
- package/dist/plugin.mjs +2 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -24,13 +24,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/bin.ts
|
|
27
|
+
var fs2 = __toESM(require("fs"));
|
|
28
|
+
var os2 = __toESM(require("os"));
|
|
29
|
+
var path2 = __toESM(require("path"));
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
27
32
|
var fs = __toESM(require("fs"));
|
|
28
33
|
var os = __toESM(require("os"));
|
|
29
34
|
var path = __toESM(require("path"));
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
35
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
33
36
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
37
|
+
var BUNDLED_API_KEY = "fgrc_k1_8b8cd6c4df4685cd1bae986bb992c7a9f188fc6e";
|
|
38
|
+
function resolveApiKey(explicit) {
|
|
39
|
+
if (explicit) return explicit;
|
|
40
|
+
if (process.env.FASTGRC_API_KEY) return process.env.FASTGRC_API_KEY;
|
|
41
|
+
try {
|
|
42
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), ".fastgrc.json"), "utf8"));
|
|
43
|
+
if (cfg.apiKey) return cfg.apiKey;
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
return BUNDLED_API_KEY || void 0;
|
|
47
|
+
}
|
|
34
48
|
async function evaluate(payload) {
|
|
35
49
|
const {
|
|
36
50
|
toolName,
|
|
@@ -80,20 +94,20 @@ args: ${JSON.stringify(args)}`;
|
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
// src/bin.ts
|
|
83
|
-
var CONFIG_PATH =
|
|
97
|
+
var CONFIG_PATH = path2.join(os2.homedir(), ".fastgrc.json");
|
|
84
98
|
function readConfig() {
|
|
85
99
|
try {
|
|
86
|
-
return JSON.parse(
|
|
100
|
+
return JSON.parse(fs2.readFileSync(CONFIG_PATH, "utf8"));
|
|
87
101
|
} catch {
|
|
88
102
|
return {};
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
105
|
function writeConfig(data) {
|
|
92
|
-
|
|
106
|
+
fs2.writeFileSync(CONFIG_PATH, JSON.stringify(data, null, 2), { mode: 384 });
|
|
93
107
|
}
|
|
94
108
|
function computeHandler() {
|
|
95
109
|
const binPath = process.argv[1];
|
|
96
|
-
const homeDir =
|
|
110
|
+
const homeDir = os2.homedir();
|
|
97
111
|
return { binPath, homeDir, handlerStr: `HOME=${homeDir} node ${binPath}` };
|
|
98
112
|
}
|
|
99
113
|
function printTestSnippet(handlerStr) {
|
|
@@ -107,7 +121,7 @@ Test it directly (bypasses OpenClaw):
|
|
|
107
121
|
);
|
|
108
122
|
}
|
|
109
123
|
function doInstallHook(targetDir) {
|
|
110
|
-
const hookMdPath =
|
|
124
|
+
const hookMdPath = path2.join(targetDir, "HOOK.md");
|
|
111
125
|
const { handlerStr } = computeHandler();
|
|
112
126
|
const HOOK_ENTRY = ` - matcher: PreToolUse
|
|
113
127
|
handler: "${handlerStr}"
|
|
@@ -117,8 +131,8 @@ function doInstallHook(targetDir) {
|
|
|
117
131
|
if (!hasKey) {
|
|
118
132
|
process.stdout.write("\u26A0 No API key set yet. Run: fastgrc-hook set-key fgrc_k1_your_key\n\n");
|
|
119
133
|
}
|
|
120
|
-
if (!
|
|
121
|
-
|
|
134
|
+
if (!fs2.existsSync(hookMdPath)) {
|
|
135
|
+
fs2.writeFileSync(hookMdPath, HOOK_BLOCK, "utf8");
|
|
122
136
|
process.stdout.write(`\u2713 Created ${hookMdPath}
|
|
123
137
|
Handler: ${handlerStr}
|
|
124
138
|
|
|
@@ -127,7 +141,7 @@ Restart OpenClaw \u2014 FastGRC will evaluate every tool call.
|
|
|
127
141
|
printTestSnippet(handlerStr);
|
|
128
142
|
return;
|
|
129
143
|
}
|
|
130
|
-
const existing =
|
|
144
|
+
const existing = fs2.readFileSync(hookMdPath, "utf8");
|
|
131
145
|
if (existing.includes(handlerStr)) {
|
|
132
146
|
process.stdout.write(`\u2713 FastGRC hook already up to date in ${hookMdPath}
|
|
133
147
|
Handler: ${handlerStr}
|
|
@@ -140,7 +154,7 @@ Restart OpenClaw \u2014 FastGRC will evaluate every tool call.
|
|
|
140
154
|
/handler:\s*"[^"]*(?:fastgrc-hook|fastgrc-openclaw)[^"]*"/,
|
|
141
155
|
`handler: "${handlerStr}"`
|
|
142
156
|
);
|
|
143
|
-
|
|
157
|
+
fs2.writeFileSync(hookMdPath, patched, "utf8");
|
|
144
158
|
process.stdout.write(`\u2713 Updated handler in ${hookMdPath} \u2014 now uses absolute path.
|
|
145
159
|
Handler: ${handlerStr}
|
|
146
160
|
|
|
@@ -159,7 +173,7 @@ ${HOOK_ENTRY}`;
|
|
|
159
173
|
} else {
|
|
160
174
|
updated = HOOK_BLOCK + "\n" + existing;
|
|
161
175
|
}
|
|
162
|
-
|
|
176
|
+
fs2.writeFileSync(hookMdPath, updated, "utf8");
|
|
163
177
|
process.stdout.write(`\u2713 Updated ${hookMdPath} \u2014 FastGRC hook added.
|
|
164
178
|
Handler: ${handlerStr}
|
|
165
179
|
|
|
@@ -168,12 +182,12 @@ Restart OpenClaw to activate.
|
|
|
168
182
|
printTestSnippet(handlerStr);
|
|
169
183
|
}
|
|
170
184
|
function doUninstallHook(targetDir) {
|
|
171
|
-
const hookMdPath =
|
|
172
|
-
if (!
|
|
185
|
+
const hookMdPath = path2.join(targetDir, "HOOK.md");
|
|
186
|
+
if (!fs2.existsSync(hookMdPath)) {
|
|
173
187
|
process.stdout.write("No HOOK.md found \u2014 nothing to remove.\n");
|
|
174
188
|
return;
|
|
175
189
|
}
|
|
176
|
-
const existing =
|
|
190
|
+
const existing = fs2.readFileSync(hookMdPath, "utf8");
|
|
177
191
|
const patched = existing.replace(
|
|
178
192
|
/[ \t]*-[ \t]*matcher:[ \t]*PreToolUse\n[ \t]*handler:[ \t]*"[^"]*(?:fastgrc-hook|fastgrc-openclaw)[^"]*"\n?/,
|
|
179
193
|
""
|
|
@@ -181,7 +195,7 @@ function doUninstallHook(targetDir) {
|
|
|
181
195
|
if (patched === existing) {
|
|
182
196
|
process.stdout.write("FastGRC hook not found in HOOK.md \u2014 nothing to remove.\n");
|
|
183
197
|
} else {
|
|
184
|
-
|
|
198
|
+
fs2.writeFileSync(hookMdPath, patched, "utf8");
|
|
185
199
|
process.stdout.write(`\u2713 FastGRC hook removed from ${hookMdPath}
|
|
186
200
|
`);
|
|
187
201
|
}
|
|
@@ -310,7 +324,7 @@ if (cmd === "test") {
|
|
|
310
324
|
process.stdout.write(`Payload: ${payload}
|
|
311
325
|
|
|
312
326
|
`);
|
|
313
|
-
const apiKey =
|
|
327
|
+
const apiKey = resolveApiKey();
|
|
314
328
|
if (!apiKey) {
|
|
315
329
|
process.stderr.write("No API key configured. Run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
316
330
|
process.exit(1);
|
|
@@ -352,7 +366,7 @@ if (cmd === "test") {
|
|
|
352
366
|
}
|
|
353
367
|
if (cmd === "test" || cmd === "where" || cmd === "which-hook" || cmd === "setup" || cmd === "uninstall" || cmd === "install-hook" || cmd === "uninstall-hook") {
|
|
354
368
|
} else {
|
|
355
|
-
const apiKey =
|
|
369
|
+
const apiKey = resolveApiKey();
|
|
356
370
|
if (!apiKey) {
|
|
357
371
|
process.stderr.write("[fastgrc-hook] No API key configured \u2014 run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
358
372
|
process.exit(0);
|
package/dist/bin.mjs
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
|
+
import * as fs2 from "fs";
|
|
5
|
+
import * as os2 from "os";
|
|
6
|
+
import * as path2 from "path";
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
4
9
|
import * as fs from "fs";
|
|
5
10
|
import * as os from "os";
|
|
6
11
|
import * as path from "path";
|
|
7
|
-
|
|
8
|
-
// src/index.ts
|
|
9
12
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
10
13
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
14
|
+
var BUNDLED_API_KEY = "fgrc_k1_8b8cd6c4df4685cd1bae986bb992c7a9f188fc6e";
|
|
15
|
+
function resolveApiKey(explicit) {
|
|
16
|
+
if (explicit) return explicit;
|
|
17
|
+
if (process.env.FASTGRC_API_KEY) return process.env.FASTGRC_API_KEY;
|
|
18
|
+
try {
|
|
19
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), ".fastgrc.json"), "utf8"));
|
|
20
|
+
if (cfg.apiKey) return cfg.apiKey;
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
return BUNDLED_API_KEY || void 0;
|
|
24
|
+
}
|
|
11
25
|
async function evaluate(payload) {
|
|
12
26
|
const {
|
|
13
27
|
toolName,
|
|
@@ -57,20 +71,20 @@ args: ${JSON.stringify(args)}`;
|
|
|
57
71
|
}
|
|
58
72
|
|
|
59
73
|
// src/bin.ts
|
|
60
|
-
var CONFIG_PATH =
|
|
74
|
+
var CONFIG_PATH = path2.join(os2.homedir(), ".fastgrc.json");
|
|
61
75
|
function readConfig() {
|
|
62
76
|
try {
|
|
63
|
-
return JSON.parse(
|
|
77
|
+
return JSON.parse(fs2.readFileSync(CONFIG_PATH, "utf8"));
|
|
64
78
|
} catch {
|
|
65
79
|
return {};
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
function writeConfig(data) {
|
|
69
|
-
|
|
83
|
+
fs2.writeFileSync(CONFIG_PATH, JSON.stringify(data, null, 2), { mode: 384 });
|
|
70
84
|
}
|
|
71
85
|
function computeHandler() {
|
|
72
86
|
const binPath = process.argv[1];
|
|
73
|
-
const homeDir =
|
|
87
|
+
const homeDir = os2.homedir();
|
|
74
88
|
return { binPath, homeDir, handlerStr: `HOME=${homeDir} node ${binPath}` };
|
|
75
89
|
}
|
|
76
90
|
function printTestSnippet(handlerStr) {
|
|
@@ -84,7 +98,7 @@ Test it directly (bypasses OpenClaw):
|
|
|
84
98
|
);
|
|
85
99
|
}
|
|
86
100
|
function doInstallHook(targetDir) {
|
|
87
|
-
const hookMdPath =
|
|
101
|
+
const hookMdPath = path2.join(targetDir, "HOOK.md");
|
|
88
102
|
const { handlerStr } = computeHandler();
|
|
89
103
|
const HOOK_ENTRY = ` - matcher: PreToolUse
|
|
90
104
|
handler: "${handlerStr}"
|
|
@@ -94,8 +108,8 @@ function doInstallHook(targetDir) {
|
|
|
94
108
|
if (!hasKey) {
|
|
95
109
|
process.stdout.write("\u26A0 No API key set yet. Run: fastgrc-hook set-key fgrc_k1_your_key\n\n");
|
|
96
110
|
}
|
|
97
|
-
if (!
|
|
98
|
-
|
|
111
|
+
if (!fs2.existsSync(hookMdPath)) {
|
|
112
|
+
fs2.writeFileSync(hookMdPath, HOOK_BLOCK, "utf8");
|
|
99
113
|
process.stdout.write(`\u2713 Created ${hookMdPath}
|
|
100
114
|
Handler: ${handlerStr}
|
|
101
115
|
|
|
@@ -104,7 +118,7 @@ Restart OpenClaw \u2014 FastGRC will evaluate every tool call.
|
|
|
104
118
|
printTestSnippet(handlerStr);
|
|
105
119
|
return;
|
|
106
120
|
}
|
|
107
|
-
const existing =
|
|
121
|
+
const existing = fs2.readFileSync(hookMdPath, "utf8");
|
|
108
122
|
if (existing.includes(handlerStr)) {
|
|
109
123
|
process.stdout.write(`\u2713 FastGRC hook already up to date in ${hookMdPath}
|
|
110
124
|
Handler: ${handlerStr}
|
|
@@ -117,7 +131,7 @@ Restart OpenClaw \u2014 FastGRC will evaluate every tool call.
|
|
|
117
131
|
/handler:\s*"[^"]*(?:fastgrc-hook|fastgrc-openclaw)[^"]*"/,
|
|
118
132
|
`handler: "${handlerStr}"`
|
|
119
133
|
);
|
|
120
|
-
|
|
134
|
+
fs2.writeFileSync(hookMdPath, patched, "utf8");
|
|
121
135
|
process.stdout.write(`\u2713 Updated handler in ${hookMdPath} \u2014 now uses absolute path.
|
|
122
136
|
Handler: ${handlerStr}
|
|
123
137
|
|
|
@@ -136,7 +150,7 @@ ${HOOK_ENTRY}`;
|
|
|
136
150
|
} else {
|
|
137
151
|
updated = HOOK_BLOCK + "\n" + existing;
|
|
138
152
|
}
|
|
139
|
-
|
|
153
|
+
fs2.writeFileSync(hookMdPath, updated, "utf8");
|
|
140
154
|
process.stdout.write(`\u2713 Updated ${hookMdPath} \u2014 FastGRC hook added.
|
|
141
155
|
Handler: ${handlerStr}
|
|
142
156
|
|
|
@@ -145,12 +159,12 @@ Restart OpenClaw to activate.
|
|
|
145
159
|
printTestSnippet(handlerStr);
|
|
146
160
|
}
|
|
147
161
|
function doUninstallHook(targetDir) {
|
|
148
|
-
const hookMdPath =
|
|
149
|
-
if (!
|
|
162
|
+
const hookMdPath = path2.join(targetDir, "HOOK.md");
|
|
163
|
+
if (!fs2.existsSync(hookMdPath)) {
|
|
150
164
|
process.stdout.write("No HOOK.md found \u2014 nothing to remove.\n");
|
|
151
165
|
return;
|
|
152
166
|
}
|
|
153
|
-
const existing =
|
|
167
|
+
const existing = fs2.readFileSync(hookMdPath, "utf8");
|
|
154
168
|
const patched = existing.replace(
|
|
155
169
|
/[ \t]*-[ \t]*matcher:[ \t]*PreToolUse\n[ \t]*handler:[ \t]*"[^"]*(?:fastgrc-hook|fastgrc-openclaw)[^"]*"\n?/,
|
|
156
170
|
""
|
|
@@ -158,7 +172,7 @@ function doUninstallHook(targetDir) {
|
|
|
158
172
|
if (patched === existing) {
|
|
159
173
|
process.stdout.write("FastGRC hook not found in HOOK.md \u2014 nothing to remove.\n");
|
|
160
174
|
} else {
|
|
161
|
-
|
|
175
|
+
fs2.writeFileSync(hookMdPath, patched, "utf8");
|
|
162
176
|
process.stdout.write(`\u2713 FastGRC hook removed from ${hookMdPath}
|
|
163
177
|
`);
|
|
164
178
|
}
|
|
@@ -287,7 +301,7 @@ if (cmd === "test") {
|
|
|
287
301
|
process.stdout.write(`Payload: ${payload}
|
|
288
302
|
|
|
289
303
|
`);
|
|
290
|
-
const apiKey =
|
|
304
|
+
const apiKey = resolveApiKey();
|
|
291
305
|
if (!apiKey) {
|
|
292
306
|
process.stderr.write("No API key configured. Run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
293
307
|
process.exit(1);
|
|
@@ -329,7 +343,7 @@ if (cmd === "test") {
|
|
|
329
343
|
}
|
|
330
344
|
if (cmd === "test" || cmd === "where" || cmd === "which-hook" || cmd === "setup" || cmd === "uninstall" || cmd === "install-hook" || cmd === "uninstall-hook") {
|
|
331
345
|
} else {
|
|
332
|
-
const apiKey =
|
|
346
|
+
const apiKey = resolveApiKey();
|
|
333
347
|
if (!apiKey) {
|
|
334
348
|
process.stderr.write("[fastgrc-hook] No API key configured \u2014 run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
335
349
|
process.exit(0);
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,7 @@ var os = __toESM(require("os"));
|
|
|
43
43
|
var path = __toESM(require("path"));
|
|
44
44
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
45
45
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
46
|
+
var BUNDLED_API_KEY = "fgrc_k1_8b8cd6c4df4685cd1bae986bb992c7a9f188fc6e";
|
|
46
47
|
function resolveApiKey(explicit) {
|
|
47
48
|
if (explicit) return explicit;
|
|
48
49
|
if (process.env.FASTGRC_API_KEY) return process.env.FASTGRC_API_KEY;
|
|
@@ -51,7 +52,7 @@ function resolveApiKey(explicit) {
|
|
|
51
52
|
if (cfg.apiKey) return cfg.apiKey;
|
|
52
53
|
} catch {
|
|
53
54
|
}
|
|
54
|
-
return void 0;
|
|
55
|
+
return BUNDLED_API_KEY || void 0;
|
|
55
56
|
}
|
|
56
57
|
function resolveConfig(explicit) {
|
|
57
58
|
const apiKey = resolveApiKey(explicit?.apiKey);
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import * as os from "os";
|
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
6
6
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
7
|
+
var BUNDLED_API_KEY = "fgrc_k1_8b8cd6c4df4685cd1bae986bb992c7a9f188fc6e";
|
|
7
8
|
function resolveApiKey(explicit) {
|
|
8
9
|
if (explicit) return explicit;
|
|
9
10
|
if (process.env.FASTGRC_API_KEY) return process.env.FASTGRC_API_KEY;
|
|
@@ -12,7 +13,7 @@ function resolveApiKey(explicit) {
|
|
|
12
13
|
if (cfg.apiKey) return cfg.apiKey;
|
|
13
14
|
} catch {
|
|
14
15
|
}
|
|
15
|
-
return void 0;
|
|
16
|
+
return BUNDLED_API_KEY || void 0;
|
|
16
17
|
}
|
|
17
18
|
function resolveConfig(explicit) {
|
|
18
19
|
const apiKey = resolveApiKey(explicit?.apiKey);
|
package/dist/plugin.js
CHANGED
|
@@ -40,6 +40,7 @@ var os = __toESM(require("os"));
|
|
|
40
40
|
var path = __toESM(require("path"));
|
|
41
41
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
42
42
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
43
|
+
var BUNDLED_API_KEY = "fgrc_k1_8b8cd6c4df4685cd1bae986bb992c7a9f188fc6e";
|
|
43
44
|
function resolveApiKey(explicit) {
|
|
44
45
|
if (explicit) return explicit;
|
|
45
46
|
if (process.env.FASTGRC_API_KEY) return process.env.FASTGRC_API_KEY;
|
|
@@ -48,7 +49,7 @@ function resolveApiKey(explicit) {
|
|
|
48
49
|
if (cfg.apiKey) return cfg.apiKey;
|
|
49
50
|
} catch {
|
|
50
51
|
}
|
|
51
|
-
return void 0;
|
|
52
|
+
return BUNDLED_API_KEY || void 0;
|
|
52
53
|
}
|
|
53
54
|
function resolveConfig(explicit) {
|
|
54
55
|
const apiKey = resolveApiKey(explicit?.apiKey);
|
package/dist/plugin.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import * as os from "os";
|
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
6
6
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
7
|
+
var BUNDLED_API_KEY = "fgrc_k1_8b8cd6c4df4685cd1bae986bb992c7a9f188fc6e";
|
|
7
8
|
function resolveApiKey(explicit) {
|
|
8
9
|
if (explicit) return explicit;
|
|
9
10
|
if (process.env.FASTGRC_API_KEY) return process.env.FASTGRC_API_KEY;
|
|
@@ -12,7 +13,7 @@ function resolveApiKey(explicit) {
|
|
|
12
13
|
if (cfg.apiKey) return cfg.apiKey;
|
|
13
14
|
} catch {
|
|
14
15
|
}
|
|
15
|
-
return void 0;
|
|
16
|
+
return BUNDLED_API_KEY || void 0;
|
|
16
17
|
}
|
|
17
18
|
function resolveConfig(explicit) {
|
|
18
19
|
const apiKey = resolveApiKey(explicit?.apiKey);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastgrc-openclaw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
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",
|