fastgrc-openclaw 1.0.17 → 1.0.18
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/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +16 -2
- package/dist/index.mjs +14 -1
- package/dist/plugin.js +18 -1
- package/dist/plugin.mjs +18 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
declare function resolveApiKey(explicit?: string): string | undefined;
|
|
2
|
+
declare function resolveConfig(explicit?: {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
policyId?: string;
|
|
5
|
+
}): {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
policyId?: string;
|
|
8
|
+
};
|
|
2
9
|
interface FastGRCPluginOptions {
|
|
3
10
|
/**
|
|
4
11
|
* Your FastGRC API key (fgrc_k1_...).
|
|
@@ -76,4 +83,4 @@ declare function evaluate(payload: {
|
|
|
76
83
|
}): Promise<EvaluateResponse | null>;
|
|
77
84
|
declare function FastGRCPlugin(options: FastGRCPluginOptions): OpenClawPlugin;
|
|
78
85
|
|
|
79
|
-
export { FastGRCApprovalRequiredError, FastGRCBlockedError, FastGRCPlugin, type FastGRCPluginOptions, evaluate, resolveApiKey };
|
|
86
|
+
export { FastGRCApprovalRequiredError, FastGRCBlockedError, FastGRCPlugin, type FastGRCPluginOptions, evaluate, resolveApiKey, resolveConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
declare function resolveApiKey(explicit?: string): string | undefined;
|
|
2
|
+
declare function resolveConfig(explicit?: {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
policyId?: string;
|
|
5
|
+
}): {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
policyId?: string;
|
|
8
|
+
};
|
|
2
9
|
interface FastGRCPluginOptions {
|
|
3
10
|
/**
|
|
4
11
|
* Your FastGRC API key (fgrc_k1_...).
|
|
@@ -76,4 +83,4 @@ declare function evaluate(payload: {
|
|
|
76
83
|
}): Promise<EvaluateResponse | null>;
|
|
77
84
|
declare function FastGRCPlugin(options: FastGRCPluginOptions): OpenClawPlugin;
|
|
78
85
|
|
|
79
|
-
export { FastGRCApprovalRequiredError, FastGRCBlockedError, FastGRCPlugin, type FastGRCPluginOptions, evaluate, resolveApiKey };
|
|
86
|
+
export { FastGRCApprovalRequiredError, FastGRCBlockedError, FastGRCPlugin, type FastGRCPluginOptions, evaluate, resolveApiKey, resolveConfig };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,8 @@ __export(index_exports, {
|
|
|
34
34
|
FastGRCBlockedError: () => FastGRCBlockedError,
|
|
35
35
|
FastGRCPlugin: () => FastGRCPlugin,
|
|
36
36
|
evaluate: () => evaluate,
|
|
37
|
-
resolveApiKey: () => resolveApiKey
|
|
37
|
+
resolveApiKey: () => resolveApiKey,
|
|
38
|
+
resolveConfig: () => resolveConfig
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(index_exports);
|
|
40
41
|
var fs = __toESM(require("fs"));
|
|
@@ -52,6 +53,18 @@ function resolveApiKey(explicit) {
|
|
|
52
53
|
}
|
|
53
54
|
return void 0;
|
|
54
55
|
}
|
|
56
|
+
function resolveConfig(explicit) {
|
|
57
|
+
const apiKey = resolveApiKey(explicit?.apiKey);
|
|
58
|
+
let policyId = explicit?.policyId;
|
|
59
|
+
if (!policyId) {
|
|
60
|
+
try {
|
|
61
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), ".fastgrc.json"), "utf8"));
|
|
62
|
+
if (cfg.policyId) policyId = cfg.policyId;
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { apiKey, policyId };
|
|
67
|
+
}
|
|
55
68
|
var FastGRCBlockedError = class extends Error {
|
|
56
69
|
constructor(matchedRule, reasoning, policyId) {
|
|
57
70
|
super(
|
|
@@ -179,6 +192,7 @@ function FastGRCPlugin(options) {
|
|
|
179
192
|
FastGRCBlockedError,
|
|
180
193
|
FastGRCPlugin,
|
|
181
194
|
evaluate,
|
|
182
|
-
resolveApiKey
|
|
195
|
+
resolveApiKey,
|
|
196
|
+
resolveConfig
|
|
183
197
|
});
|
|
184
198
|
module.exports = module.exports.default ?? module.exports;
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,18 @@ function resolveApiKey(explicit) {
|
|
|
14
14
|
}
|
|
15
15
|
return void 0;
|
|
16
16
|
}
|
|
17
|
+
function resolveConfig(explicit) {
|
|
18
|
+
const apiKey = resolveApiKey(explicit?.apiKey);
|
|
19
|
+
let policyId = explicit?.policyId;
|
|
20
|
+
if (!policyId) {
|
|
21
|
+
try {
|
|
22
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), ".fastgrc.json"), "utf8"));
|
|
23
|
+
if (cfg.policyId) policyId = cfg.policyId;
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { apiKey, policyId };
|
|
28
|
+
}
|
|
17
29
|
var FastGRCBlockedError = class extends Error {
|
|
18
30
|
constructor(matchedRule, reasoning, policyId) {
|
|
19
31
|
super(
|
|
@@ -140,5 +152,6 @@ export {
|
|
|
140
152
|
FastGRCBlockedError,
|
|
141
153
|
FastGRCPlugin,
|
|
142
154
|
evaluate,
|
|
143
|
-
resolveApiKey
|
|
155
|
+
resolveApiKey,
|
|
156
|
+
resolveConfig
|
|
144
157
|
};
|
package/dist/plugin.js
CHANGED
|
@@ -50,6 +50,18 @@ function resolveApiKey(explicit) {
|
|
|
50
50
|
}
|
|
51
51
|
return void 0;
|
|
52
52
|
}
|
|
53
|
+
function resolveConfig(explicit) {
|
|
54
|
+
const apiKey = resolveApiKey(explicit?.apiKey);
|
|
55
|
+
let policyId = explicit?.policyId;
|
|
56
|
+
if (!policyId) {
|
|
57
|
+
try {
|
|
58
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), ".fastgrc.json"), "utf8"));
|
|
59
|
+
if (cfg.policyId) policyId = cfg.policyId;
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { apiKey, policyId };
|
|
64
|
+
}
|
|
53
65
|
async function evaluate(payload) {
|
|
54
66
|
const {
|
|
55
67
|
toolName,
|
|
@@ -108,14 +120,18 @@ var pluginEntry = {
|
|
|
108
120
|
description: "Evaluate every tool call against your FastGRC compliance policy before it executes. Blocks violations, flags drift, builds an audit trail.",
|
|
109
121
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
122
|
register(api) {
|
|
111
|
-
const apiKey =
|
|
123
|
+
const { apiKey, policyId } = resolveConfig();
|
|
112
124
|
if (!apiKey) {
|
|
113
125
|
console.warn(
|
|
114
126
|
"[fastgrc] No API key found \u2014 all tool calls will proceed unchecked.\n\n Run once to connect:\n fastgrc-hook set-key fgrc_k1_your_key_here\n\n Get a key at: https://app.fastgrc.ai/connect\n Manage keys at: https://app.fastgrc.ai/dashboard/settings"
|
|
115
127
|
);
|
|
116
128
|
return;
|
|
117
129
|
}
|
|
130
|
+
process.stderr.write(`[fastgrc] register called \u2014 policyId: ${policyId ?? "none"}
|
|
131
|
+
`);
|
|
118
132
|
api.on("before_tool_call", async (event, ctx) => {
|
|
133
|
+
process.stderr.write(`[fastgrc] before_tool_call fired \u2014 tool: ${event.toolName}
|
|
134
|
+
`);
|
|
119
135
|
const result = await evaluate({
|
|
120
136
|
toolName: event.toolName,
|
|
121
137
|
args: event.params,
|
|
@@ -123,6 +139,7 @@ var pluginEntry = {
|
|
|
123
139
|
agentType: void 0,
|
|
124
140
|
agentName: void 0,
|
|
125
141
|
apiKey,
|
|
142
|
+
policyId,
|
|
126
143
|
baseUrl: DEFAULT_BASE_URL2,
|
|
127
144
|
timeoutMs: DEFAULT_TIMEOUT_MS2
|
|
128
145
|
});
|
package/dist/plugin.mjs
CHANGED
|
@@ -14,6 +14,18 @@ function resolveApiKey(explicit) {
|
|
|
14
14
|
}
|
|
15
15
|
return void 0;
|
|
16
16
|
}
|
|
17
|
+
function resolveConfig(explicit) {
|
|
18
|
+
const apiKey = resolveApiKey(explicit?.apiKey);
|
|
19
|
+
let policyId = explicit?.policyId;
|
|
20
|
+
if (!policyId) {
|
|
21
|
+
try {
|
|
22
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), ".fastgrc.json"), "utf8"));
|
|
23
|
+
if (cfg.policyId) policyId = cfg.policyId;
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { apiKey, policyId };
|
|
28
|
+
}
|
|
17
29
|
async function evaluate(payload) {
|
|
18
30
|
const {
|
|
19
31
|
toolName,
|
|
@@ -72,14 +84,18 @@ var pluginEntry = {
|
|
|
72
84
|
description: "Evaluate every tool call against your FastGRC compliance policy before it executes. Blocks violations, flags drift, builds an audit trail.",
|
|
73
85
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
86
|
register(api) {
|
|
75
|
-
const apiKey =
|
|
87
|
+
const { apiKey, policyId } = resolveConfig();
|
|
76
88
|
if (!apiKey) {
|
|
77
89
|
console.warn(
|
|
78
90
|
"[fastgrc] No API key found \u2014 all tool calls will proceed unchecked.\n\n Run once to connect:\n fastgrc-hook set-key fgrc_k1_your_key_here\n\n Get a key at: https://app.fastgrc.ai/connect\n Manage keys at: https://app.fastgrc.ai/dashboard/settings"
|
|
79
91
|
);
|
|
80
92
|
return;
|
|
81
93
|
}
|
|
94
|
+
process.stderr.write(`[fastgrc] register called \u2014 policyId: ${policyId ?? "none"}
|
|
95
|
+
`);
|
|
82
96
|
api.on("before_tool_call", async (event, ctx) => {
|
|
97
|
+
process.stderr.write(`[fastgrc] before_tool_call fired \u2014 tool: ${event.toolName}
|
|
98
|
+
`);
|
|
83
99
|
const result = await evaluate({
|
|
84
100
|
toolName: event.toolName,
|
|
85
101
|
args: event.params,
|
|
@@ -87,6 +103,7 @@ var pluginEntry = {
|
|
|
87
103
|
agentType: void 0,
|
|
88
104
|
agentName: void 0,
|
|
89
105
|
apiKey,
|
|
106
|
+
policyId,
|
|
90
107
|
baseUrl: DEFAULT_BASE_URL2,
|
|
91
108
|
timeoutMs: DEFAULT_TIMEOUT_MS2
|
|
92
109
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastgrc-openclaw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
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",
|