fastgrc-openclaw 1.0.25 → 1.0.27

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 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 = path.join(os.homedir(), ".fastgrc.json");
97
+ var CONFIG_PATH = path2.join(os2.homedir(), ".fastgrc.json");
84
98
  function readConfig() {
85
99
  try {
86
- return JSON.parse(fs.readFileSync(CONFIG_PATH, "utf8"));
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
- fs.writeFileSync(CONFIG_PATH, JSON.stringify(data, null, 2), { mode: 384 });
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 = os.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 = path.join(targetDir, "HOOK.md");
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 (!fs.existsSync(hookMdPath)) {
121
- fs.writeFileSync(hookMdPath, HOOK_BLOCK, "utf8");
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 = fs.readFileSync(hookMdPath, "utf8");
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
- fs.writeFileSync(hookMdPath, patched, "utf8");
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
- fs.writeFileSync(hookMdPath, updated, "utf8");
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 = path.join(targetDir, "HOOK.md");
172
- if (!fs.existsSync(hookMdPath)) {
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 = fs.readFileSync(hookMdPath, "utf8");
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
- fs.writeFileSync(hookMdPath, patched, "utf8");
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 = process.env.FASTGRC_API_KEY ?? readConfig().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 = process.env.FASTGRC_API_KEY ?? readConfig().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 = path.join(os.homedir(), ".fastgrc.json");
74
+ var CONFIG_PATH = path2.join(os2.homedir(), ".fastgrc.json");
61
75
  function readConfig() {
62
76
  try {
63
- return JSON.parse(fs.readFileSync(CONFIG_PATH, "utf8"));
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
- fs.writeFileSync(CONFIG_PATH, JSON.stringify(data, null, 2), { mode: 384 });
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 = os.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 = path.join(targetDir, "HOOK.md");
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 (!fs.existsSync(hookMdPath)) {
98
- fs.writeFileSync(hookMdPath, HOOK_BLOCK, "utf8");
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 = fs.readFileSync(hookMdPath, "utf8");
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
- fs.writeFileSync(hookMdPath, patched, "utf8");
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
- fs.writeFileSync(hookMdPath, updated, "utf8");
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 = path.join(targetDir, "HOOK.md");
149
- if (!fs.existsSync(hookMdPath)) {
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 = fs.readFileSync(hookMdPath, "utf8");
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
- fs.writeFileSync(hookMdPath, patched, "utf8");
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 = process.env.FASTGRC_API_KEY ?? readConfig().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 = process.env.FASTGRC_API_KEY ?? readConfig().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);
@@ -126,7 +127,18 @@ var pluginEntry = {
126
127
  );
127
128
  return;
128
129
  }
130
+ console.log("[fastgrc] Plugin registered \u2014 before_tool_call hook active");
131
+ const _origOn = api.on.bind(api);
132
+ api.on = (event, handler) => {
133
+ _origOn(event, handler);
134
+ };
135
+ if (typeof api.onAny === "function") {
136
+ api.onAny((event, ...args) => {
137
+ console.log(`[fastgrc:event] ${event}`, JSON.stringify(args[0])?.slice(0, 120));
138
+ });
139
+ }
129
140
  api.on("before_tool_call", async (event, ctx) => {
141
+ console.log(`[fastgrc] before_tool_call fired: ${event.toolName}`);
130
142
  const result = await evaluate({
131
143
  toolName: event.toolName,
132
144
  args: event.params,
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);
@@ -90,7 +91,18 @@ var pluginEntry = {
90
91
  );
91
92
  return;
92
93
  }
94
+ console.log("[fastgrc] Plugin registered \u2014 before_tool_call hook active");
95
+ const _origOn = api.on.bind(api);
96
+ api.on = (event, handler) => {
97
+ _origOn(event, handler);
98
+ };
99
+ if (typeof api.onAny === "function") {
100
+ api.onAny((event, ...args) => {
101
+ console.log(`[fastgrc:event] ${event}`, JSON.stringify(args[0])?.slice(0, 120));
102
+ });
103
+ }
93
104
  api.on("before_tool_call", async (event, ctx) => {
105
+ console.log(`[fastgrc] before_tool_call fired: ${event.toolName}`);
94
106
  const result = await evaluate({
95
107
  toolName: event.toolName,
96
108
  args: event.params,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastgrc-openclaw",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
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",