fastgrc-openclaw 1.0.4 → 1.0.5
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 +69 -2
- package/dist/bin.mjs +47 -2
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +28 -4
- package/dist/index.mjs +18 -4
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/bin.ts
|
|
27
|
+
var fs = __toESM(require("fs"));
|
|
28
|
+
var os = __toESM(require("os"));
|
|
29
|
+
var path = __toESM(require("path"));
|
|
3
30
|
|
|
4
31
|
// src/index.ts
|
|
5
32
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
@@ -53,9 +80,49 @@ args: ${JSON.stringify(args)}`;
|
|
|
53
80
|
}
|
|
54
81
|
|
|
55
82
|
// src/bin.ts
|
|
56
|
-
var
|
|
83
|
+
var CONFIG_PATH = path.join(os.homedir(), ".fastgrc.json");
|
|
84
|
+
function readConfig() {
|
|
85
|
+
try {
|
|
86
|
+
return JSON.parse(fs.readFileSync(CONFIG_PATH, "utf8"));
|
|
87
|
+
} catch {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function writeConfig(data) {
|
|
92
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(data, null, 2), { mode: 384 });
|
|
93
|
+
}
|
|
94
|
+
var [, , cmd, arg] = process.argv;
|
|
95
|
+
if (cmd === "set-key") {
|
|
96
|
+
if (!arg) {
|
|
97
|
+
process.stderr.write("Usage: fastgrc-hook set-key fgrc_k1_...\n");
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
writeConfig({ ...readConfig(), apiKey: arg });
|
|
101
|
+
process.stdout.write(`\u2713 FastGRC API key saved to ${CONFIG_PATH}
|
|
102
|
+
`);
|
|
103
|
+
process.stdout.write(' Run "fastgrc-hook get-key" to verify.\n');
|
|
104
|
+
process.exit(0);
|
|
105
|
+
}
|
|
106
|
+
if (cmd === "get-key") {
|
|
107
|
+
const key = readConfig().apiKey;
|
|
108
|
+
if (!key) {
|
|
109
|
+
process.stdout.write("No key stored. Run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
110
|
+
} else {
|
|
111
|
+
process.stdout.write(`${key.slice(0, 12)}${"*".repeat(Math.max(0, key.length - 12))}
|
|
112
|
+
`);
|
|
113
|
+
}
|
|
114
|
+
process.exit(0);
|
|
115
|
+
}
|
|
116
|
+
if (cmd === "unset-key") {
|
|
117
|
+
const cfg = readConfig();
|
|
118
|
+
delete cfg.apiKey;
|
|
119
|
+
writeConfig(cfg);
|
|
120
|
+
process.stdout.write("FastGRC API key removed.\n");
|
|
121
|
+
process.exit(0);
|
|
122
|
+
}
|
|
123
|
+
var apiKey = process.env.FASTGRC_API_KEY ?? readConfig().apiKey;
|
|
57
124
|
if (!apiKey) {
|
|
58
|
-
process.stderr.write("[fastgrc-hook]
|
|
125
|
+
process.stderr.write("[fastgrc-hook] No API key configured \u2014 run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
59
126
|
process.exit(0);
|
|
60
127
|
}
|
|
61
128
|
var baseUrl = process.env.FASTGRC_BASE_URL ?? "https://app.fastgrc.ai";
|
package/dist/bin.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/bin.ts
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import * as os from "os";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
|
|
3
8
|
// src/index.ts
|
|
4
9
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
5
10
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
@@ -52,9 +57,49 @@ args: ${JSON.stringify(args)}`;
|
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
// src/bin.ts
|
|
55
|
-
var
|
|
60
|
+
var CONFIG_PATH = path.join(os.homedir(), ".fastgrc.json");
|
|
61
|
+
function readConfig() {
|
|
62
|
+
try {
|
|
63
|
+
return JSON.parse(fs.readFileSync(CONFIG_PATH, "utf8"));
|
|
64
|
+
} catch {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function writeConfig(data) {
|
|
69
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(data, null, 2), { mode: 384 });
|
|
70
|
+
}
|
|
71
|
+
var [, , cmd, arg] = process.argv;
|
|
72
|
+
if (cmd === "set-key") {
|
|
73
|
+
if (!arg) {
|
|
74
|
+
process.stderr.write("Usage: fastgrc-hook set-key fgrc_k1_...\n");
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
writeConfig({ ...readConfig(), apiKey: arg });
|
|
78
|
+
process.stdout.write(`\u2713 FastGRC API key saved to ${CONFIG_PATH}
|
|
79
|
+
`);
|
|
80
|
+
process.stdout.write(' Run "fastgrc-hook get-key" to verify.\n');
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}
|
|
83
|
+
if (cmd === "get-key") {
|
|
84
|
+
const key = readConfig().apiKey;
|
|
85
|
+
if (!key) {
|
|
86
|
+
process.stdout.write("No key stored. Run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
87
|
+
} else {
|
|
88
|
+
process.stdout.write(`${key.slice(0, 12)}${"*".repeat(Math.max(0, key.length - 12))}
|
|
89
|
+
`);
|
|
90
|
+
}
|
|
91
|
+
process.exit(0);
|
|
92
|
+
}
|
|
93
|
+
if (cmd === "unset-key") {
|
|
94
|
+
const cfg = readConfig();
|
|
95
|
+
delete cfg.apiKey;
|
|
96
|
+
writeConfig(cfg);
|
|
97
|
+
process.stdout.write("FastGRC API key removed.\n");
|
|
98
|
+
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
var apiKey = process.env.FASTGRC_API_KEY ?? readConfig().apiKey;
|
|
56
101
|
if (!apiKey) {
|
|
57
|
-
process.stderr.write("[fastgrc-hook]
|
|
102
|
+
process.stderr.write("[fastgrc-hook] No API key configured \u2014 run: fastgrc-hook set-key fgrc_k1_...\n");
|
|
58
103
|
process.exit(0);
|
|
59
104
|
}
|
|
60
105
|
var baseUrl = process.env.FASTGRC_BASE_URL ?? "https://app.fastgrc.ai";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
interface FastGRCPluginOptions {
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Your FastGRC API key (fgrc_k1_...).
|
|
4
|
+
* Optional — falls back to FASTGRC_API_KEY env var, then ~/.fastgrc.json (set via `fastgrc-hook set-key`).
|
|
5
|
+
*/
|
|
6
|
+
apiKey?: string;
|
|
4
7
|
/** Specific policy ID to evaluate against. Omit to use the org-wide default. */
|
|
5
8
|
policyId?: string;
|
|
6
9
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
interface FastGRCPluginOptions {
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Your FastGRC API key (fgrc_k1_...).
|
|
4
|
+
* Optional — falls back to FASTGRC_API_KEY env var, then ~/.fastgrc.json (set via `fastgrc-hook set-key`).
|
|
5
|
+
*/
|
|
6
|
+
apiKey?: string;
|
|
4
7
|
/** Specific policy ID to evaluate against. Omit to use the org-wide default. */
|
|
5
8
|
policyId?: string;
|
|
6
9
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -26,8 +36,21 @@ __export(index_exports, {
|
|
|
26
36
|
evaluate: () => evaluate
|
|
27
37
|
});
|
|
28
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
var fs = __toESM(require("fs"));
|
|
40
|
+
var os = __toESM(require("os"));
|
|
41
|
+
var path = __toESM(require("path"));
|
|
29
42
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
30
43
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
44
|
+
function resolveApiKey(explicit) {
|
|
45
|
+
if (explicit) return explicit;
|
|
46
|
+
if (process.env.FASTGRC_API_KEY) return process.env.FASTGRC_API_KEY;
|
|
47
|
+
try {
|
|
48
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), ".fastgrc.json"), "utf8"));
|
|
49
|
+
if (cfg.apiKey) return cfg.apiKey;
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
31
54
|
var FastGRCBlockedError = class extends Error {
|
|
32
55
|
constructor(matchedRule, reasoning, policyId) {
|
|
33
56
|
super(
|
|
@@ -101,14 +124,14 @@ args: ${JSON.stringify(args)}`;
|
|
|
101
124
|
}
|
|
102
125
|
function FastGRCPlugin(options) {
|
|
103
126
|
const {
|
|
104
|
-
apiKey,
|
|
105
127
|
policyId,
|
|
106
128
|
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
107
129
|
baseUrl = DEFAULT_BASE_URL
|
|
108
130
|
} = options;
|
|
109
|
-
|
|
131
|
+
const resolvedKey = resolveApiKey(options.apiKey);
|
|
132
|
+
if (!resolvedKey) {
|
|
110
133
|
console.warn(
|
|
111
|
-
|
|
134
|
+
"[fastgrc] No API key found \u2014 all tool calls will proceed unchecked.\n\n Quick setup (install + set key in one command):\n npm install -g fastgrc-openclaw && fastgrc-hook set-key fgrc_k1_your_key\n\n Already installed? Just run:\n fastgrc-hook set-key fgrc_k1_your_key\n\n Get a key at: https://app.fastgrc.ai/connect\n Manage keys at: https://app.fastgrc.ai/dashboard/settings"
|
|
112
135
|
);
|
|
113
136
|
}
|
|
114
137
|
const dashboardUrl = `${baseUrl.replace(/\/$/, "")}/dashboard/agent-policies`;
|
|
@@ -116,13 +139,14 @@ function FastGRCPlugin(options) {
|
|
|
116
139
|
name: "fastgrc",
|
|
117
140
|
hooks: {
|
|
118
141
|
async before_tool_call(toolName, args, context) {
|
|
142
|
+
if (!resolvedKey) return { block: false };
|
|
119
143
|
const result = await evaluate({
|
|
120
144
|
toolName,
|
|
121
145
|
args,
|
|
122
146
|
agentId: context.id,
|
|
123
147
|
agentType: context.type,
|
|
124
148
|
agentName: context.name,
|
|
125
|
-
apiKey,
|
|
149
|
+
apiKey: resolvedKey,
|
|
126
150
|
policyId,
|
|
127
151
|
baseUrl,
|
|
128
152
|
timeoutMs
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import * as path from "path";
|
|
2
5
|
var DEFAULT_BASE_URL = "https://app.fastgrc.ai";
|
|
3
6
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
7
|
+
function resolveApiKey(explicit) {
|
|
8
|
+
if (explicit) return explicit;
|
|
9
|
+
if (process.env.FASTGRC_API_KEY) return process.env.FASTGRC_API_KEY;
|
|
10
|
+
try {
|
|
11
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), ".fastgrc.json"), "utf8"));
|
|
12
|
+
if (cfg.apiKey) return cfg.apiKey;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
4
17
|
var FastGRCBlockedError = class extends Error {
|
|
5
18
|
constructor(matchedRule, reasoning, policyId) {
|
|
6
19
|
super(
|
|
@@ -74,14 +87,14 @@ args: ${JSON.stringify(args)}`;
|
|
|
74
87
|
}
|
|
75
88
|
function FastGRCPlugin(options) {
|
|
76
89
|
const {
|
|
77
|
-
apiKey,
|
|
78
90
|
policyId,
|
|
79
91
|
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
80
92
|
baseUrl = DEFAULT_BASE_URL
|
|
81
93
|
} = options;
|
|
82
|
-
|
|
94
|
+
const resolvedKey = resolveApiKey(options.apiKey);
|
|
95
|
+
if (!resolvedKey) {
|
|
83
96
|
console.warn(
|
|
84
|
-
|
|
97
|
+
"[fastgrc] No API key found \u2014 all tool calls will proceed unchecked.\n\n Quick setup (install + set key in one command):\n npm install -g fastgrc-openclaw && fastgrc-hook set-key fgrc_k1_your_key\n\n Already installed? Just run:\n fastgrc-hook set-key fgrc_k1_your_key\n\n Get a key at: https://app.fastgrc.ai/connect\n Manage keys at: https://app.fastgrc.ai/dashboard/settings"
|
|
85
98
|
);
|
|
86
99
|
}
|
|
87
100
|
const dashboardUrl = `${baseUrl.replace(/\/$/, "")}/dashboard/agent-policies`;
|
|
@@ -89,13 +102,14 @@ function FastGRCPlugin(options) {
|
|
|
89
102
|
name: "fastgrc",
|
|
90
103
|
hooks: {
|
|
91
104
|
async before_tool_call(toolName, args, context) {
|
|
105
|
+
if (!resolvedKey) return { block: false };
|
|
92
106
|
const result = await evaluate({
|
|
93
107
|
toolName,
|
|
94
108
|
args,
|
|
95
109
|
agentId: context.id,
|
|
96
110
|
agentType: context.type,
|
|
97
111
|
agentName: context.name,
|
|
98
|
-
apiKey,
|
|
112
|
+
apiKey: resolvedKey,
|
|
99
113
|
policyId,
|
|
100
114
|
baseUrl,
|
|
101
115
|
timeoutMs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastgrc-openclaw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|