@ory/claude-code 0.1.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.
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.generateSettings = generateSettings;
37
+ exports.generateInstalledSettings = generateInstalledSettings;
38
+ exports.generateDevSettings = generateDevSettings;
39
+ const path = __importStar(require("node:path"));
40
+ const argus_1 = require("@ory/argus");
41
+ /**
42
+ * Generate the .claude/settings.local.json that configures Ory hooks.
43
+ */
44
+ function generateSettings(hookScriptPath) {
45
+ const cmd = `node ${hookScriptPath}`;
46
+ return {
47
+ hooks: {
48
+ SessionStart: (0, argus_1.matcherHookEntry)(cmd),
49
+ PreToolUse: (0, argus_1.matcherHookEntry)(cmd),
50
+ PostToolUse: (0, argus_1.matcherHookEntry)(cmd),
51
+ PermissionRequest: (0, argus_1.matcherHookEntry)(cmd),
52
+ },
53
+ };
54
+ }
55
+ /**
56
+ * Generate settings assuming the plugin is installed via npm/pnpm.
57
+ */
58
+ function generateInstalledSettings() {
59
+ return generateSettings("ory-claude-hook");
60
+ }
61
+ /**
62
+ * Generate settings pointing to a local dev build.
63
+ */
64
+ function generateDevSettings(packageDir) {
65
+ const hookPath = path.resolve(packageDir, "dist", "hook.js");
66
+ return generateSettings(hookPath);
67
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Claude Code hook event payload delivered on stdin.
3
+ * See: https://code.claude.com/docs/en/hooks
4
+ */
5
+ export interface ClaudeCodeHookInput {
6
+ session_id: string;
7
+ transcript_path: string;
8
+ cwd: string;
9
+ permission_mode?: "default" | "plan" | "acceptEdits" | "auto" | "dontAsk" | "bypassPermissions" | string;
10
+ hook_event_name: string;
11
+ tool_name?: string;
12
+ tool_input?: Record<string, unknown>;
13
+ tool_response?: Record<string, unknown>;
14
+ tool_use_id?: string;
15
+ /** PostToolUseFailure — tool error payload. */
16
+ tool_error?: unknown;
17
+ model?: string;
18
+ /** SessionStart matcher: startup | resume | clear | … */
19
+ source?: string;
20
+ prompt?: string;
21
+ subagent_type?: string;
22
+ subagent_prompt?: string;
23
+ subagent_response?: string;
24
+ agent_id?: string;
25
+ agent_type?: string;
26
+ /** Matcher: clear | resume | logout | prompt_input_exit | … */
27
+ reason?: string;
28
+ stop_hook_active?: boolean;
29
+ last_assistant_message?: string;
30
+ }
31
+ /**
32
+ * Claude Code hook output written to stdout.
33
+ *
34
+ * Top-level `decision: "block"` is honored on blocking-capable events
35
+ * (PreToolUse, UserPromptSubmit, PostToolUse, Stop, …). PermissionRequest
36
+ * uses the structured `hookSpecificOutput.decision.{behavior}` shape below
37
+ * instead — the top-level `decision` is ignored there.
38
+ */
39
+ export interface ClaudeCodeHookOutput {
40
+ continue?: boolean;
41
+ decision?: "block";
42
+ reason?: string;
43
+ stopReason?: string;
44
+ suppressOutput?: boolean;
45
+ systemMessage?: string;
46
+ updatedInput?: Record<string, unknown>;
47
+ hookSpecificOutput?: ClaudeCodeHookSpecificOutput;
48
+ }
49
+ /**
50
+ * Per-event structured output. Field shape depends on `hookEventName`:
51
+ * - PreToolUse: `permissionDecision` + `permissionDecisionReason`,
52
+ * plus optional `permissionRules` to persist a rule for future calls.
53
+ * - PermissionRequest: nested `decision: { behavior, updatedInput?, permissionRules? }`.
54
+ * Omit `decision` entirely to fall through to Claude's normal user prompt.
55
+ * - SessionStart / UserPromptSubmit: `additionalContext` for context injection.
56
+ */
57
+ export interface ClaudeCodeHookSpecificOutput {
58
+ hookEventName?: string;
59
+ permissionDecision?: "allow" | "deny" | "ask" | "defer";
60
+ permissionDecisionReason?: string;
61
+ decision?: {
62
+ behavior: "allow" | "deny";
63
+ updatedInput?: Record<string, unknown>;
64
+ permissionRules?: string[];
65
+ };
66
+ permissionRules?: string[];
67
+ additionalContext?: string;
68
+ /** Set when the plugin needs the agent to prompt the user for config. */
69
+ oryConfigRequired?: boolean;
70
+ message?: string;
71
+ [key: string]: unknown;
72
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,104 @@
1
+ {
2
+ "description": "Ory Claude Code Hooks",
3
+ "hooks": {
4
+ "SessionStart": [
5
+ {
6
+ "matcher": "",
7
+ "hooks": [
8
+ {
9
+ "type": "command",
10
+ "command": "npx ory-claude-hook"
11
+ }
12
+ ]
13
+ }
14
+ ],
15
+ "SessionEnd": [
16
+ {
17
+ "matcher": "",
18
+ "hooks": [
19
+ {
20
+ "type": "command",
21
+ "command": "npx ory-claude-hook"
22
+ }
23
+ ]
24
+ }
25
+ ],
26
+ "UserPromptSubmit": [
27
+ {
28
+ "matcher": "",
29
+ "hooks": [
30
+ {
31
+ "type": "command",
32
+ "command": "npx ory-claude-hook"
33
+ }
34
+ ]
35
+ }
36
+ ],
37
+ "PreToolUse": [
38
+ {
39
+ "matcher": "",
40
+ "hooks": [
41
+ {
42
+ "type": "command",
43
+ "command": "npx ory-claude-hook"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "PostToolUse": [
49
+ {
50
+ "matcher": "",
51
+ "hooks": [
52
+ {
53
+ "type": "command",
54
+ "command": "npx ory-claude-hook"
55
+ }
56
+ ]
57
+ }
58
+ ],
59
+ "PostToolUseFailure": [
60
+ {
61
+ "matcher": "",
62
+ "hooks": [
63
+ {
64
+ "type": "command",
65
+ "command": "npx ory-claude-hook"
66
+ }
67
+ ]
68
+ }
69
+ ],
70
+ "SubagentStart": [
71
+ {
72
+ "matcher": "",
73
+ "hooks": [
74
+ {
75
+ "type": "command",
76
+ "command": "npx ory-claude-hook"
77
+ }
78
+ ]
79
+ }
80
+ ],
81
+ "SubagentStop": [
82
+ {
83
+ "matcher": "",
84
+ "hooks": [
85
+ {
86
+ "type": "command",
87
+ "command": "npx ory-claude-hook"
88
+ }
89
+ ]
90
+ }
91
+ ],
92
+ "PermissionRequest": [
93
+ {
94
+ "matcher": "",
95
+ "hooks": [
96
+ {
97
+ "type": "command",
98
+ "command": "npx ory-claude-hook"
99
+ }
100
+ ]
101
+ }
102
+ ]
103
+ }
104
+ }
package/package.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "name": "@ory/claude-code",
3
+ "version": "0.1.0",
4
+ "description": "Ory plugin for Claude Code: scaffolding skills, a local Ory instance, and authentication, authorization, and audit for every tool call",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://ory.com",
7
+ "keywords": [
8
+ "ory",
9
+ "claude",
10
+ "claude-code",
11
+ "anthropic",
12
+ "hooks",
13
+ "plugin",
14
+ "identity",
15
+ "identity-management",
16
+ "iam",
17
+ "authentication",
18
+ "authorization",
19
+ "access-control",
20
+ "permissions",
21
+ "rbac",
22
+ "zanzibar",
23
+ "oauth",
24
+ "oauth2",
25
+ "openid-connect",
26
+ "oidc",
27
+ "session",
28
+ "mfa",
29
+ "sso",
30
+ "audit",
31
+ "audit-log",
32
+ "compliance",
33
+ "agent",
34
+ "ai-agent",
35
+ "agent-security",
36
+ "guardrails",
37
+ "llm",
38
+ "mcp",
39
+ "mcp-server",
40
+ "tracing",
41
+ "distributed-tracing",
42
+ "observability",
43
+ "kratos",
44
+ "keto",
45
+ "hydra"
46
+ ],
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "main": "dist/index.js",
51
+ "types": "dist/index.d.ts",
52
+ "exports": {
53
+ ".": {
54
+ "types": "./dist/index.d.ts",
55
+ "default": "./dist/index.js"
56
+ }
57
+ },
58
+ "bin": {
59
+ "claude-code": "dist/cli/main.js",
60
+ "ory-claude": "dist/cli/main.js",
61
+ "ory-claude-hook": "dist/hook.js",
62
+ "ory-claude-setup": "dist/cli/setup.js"
63
+ },
64
+ "files": [
65
+ ".claude-plugin",
66
+ "dist",
67
+ "hooks",
68
+ ".mcp.json",
69
+ "!dist/dev",
70
+ "!dist/**/*.tsbuildinfo"
71
+ ],
72
+ "dependencies": {
73
+ "@ory/argus": "0.1.0"
74
+ },
75
+ "engines": {
76
+ "node": ">=24"
77
+ },
78
+ "scripts": {
79
+ "build": "tsc",
80
+ "clean": "rm -rf dist *.tsbuildinfo",
81
+ "test": "vitest run",
82
+ "test:watch": "vitest",
83
+ "typecheck": "tsc --noEmit",
84
+ "dev": "node dist/dev/launcher.js"
85
+ }
86
+ }