@windyroad/risk-scorer 0.19.4-preview.1201 → 0.19.5-preview.1207
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.
|
@@ -5,6 +5,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameS
|
|
|
5
5
|
import { dirname, isAbsolute, join } from "node:path";
|
|
6
6
|
import { spawnSync } from "node:child_process";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { CLOSE_TOOLS, SPAWN_TOOLS, WAIT_TOOLS, response } from "./lib/codex-completion-input.mjs";
|
|
8
9
|
|
|
9
10
|
const hookDir = dirname(fileURLToPath(import.meta.url));
|
|
10
11
|
const riskAgentRoles = new Set([
|
|
@@ -16,26 +17,6 @@ const riskAgentRoles = new Set([
|
|
|
16
17
|
"wr-risk-scorer:inbound-report",
|
|
17
18
|
]);
|
|
18
19
|
|
|
19
|
-
function parsedResponse(value) {
|
|
20
|
-
if (Array.isArray(value)) {
|
|
21
|
-
const text = value
|
|
22
|
-
.filter((item) => item && typeof item === "object" && typeof item.text === "string")
|
|
23
|
-
.map((item) => item.text)
|
|
24
|
-
.join("\n");
|
|
25
|
-
return parsedResponse(text);
|
|
26
|
-
}
|
|
27
|
-
if (typeof value === "object" && value) return value;
|
|
28
|
-
try {
|
|
29
|
-
return parsedResponse(JSON.parse(value));
|
|
30
|
-
} catch {
|
|
31
|
-
return {};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function response(input) {
|
|
36
|
-
return parsedResponse(input.tool_response);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
20
|
function riskDir(sessionId) {
|
|
40
21
|
return join(process.env.TMPDIR || "/tmp", `claude-risk-${sessionId}`);
|
|
41
22
|
}
|
|
@@ -429,13 +410,13 @@ if (!/^[A-Za-z0-9-]+$/.test(input.session_id || "")) {
|
|
|
429
410
|
process.exit(0);
|
|
430
411
|
}
|
|
431
412
|
|
|
432
|
-
if (
|
|
413
|
+
if (SPAWN_TOOLS.has(input.tool_name)) {
|
|
433
414
|
rememberSpawn(input);
|
|
434
415
|
}
|
|
435
|
-
if (
|
|
416
|
+
if (CLOSE_TOOLS.has(input.tool_name)) {
|
|
436
417
|
markClose(input);
|
|
437
418
|
}
|
|
438
|
-
if (
|
|
419
|
+
if (WAIT_TOOLS.has(input.tool_name)) {
|
|
439
420
|
markWait(input);
|
|
440
421
|
}
|
|
441
422
|
if (input.hook_event_name === "SubagentStop") {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const SPAWN_TOOLS = new Set([
|
|
2
|
+
"collaboration.spawn_agent",
|
|
3
|
+
"collaborationspawn_agent",
|
|
4
|
+
"spawn_agent",
|
|
5
|
+
"multi_agent_v1__spawn_agent",
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
export const WAIT_TOOLS = new Set([
|
|
9
|
+
"collaboration.wait_agent",
|
|
10
|
+
"collaborationwait_agent",
|
|
11
|
+
"wait_agent",
|
|
12
|
+
"multi_agent_v1__wait_agent",
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
export const CLOSE_TOOLS = new Set([
|
|
16
|
+
"collaboration.interrupt_agent",
|
|
17
|
+
"collaborationinterrupt_agent",
|
|
18
|
+
"interrupt_agent",
|
|
19
|
+
"close_agent",
|
|
20
|
+
"multi_agent_v1__close_agent",
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
export function parsedResponse(value) {
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
const text = value
|
|
26
|
+
.filter((item) => item && typeof item === "object" && typeof item.text === "string")
|
|
27
|
+
.map((item) => item.text)
|
|
28
|
+
.join("\n");
|
|
29
|
+
return parsedResponse(text);
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === "object" && value) return value;
|
|
32
|
+
try {
|
|
33
|
+
return parsedResponse(JSON.parse(value));
|
|
34
|
+
} catch {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function response(input) {
|
|
40
|
+
return parsedResponse(input?.tool_response);
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windyroad/risk-scorer",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.5-preview.1207",
|
|
4
4
|
"description": "Pipeline risk scoring, commit/push gates, and secret leak detection",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepack": "node scripts/sync-codex-skills.mjs --pack",
|