@intended-inc/claude-code-hook 0.1.0 → 0.1.1
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 +10 -4
- package/dist/bin.mjs +10 -4
- package/dist/index.js +10 -4
- package/dist/index.mjs +10 -4
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -7,9 +7,15 @@ var path = require('path');
|
|
|
7
7
|
|
|
8
8
|
// src/evaluate.ts
|
|
9
9
|
var AUTHORITY_STATUSES = /* @__PURE__ */ new Set([200, 202, 403]);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
var MAX_DESCRIBED_KEYS = 20;
|
|
11
|
+
var SAFE_KEY = /^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/;
|
|
12
|
+
function describeToolCall(name, args) {
|
|
13
|
+
const keys = Object.keys(args);
|
|
14
|
+
if (keys.length === 0) return `Call tool "${name}"`;
|
|
15
|
+
const named = keys.filter((k) => SAFE_KEY.test(k)).slice(0, MAX_DESCRIBED_KEYS);
|
|
16
|
+
const unnamed = keys.length - named.length;
|
|
17
|
+
const list = [...named, ...unnamed > 0 ? [`+${unnamed} more`] : []].join(", ");
|
|
18
|
+
return `Call tool "${name}" with args: ${list}`;
|
|
13
19
|
}
|
|
14
20
|
async function evaluateHookDecision(input) {
|
|
15
21
|
const { event, env } = input;
|
|
@@ -29,7 +35,7 @@ async function evaluateHookDecision(input) {
|
|
|
29
35
|
tenantId,
|
|
30
36
|
actor: { id: `claude-code:${toolName}`, type: "agent" },
|
|
31
37
|
source: { connector: "claude-code", harness: "claude-code", tool: toolName },
|
|
32
|
-
proposedAction:
|
|
38
|
+
proposedAction: describeToolCall(toolName, args),
|
|
33
39
|
arguments: args
|
|
34
40
|
})
|
|
35
41
|
});
|
package/dist/bin.mjs
CHANGED
|
@@ -5,9 +5,15 @@ import { join } from 'path';
|
|
|
5
5
|
|
|
6
6
|
// src/evaluate.ts
|
|
7
7
|
var AUTHORITY_STATUSES = /* @__PURE__ */ new Set([200, 202, 403]);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var MAX_DESCRIBED_KEYS = 20;
|
|
9
|
+
var SAFE_KEY = /^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/;
|
|
10
|
+
function describeToolCall(name, args) {
|
|
11
|
+
const keys = Object.keys(args);
|
|
12
|
+
if (keys.length === 0) return `Call tool "${name}"`;
|
|
13
|
+
const named = keys.filter((k) => SAFE_KEY.test(k)).slice(0, MAX_DESCRIBED_KEYS);
|
|
14
|
+
const unnamed = keys.length - named.length;
|
|
15
|
+
const list = [...named, ...unnamed > 0 ? [`+${unnamed} more`] : []].join(", ");
|
|
16
|
+
return `Call tool "${name}" with args: ${list}`;
|
|
11
17
|
}
|
|
12
18
|
async function evaluateHookDecision(input) {
|
|
13
19
|
const { event, env } = input;
|
|
@@ -27,7 +33,7 @@ async function evaluateHookDecision(input) {
|
|
|
27
33
|
tenantId,
|
|
28
34
|
actor: { id: `claude-code:${toolName}`, type: "agent" },
|
|
29
35
|
source: { connector: "claude-code", harness: "claude-code", tool: toolName },
|
|
30
|
-
proposedAction:
|
|
36
|
+
proposedAction: describeToolCall(toolName, args),
|
|
31
37
|
arguments: args
|
|
32
38
|
})
|
|
33
39
|
});
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
// src/evaluate.ts
|
|
4
4
|
var AUTHORITY_STATUSES = /* @__PURE__ */ new Set([200, 202, 403]);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
var MAX_DESCRIBED_KEYS = 20;
|
|
6
|
+
var SAFE_KEY = /^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/;
|
|
7
|
+
function describeToolCall(name, args) {
|
|
8
|
+
const keys = Object.keys(args);
|
|
9
|
+
if (keys.length === 0) return `Call tool "${name}"`;
|
|
10
|
+
const named = keys.filter((k) => SAFE_KEY.test(k)).slice(0, MAX_DESCRIBED_KEYS);
|
|
11
|
+
const unnamed = keys.length - named.length;
|
|
12
|
+
const list = [...named, ...unnamed > 0 ? [`+${unnamed} more`] : []].join(", ");
|
|
13
|
+
return `Call tool "${name}" with args: ${list}`;
|
|
8
14
|
}
|
|
9
15
|
async function evaluateHookDecision(input) {
|
|
10
16
|
const { event, env } = input;
|
|
@@ -24,7 +30,7 @@ async function evaluateHookDecision(input) {
|
|
|
24
30
|
tenantId,
|
|
25
31
|
actor: { id: `claude-code:${toolName}`, type: "agent" },
|
|
26
32
|
source: { connector: "claude-code", harness: "claude-code", tool: toolName },
|
|
27
|
-
proposedAction:
|
|
33
|
+
proposedAction: describeToolCall(toolName, args),
|
|
28
34
|
arguments: args
|
|
29
35
|
})
|
|
30
36
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// src/evaluate.ts
|
|
2
2
|
var AUTHORITY_STATUSES = /* @__PURE__ */ new Set([200, 202, 403]);
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var MAX_DESCRIBED_KEYS = 20;
|
|
4
|
+
var SAFE_KEY = /^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/;
|
|
5
|
+
function describeToolCall(name, args) {
|
|
6
|
+
const keys = Object.keys(args);
|
|
7
|
+
if (keys.length === 0) return `Call tool "${name}"`;
|
|
8
|
+
const named = keys.filter((k) => SAFE_KEY.test(k)).slice(0, MAX_DESCRIBED_KEYS);
|
|
9
|
+
const unnamed = keys.length - named.length;
|
|
10
|
+
const list = [...named, ...unnamed > 0 ? [`+${unnamed} more`] : []].join(", ");
|
|
11
|
+
return `Call tool "${name}" with args: ${list}`;
|
|
6
12
|
}
|
|
7
13
|
async function evaluateHookDecision(input) {
|
|
8
14
|
const { event, env } = input;
|
|
@@ -22,7 +28,7 @@ async function evaluateHookDecision(input) {
|
|
|
22
28
|
tenantId,
|
|
23
29
|
actor: { id: `claude-code:${toolName}`, type: "agent" },
|
|
24
30
|
source: { connector: "claude-code", harness: "claude-code", tool: toolName },
|
|
25
|
-
proposedAction:
|
|
31
|
+
proposedAction: describeToolCall(toolName, args),
|
|
26
32
|
arguments: args
|
|
27
33
|
})
|
|
28
34
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intended-inc/claude-code-hook",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Claude Code PreToolUse hook — govern every tool call through Intended's authority layer. Fail-open when unconfigured, fail-closed on DENY / unreachable / non-2xx. npx-invokable from .claude/settings.json.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"@types/node": "^22.0.0",
|
|
45
45
|
"tsup": "^8.5.0",
|
|
46
46
|
"typescript": "^5.5.0",
|
|
47
|
-
"vitest": "^
|
|
47
|
+
"vitest": "^5.0.5"
|
|
48
48
|
}
|
|
49
49
|
}
|