@ory/claude-code 0.13.9 → 1.0.0
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/.claude-plugin/marketplace.json +2 -2
- package/README.md +71 -61
- package/dist/cli/main.js +46 -24
- package/dist/cli/setup.d.ts +39 -29
- package/dist/cli/setup.js +191 -180
- package/dist/handlers.d.ts +2 -7
- package/dist/handlers.js +157 -459
- package/dist/hook.js +40 -16
- package/package.json +9 -8
package/dist/hook.js
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
const argus_1 = require("@ory/argus");
|
|
12
12
|
const handlers_js_1 = require("./handlers.js");
|
|
13
|
+
const EVENT_FLUSH_TIMEOUT_MS = 750;
|
|
14
|
+
let client;
|
|
15
|
+
async function flushEvents() {
|
|
16
|
+
try {
|
|
17
|
+
await client?.flushEvents(EVENT_FLUSH_TIMEOUT_MS);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// The hook decision must not depend on activity delivery.
|
|
21
|
+
}
|
|
22
|
+
}
|
|
13
23
|
/**
|
|
14
24
|
* Read all of stdin as a string.
|
|
15
25
|
*
|
|
@@ -21,31 +31,44 @@ function readStdin() {
|
|
|
21
31
|
return new Promise((resolve, reject) => {
|
|
22
32
|
const chunks = [];
|
|
23
33
|
let resolved = false;
|
|
34
|
+
let idleTimer;
|
|
35
|
+
function cleanup() {
|
|
36
|
+
if (idleTimer)
|
|
37
|
+
clearTimeout(idleTimer);
|
|
38
|
+
process.stdin.off("data", onData);
|
|
39
|
+
process.stdin.off("end", done);
|
|
40
|
+
process.stdin.off("error", onError);
|
|
41
|
+
process.stdin.pause();
|
|
42
|
+
}
|
|
24
43
|
function done() {
|
|
25
44
|
if (!resolved) {
|
|
26
45
|
resolved = true;
|
|
46
|
+
cleanup();
|
|
27
47
|
resolve(Buffer.concat(chunks).toString("utf-8"));
|
|
28
48
|
}
|
|
29
49
|
}
|
|
30
|
-
|
|
50
|
+
function onData(chunk) {
|
|
31
51
|
chunks.push(chunk);
|
|
32
52
|
// Reset idle timer on every chunk. Once data stops arriving for 100 ms
|
|
33
53
|
// we assume the full payload has been delivered.
|
|
34
|
-
|
|
54
|
+
if (idleTimer)
|
|
55
|
+
clearTimeout(idleTimer);
|
|
35
56
|
idleTimer = setTimeout(done, 100);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
process.stdin.on("error", (err) => {
|
|
57
|
+
}
|
|
58
|
+
function onError(err) {
|
|
39
59
|
if (!resolved) {
|
|
40
60
|
resolved = true;
|
|
61
|
+
cleanup();
|
|
41
62
|
reject(err);
|
|
42
63
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
64
|
+
}
|
|
65
|
+
process.stdin.on("data", onData);
|
|
66
|
+
process.stdin.on("end", done);
|
|
67
|
+
process.stdin.on("error", onError);
|
|
45
68
|
});
|
|
46
69
|
}
|
|
47
70
|
async function main() {
|
|
48
|
-
|
|
71
|
+
client = argus_1.OryAgentClient.fromEnv("claude-code");
|
|
49
72
|
const raw = await readStdin();
|
|
50
73
|
let input;
|
|
51
74
|
try {
|
|
@@ -53,24 +76,25 @@ async function main() {
|
|
|
53
76
|
}
|
|
54
77
|
catch {
|
|
55
78
|
client.logger.error("hook.stdin.parse_failed", { raw: raw.slice(0, 200) });
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
process.exitCode = 0; // Don't block on parse errors
|
|
80
|
+
return;
|
|
58
81
|
}
|
|
59
82
|
const output = await (0, handlers_js_1.handleHookEvent)(input, client);
|
|
60
83
|
if (output.decision === "block") {
|
|
61
84
|
process.stdout.write(JSON.stringify(output));
|
|
62
|
-
await
|
|
63
|
-
process.
|
|
85
|
+
await flushEvents();
|
|
86
|
+
process.exitCode = 2;
|
|
87
|
+
return;
|
|
64
88
|
}
|
|
65
89
|
if (output.hookSpecificOutput ||
|
|
66
90
|
output.updatedInput ||
|
|
67
91
|
output.decision === "approve") {
|
|
68
92
|
process.stdout.write(JSON.stringify(output));
|
|
69
93
|
}
|
|
70
|
-
await
|
|
71
|
-
process.exit(0);
|
|
94
|
+
await flushEvents();
|
|
72
95
|
}
|
|
73
|
-
main().catch((err) => {
|
|
96
|
+
main().catch(async (err) => {
|
|
74
97
|
process.stderr.write(`[ory-agent] fatal: ${err}\n`);
|
|
75
|
-
|
|
98
|
+
await flushEvents();
|
|
99
|
+
process.exitCode = 0; // Fail open
|
|
76
100
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ory/claude-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Ory plugin for Claude Code: scaffolding skills, a local Ory instance, and authentication, authorization, and audit for every tool call",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/ory/claude-plugins/tree/master/plugins/ory-agent-plugin",
|
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
"llm",
|
|
41
41
|
"mcp",
|
|
42
42
|
"mcp-server",
|
|
43
|
-
"
|
|
44
|
-
"distributed-tracing",
|
|
43
|
+
"activity-auditing",
|
|
45
44
|
"observability",
|
|
46
45
|
"kratos",
|
|
47
46
|
"keto",
|
|
@@ -52,6 +51,10 @@
|
|
|
52
51
|
"registry": "https://registry.npmjs.org/",
|
|
53
52
|
"provenance": true
|
|
54
53
|
},
|
|
54
|
+
"reova": {
|
|
55
|
+
"enabled": true,
|
|
56
|
+
"endpoint": "https://telemetry.reo.dev/data"
|
|
57
|
+
},
|
|
55
58
|
"main": "dist/index.js",
|
|
56
59
|
"types": "dist/index.d.ts",
|
|
57
60
|
"exports": {
|
|
@@ -71,12 +74,11 @@
|
|
|
71
74
|
"dist",
|
|
72
75
|
"hooks",
|
|
73
76
|
".mcp.json",
|
|
74
|
-
"!dist/dev",
|
|
75
77
|
"!dist/**/*.tsbuildinfo"
|
|
76
78
|
],
|
|
77
79
|
"dependencies": {
|
|
78
|
-
"
|
|
79
|
-
"@ory/argus": "0.
|
|
80
|
+
"reova": "^0.7.0",
|
|
81
|
+
"@ory/argus": "1.0.0"
|
|
80
82
|
},
|
|
81
83
|
"engines": {
|
|
82
84
|
"node": ">=22"
|
|
@@ -86,7 +88,6 @@
|
|
|
86
88
|
"clean": "rm -rf dist *.tsbuildinfo",
|
|
87
89
|
"test": "vitest run",
|
|
88
90
|
"test:watch": "vitest",
|
|
89
|
-
"typecheck": "tsc --noEmit"
|
|
90
|
-
"dev": "node dist/dev/launcher.js"
|
|
91
|
+
"typecheck": "tsc --noEmit"
|
|
91
92
|
}
|
|
92
93
|
}
|