@goodfoot/claude-code-hooks 1.0.10 → 1.0.11
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/cli.js +597 -604
- package/dist/constants.js +12 -12
- package/dist/env.js +36 -38
- package/dist/hooks.js +22 -22
- package/dist/index.js +37 -67
- package/dist/logger.js +371 -362
- package/dist/outputs.js +33 -34
- package/dist/runtime.js +99 -96
- package/dist/scaffold.js +178 -182
- package/dist/tool-helpers.js +255 -103
- package/dist/types.js +35 -0
- package/package.json +8 -11
- package/types/cli.d.ts +67 -98
- package/types/constants.d.ts +1 -1
- package/types/env.d.ts +16 -16
- package/types/hooks.d.ts +168 -254
- package/types/index.d.ts +15 -130
- package/types/logger.d.ts +285 -285
- package/types/outputs.d.ts +154 -229
- package/types/runtime.d.ts +4 -6
- package/types/scaffold.d.ts +6 -6
- package/types/tool-helpers.d.ts +206 -77
- package/types/types.d.ts +497 -0
- package/dist/inputs.js +0 -35
- package/dist/tool-inputs.js +0 -21
package/types/outputs.d.ts
CHANGED
|
@@ -7,10 +7,7 @@
|
|
|
7
7
|
* @see https://code.claude.com/docs/en/hooks
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
11
|
-
PermissionUpdate,
|
|
12
|
-
SyncHookJSONOutput as SDKSyncHookJSONOutput
|
|
13
|
-
} from '@anthropic-ai/claude-agent-sdk/entrypoints/agentSdkTypes.js';
|
|
10
|
+
import type { PermissionRequestHookSpecificOutput as SDKPermissionRequestHookSpecificOutput, PostToolUseFailureHookSpecificOutput as SDKPostToolUseFailureHookSpecificOutput, PostToolUseHookSpecificOutput as SDKPostToolUseHookSpecificOutput, PreToolUseHookSpecificOutput as SDKPreToolUseHookSpecificOutput, SessionStartHookSpecificOutput as SDKSessionStartHookSpecificOutput, SubagentStartHookSpecificOutput as SDKSubagentStartHookSpecificOutput, SyncHookJSONOutput as SDKSyncHookJSONOutput, UserPromptSubmitHookSpecificOutput as SDKUserPromptSubmitHookSpecificOutput } from "@anthropic-ai/claude-agent-sdk/sdk.js";
|
|
14
11
|
/**
|
|
15
12
|
* Exit codes used by Claude Code hooks.
|
|
16
13
|
*
|
|
@@ -21,266 +18,210 @@ import type {
|
|
|
21
18
|
* | 2 | Block | Handler throws OR `stopReason` set | Blocking, stderr shown to Claude |
|
|
22
19
|
*/
|
|
23
20
|
export declare const EXIT_CODES: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
/** Handler completed successfully. Claude Code parses stdout as JSON. */
|
|
22
|
+
readonly SUCCESS: 0;
|
|
23
|
+
/** Non-blocking error occurred (e.g., invalid input). stderr shown to user only. */
|
|
24
|
+
readonly ERROR: 1;
|
|
25
|
+
/** Handler threw exception OR blocking action requested. stderr shown to Claude. */
|
|
26
|
+
readonly BLOCK: 2;
|
|
30
27
|
};
|
|
31
28
|
/**
|
|
32
29
|
* Exit code type.
|
|
33
30
|
*/
|
|
34
31
|
export type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];
|
|
35
32
|
/**
|
|
36
|
-
* Re-export the SDK's SyncHookJSONOutput type
|
|
37
|
-
* Our types are derived from this to ensure wire format compatibility.
|
|
33
|
+
* Re-export the SDK's SyncHookJSONOutput type.
|
|
38
34
|
*/
|
|
39
35
|
export type { SDKSyncHookJSONOutput };
|
|
36
|
+
/**
|
|
37
|
+
* Re-export SDK hook-specific output types (includes hookEventName discriminator).
|
|
38
|
+
*/
|
|
39
|
+
export type { SDKPreToolUseHookSpecificOutput, SDKPostToolUseHookSpecificOutput, SDKPostToolUseFailureHookSpecificOutput, SDKUserPromptSubmitHookSpecificOutput, SDKSessionStartHookSpecificOutput, SDKSubagentStartHookSpecificOutput, SDKPermissionRequestHookSpecificOutput, };
|
|
40
40
|
/**
|
|
41
41
|
* PreToolUse hook-specific output fields.
|
|
42
|
-
* Omits `hookEventName` which is added automatically.
|
|
43
|
-
*/
|
|
44
|
-
export
|
|
45
|
-
/** Permission decision: 'allow', 'deny', or 'ask' */
|
|
46
|
-
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
47
|
-
/** Reason for the permission decision. */
|
|
48
|
-
permissionDecisionReason?: string;
|
|
49
|
-
/** Modified tool input to use instead of original. */
|
|
50
|
-
updatedInput?: Record<string, unknown>;
|
|
51
|
-
}
|
|
42
|
+
* Omits `hookEventName` which is added automatically by the builder.
|
|
43
|
+
*/
|
|
44
|
+
export type PreToolUseHookSpecificOutput = Omit<SDKPreToolUseHookSpecificOutput, "hookEventName">;
|
|
52
45
|
/**
|
|
53
46
|
* PostToolUse hook-specific output fields.
|
|
47
|
+
* Omits `hookEventName` which is added automatically by the builder.
|
|
54
48
|
*/
|
|
55
|
-
export
|
|
56
|
-
/** Additional context to add to the transcript. */
|
|
57
|
-
additionalContext?: string;
|
|
58
|
-
/** Updated MCP tool output to replace the original. */
|
|
59
|
-
updatedMCPToolOutput?: unknown;
|
|
60
|
-
}
|
|
49
|
+
export type PostToolUseHookSpecificOutput = Omit<SDKPostToolUseHookSpecificOutput, "hookEventName">;
|
|
61
50
|
/**
|
|
62
51
|
* PostToolUseFailure hook-specific output fields.
|
|
52
|
+
* Omits `hookEventName` which is added automatically by the builder.
|
|
63
53
|
*/
|
|
64
|
-
export
|
|
65
|
-
/** Additional context to add after the failure. */
|
|
66
|
-
additionalContext?: string;
|
|
67
|
-
}
|
|
54
|
+
export type PostToolUseFailureHookSpecificOutput = Omit<SDKPostToolUseFailureHookSpecificOutput, "hookEventName">;
|
|
68
55
|
/**
|
|
69
56
|
* UserPromptSubmit hook-specific output fields.
|
|
57
|
+
* Omits `hookEventName` which is added automatically by the builder.
|
|
70
58
|
*/
|
|
71
|
-
export
|
|
72
|
-
/** Additional context to inject into the conversation. */
|
|
73
|
-
additionalContext?: string;
|
|
74
|
-
}
|
|
59
|
+
export type UserPromptSubmitHookSpecificOutput = Omit<SDKUserPromptSubmitHookSpecificOutput, "hookEventName">;
|
|
75
60
|
/**
|
|
76
61
|
* SessionStart hook-specific output fields.
|
|
62
|
+
* Omits `hookEventName` which is added automatically by the builder.
|
|
77
63
|
*/
|
|
78
|
-
export
|
|
79
|
-
/** Additional context to inject at session start. */
|
|
80
|
-
additionalContext?: string;
|
|
81
|
-
}
|
|
64
|
+
export type SessionStartHookSpecificOutput = Omit<SDKSessionStartHookSpecificOutput, "hookEventName">;
|
|
82
65
|
/**
|
|
83
66
|
* SubagentStart hook-specific output fields.
|
|
67
|
+
* Omits `hookEventName` which is added automatically by the builder.
|
|
84
68
|
*/
|
|
85
|
-
export
|
|
86
|
-
/** Additional context to inject for the subagent. */
|
|
87
|
-
additionalContext?: string;
|
|
88
|
-
}
|
|
69
|
+
export type SubagentStartHookSpecificOutput = Omit<SDKSubagentStartHookSpecificOutput, "hookEventName">;
|
|
89
70
|
/**
|
|
90
|
-
*
|
|
71
|
+
* PermissionRequest hook-specific output fields.
|
|
72
|
+
* Omits `hookEventName` which is added automatically by the builder.
|
|
91
73
|
*/
|
|
92
|
-
export
|
|
93
|
-
/** Additional context to add about the notification. */
|
|
94
|
-
additionalContext?: string;
|
|
95
|
-
}
|
|
74
|
+
export type PermissionRequestHookSpecificOutput = Omit<SDKPermissionRequestHookSpecificOutput, "hookEventName">;
|
|
96
75
|
/**
|
|
97
76
|
* Allow decision for permission requests.
|
|
77
|
+
* Derived from SDK's PermissionRequestHookSpecificOutput.
|
|
98
78
|
*/
|
|
99
|
-
export
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
updatedInput?: Record<string, unknown>;
|
|
103
|
-
/** Permission updates to apply. */
|
|
104
|
-
updatedPermissions?: PermissionUpdate[];
|
|
105
|
-
}
|
|
79
|
+
export type PermissionRequestAllowDecision = Extract<SDKPermissionRequestHookSpecificOutput["decision"], {
|
|
80
|
+
behavior: "allow";
|
|
81
|
+
}>;
|
|
106
82
|
/**
|
|
107
83
|
* Deny decision for permission requests.
|
|
84
|
+
* Derived from SDK's PermissionRequestHookSpecificOutput.
|
|
108
85
|
*/
|
|
109
|
-
export
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
message?: string;
|
|
113
|
-
/** Whether to interrupt the current operation. */
|
|
114
|
-
interrupt?: boolean;
|
|
115
|
-
}
|
|
86
|
+
export type PermissionRequestDenyDecision = Extract<SDKPermissionRequestHookSpecificOutput["decision"], {
|
|
87
|
+
behavior: "deny";
|
|
88
|
+
}>;
|
|
116
89
|
/**
|
|
117
90
|
* Permission request decision - either allow or deny.
|
|
91
|
+
* Derived from SDK's PermissionRequestHookSpecificOutput.
|
|
118
92
|
*/
|
|
119
|
-
export type PermissionRequestDecision =
|
|
93
|
+
export type PermissionRequestDecision = SDKPermissionRequestHookSpecificOutput["decision"];
|
|
120
94
|
/**
|
|
121
|
-
*
|
|
95
|
+
* Notification hook-specific output fields.
|
|
96
|
+
* Note: Not in SDK, defined here for completeness.
|
|
122
97
|
*/
|
|
123
|
-
export interface
|
|
124
|
-
|
|
125
|
-
|
|
98
|
+
export interface NotificationHookSpecificOutput {
|
|
99
|
+
/** Additional context to add about the notification. */
|
|
100
|
+
additionalContext?: string;
|
|
126
101
|
}
|
|
127
102
|
/**
|
|
128
103
|
* Full hook-specific output with hookEventName discriminator.
|
|
129
104
|
*/
|
|
130
|
-
export type HookSpecificOutput =
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
} & PreToolUseHookSpecificOutput)
|
|
134
|
-
| ({
|
|
135
|
-
hookEventName: 'PostToolUse';
|
|
136
|
-
} & PostToolUseHookSpecificOutput)
|
|
137
|
-
| ({
|
|
138
|
-
hookEventName: 'PostToolUseFailure';
|
|
139
|
-
} & PostToolUseFailureHookSpecificOutput)
|
|
140
|
-
| ({
|
|
141
|
-
hookEventName: 'UserPromptSubmit';
|
|
142
|
-
} & UserPromptSubmitHookSpecificOutput)
|
|
143
|
-
| ({
|
|
144
|
-
hookEventName: 'SessionStart';
|
|
145
|
-
} & SessionStartHookSpecificOutput)
|
|
146
|
-
| ({
|
|
147
|
-
hookEventName: 'SubagentStart';
|
|
148
|
-
} & SubagentStartHookSpecificOutput)
|
|
149
|
-
| ({
|
|
150
|
-
hookEventName: 'Notification';
|
|
151
|
-
} & NotificationHookSpecificOutput)
|
|
152
|
-
| ({
|
|
153
|
-
hookEventName: 'PermissionRequest';
|
|
154
|
-
} & PermissionRequestHookSpecificOutput);
|
|
105
|
+
export type HookSpecificOutput = SDKPreToolUseHookSpecificOutput | SDKPostToolUseHookSpecificOutput | SDKPostToolUseFailureHookSpecificOutput | SDKUserPromptSubmitHookSpecificOutput | SDKSessionStartHookSpecificOutput | SDKSubagentStartHookSpecificOutput | SDKPermissionRequestHookSpecificOutput | ({
|
|
106
|
+
hookEventName: "Notification";
|
|
107
|
+
} & NotificationHookSpecificOutput);
|
|
155
108
|
/**
|
|
156
109
|
* The JSON output format expected by Claude Code (sync hooks only).
|
|
157
|
-
*
|
|
110
|
+
* Extends SDK's SyncHookJSONOutput to include Notification hook support.
|
|
158
111
|
*/
|
|
159
112
|
export interface SyncHookJSONOutput {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
113
|
+
/** If true, continue processing even after errors. */
|
|
114
|
+
continue?: boolean;
|
|
115
|
+
/** If true, suppress the hook's output from being displayed. */
|
|
116
|
+
suppressOutput?: boolean;
|
|
117
|
+
/** Reason for stopping the session (when blocking). */
|
|
118
|
+
stopReason?: string;
|
|
119
|
+
/** Decision for Stop/SubagentStop hooks: 'approve' allows stop, 'block' prevents it. */
|
|
120
|
+
decision?: "approve" | "block";
|
|
121
|
+
/** System message to inject into Claude's context. */
|
|
122
|
+
systemMessage?: string;
|
|
123
|
+
/** Reason shown to Claude when blocking. */
|
|
124
|
+
reason?: string;
|
|
125
|
+
/** Hook-specific output based on the hook type. */
|
|
126
|
+
hookSpecificOutput?: HookSpecificOutput;
|
|
174
127
|
}
|
|
175
128
|
/**
|
|
176
129
|
* The result of a hook handler, ready for the runtime to process.
|
|
177
130
|
* Exit code is always SUCCESS (0) - blocking behavior is communicated via stdout fields.
|
|
178
131
|
*/
|
|
179
132
|
export interface HookOutput {
|
|
180
|
-
|
|
181
|
-
|
|
133
|
+
/** JSON-serializable output to write to stdout. */
|
|
134
|
+
stdout: SyncHookJSONOutput;
|
|
182
135
|
}
|
|
183
136
|
/**
|
|
184
137
|
* Common options available to all output builders.
|
|
185
138
|
* These map directly to the wire format fields.
|
|
186
139
|
*/
|
|
187
140
|
export interface CommonOptions {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
141
|
+
/** If true, continue processing even after errors. */
|
|
142
|
+
continue?: boolean;
|
|
143
|
+
/** If true, suppress the hook's output from being displayed. */
|
|
144
|
+
suppressOutput?: boolean;
|
|
145
|
+
/** System message to inject into Claude's context. */
|
|
146
|
+
systemMessage?: string;
|
|
147
|
+
/** Reason for stopping/blocking (sets exit code to BLOCK). */
|
|
148
|
+
stopReason?: string;
|
|
196
149
|
}
|
|
197
150
|
/**
|
|
198
151
|
* Base structure for all specific outputs.
|
|
199
152
|
*/
|
|
200
153
|
interface BaseSpecificOutput<T extends string> {
|
|
201
|
-
|
|
202
|
-
|
|
154
|
+
readonly _type: T;
|
|
155
|
+
stdout: SyncHookJSONOutput;
|
|
203
156
|
}
|
|
204
157
|
/**
|
|
205
158
|
*
|
|
206
159
|
*/
|
|
207
|
-
export type PreToolUseOutput = BaseSpecificOutput<
|
|
160
|
+
export type PreToolUseOutput = BaseSpecificOutput<"PreToolUse">;
|
|
208
161
|
/**
|
|
209
162
|
*
|
|
210
163
|
*/
|
|
211
|
-
export type PostToolUseOutput = BaseSpecificOutput<
|
|
164
|
+
export type PostToolUseOutput = BaseSpecificOutput<"PostToolUse">;
|
|
212
165
|
/**
|
|
213
166
|
*
|
|
214
167
|
*/
|
|
215
|
-
export type PostToolUseFailureOutput = BaseSpecificOutput<
|
|
168
|
+
export type PostToolUseFailureOutput = BaseSpecificOutput<"PostToolUseFailure">;
|
|
216
169
|
/**
|
|
217
170
|
*
|
|
218
171
|
*/
|
|
219
|
-
export type NotificationOutput = BaseSpecificOutput<
|
|
172
|
+
export type NotificationOutput = BaseSpecificOutput<"Notification">;
|
|
220
173
|
/**
|
|
221
174
|
*
|
|
222
175
|
*/
|
|
223
|
-
export type UserPromptSubmitOutput = BaseSpecificOutput<
|
|
176
|
+
export type UserPromptSubmitOutput = BaseSpecificOutput<"UserPromptSubmit">;
|
|
224
177
|
/**
|
|
225
178
|
*
|
|
226
179
|
*/
|
|
227
|
-
export type SessionStartOutput = BaseSpecificOutput<
|
|
180
|
+
export type SessionStartOutput = BaseSpecificOutput<"SessionStart">;
|
|
228
181
|
/**
|
|
229
182
|
*
|
|
230
183
|
*/
|
|
231
|
-
export type SessionEndOutput = BaseSpecificOutput<
|
|
184
|
+
export type SessionEndOutput = BaseSpecificOutput<"SessionEnd">;
|
|
232
185
|
/**
|
|
233
186
|
*
|
|
234
187
|
*/
|
|
235
|
-
export type StopOutput = BaseSpecificOutput<
|
|
188
|
+
export type StopOutput = BaseSpecificOutput<"Stop">;
|
|
236
189
|
/**
|
|
237
190
|
*
|
|
238
191
|
*/
|
|
239
|
-
export type SubagentStartOutput = BaseSpecificOutput<
|
|
192
|
+
export type SubagentStartOutput = BaseSpecificOutput<"SubagentStart">;
|
|
240
193
|
/**
|
|
241
194
|
*
|
|
242
195
|
*/
|
|
243
|
-
export type SubagentStopOutput = BaseSpecificOutput<
|
|
196
|
+
export type SubagentStopOutput = BaseSpecificOutput<"SubagentStop">;
|
|
244
197
|
/**
|
|
245
198
|
*
|
|
246
199
|
*/
|
|
247
|
-
export type PreCompactOutput = BaseSpecificOutput<
|
|
200
|
+
export type PreCompactOutput = BaseSpecificOutput<"PreCompact">;
|
|
248
201
|
/**
|
|
249
202
|
*
|
|
250
203
|
*/
|
|
251
|
-
export type PermissionRequestOutput = BaseSpecificOutput<
|
|
204
|
+
export type PermissionRequestOutput = BaseSpecificOutput<"PermissionRequest">;
|
|
252
205
|
/**
|
|
253
206
|
* Union of all specific output types.
|
|
254
207
|
*/
|
|
255
|
-
export type SpecificHookOutput =
|
|
256
|
-
| PreToolUseOutput
|
|
257
|
-
| PostToolUseOutput
|
|
258
|
-
| PostToolUseFailureOutput
|
|
259
|
-
| NotificationOutput
|
|
260
|
-
| UserPromptSubmitOutput
|
|
261
|
-
| SessionStartOutput
|
|
262
|
-
| SessionEndOutput
|
|
263
|
-
| StopOutput
|
|
264
|
-
| SubagentStartOutput
|
|
265
|
-
| SubagentStopOutput
|
|
266
|
-
| PreCompactOutput
|
|
267
|
-
| PermissionRequestOutput;
|
|
208
|
+
export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PermissionRequestOutput;
|
|
268
209
|
/**
|
|
269
210
|
* Options for decision-based hooks (Stop, SubagentStop).
|
|
270
211
|
*/
|
|
271
212
|
interface DecisionOptions extends CommonOptions {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
213
|
+
/** Decision: 'approve' allows the action, 'block' prevents it. */
|
|
214
|
+
decision?: "approve" | "block";
|
|
215
|
+
/** Reason for the decision (shown to Claude when blocking). */
|
|
216
|
+
reason?: string;
|
|
276
217
|
}
|
|
277
218
|
/**
|
|
278
219
|
* Options for the PreToolUse output builder.
|
|
279
220
|
* Uses wire format: hookSpecificOutput with permissionDecision.
|
|
280
221
|
*/
|
|
281
222
|
export type PreToolUseOptions = CommonOptions & {
|
|
282
|
-
|
|
283
|
-
|
|
223
|
+
/** Hook-specific output matching the wire format. */
|
|
224
|
+
hookSpecificOutput?: PreToolUseHookSpecificOutput;
|
|
284
225
|
};
|
|
285
226
|
/**
|
|
286
227
|
* Creates an output for PreToolUse hooks.
|
|
@@ -310,20 +251,18 @@ export type PreToolUseOptions = CommonOptions & {
|
|
|
310
251
|
* });
|
|
311
252
|
* ```
|
|
312
253
|
*/
|
|
313
|
-
export declare const preToolUseOutput: (
|
|
314
|
-
options?: CommonOptions & {
|
|
254
|
+
export declare const preToolUseOutput: (options?: CommonOptions & {
|
|
315
255
|
hookSpecificOutput?: PreToolUseHookSpecificOutput | undefined;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
stdout: SyncHookJSONOutput;
|
|
256
|
+
}) => {
|
|
257
|
+
readonly _type: "PreToolUse";
|
|
258
|
+
stdout: SyncHookJSONOutput;
|
|
320
259
|
};
|
|
321
260
|
/**
|
|
322
261
|
* Options for the PostToolUse output builder.
|
|
323
262
|
*/
|
|
324
263
|
export type PostToolUseOptions = CommonOptions & {
|
|
325
|
-
|
|
326
|
-
|
|
264
|
+
/** Hook-specific output matching the wire format. */
|
|
265
|
+
hookSpecificOutput?: PostToolUseHookSpecificOutput;
|
|
327
266
|
};
|
|
328
267
|
/**
|
|
329
268
|
* Creates an output for PostToolUse hooks.
|
|
@@ -339,20 +278,18 @@ export type PostToolUseOptions = CommonOptions & {
|
|
|
339
278
|
* });
|
|
340
279
|
* ```
|
|
341
280
|
*/
|
|
342
|
-
export declare const postToolUseOutput: (
|
|
343
|
-
options?: CommonOptions & {
|
|
281
|
+
export declare const postToolUseOutput: (options?: CommonOptions & {
|
|
344
282
|
hookSpecificOutput?: PostToolUseHookSpecificOutput | undefined;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
stdout: SyncHookJSONOutput;
|
|
283
|
+
}) => {
|
|
284
|
+
readonly _type: "PostToolUse";
|
|
285
|
+
stdout: SyncHookJSONOutput;
|
|
349
286
|
};
|
|
350
287
|
/**
|
|
351
288
|
* Options for the PostToolUseFailure output builder.
|
|
352
289
|
*/
|
|
353
290
|
export type PostToolUseFailureOptions = CommonOptions & {
|
|
354
|
-
|
|
355
|
-
|
|
291
|
+
/** Hook-specific output matching the wire format. */
|
|
292
|
+
hookSpecificOutput?: PostToolUseFailureHookSpecificOutput;
|
|
356
293
|
};
|
|
357
294
|
/**
|
|
358
295
|
* Creates an output for PostToolUseFailure hooks.
|
|
@@ -367,20 +304,18 @@ export type PostToolUseFailureOptions = CommonOptions & {
|
|
|
367
304
|
* });
|
|
368
305
|
* ```
|
|
369
306
|
*/
|
|
370
|
-
export declare const postToolUseFailureOutput: (
|
|
371
|
-
options?: CommonOptions & {
|
|
307
|
+
export declare const postToolUseFailureOutput: (options?: CommonOptions & {
|
|
372
308
|
hookSpecificOutput?: PostToolUseFailureHookSpecificOutput | undefined;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
stdout: SyncHookJSONOutput;
|
|
309
|
+
}) => {
|
|
310
|
+
readonly _type: "PostToolUseFailure";
|
|
311
|
+
stdout: SyncHookJSONOutput;
|
|
377
312
|
};
|
|
378
313
|
/**
|
|
379
314
|
* Options for the UserPromptSubmit output builder.
|
|
380
315
|
*/
|
|
381
316
|
export type UserPromptSubmitOptions = CommonOptions & {
|
|
382
|
-
|
|
383
|
-
|
|
317
|
+
/** Hook-specific output matching the wire format. */
|
|
318
|
+
hookSpecificOutput?: UserPromptSubmitHookSpecificOutput;
|
|
384
319
|
};
|
|
385
320
|
/**
|
|
386
321
|
* Creates an output for UserPromptSubmit hooks.
|
|
@@ -395,20 +330,18 @@ export type UserPromptSubmitOptions = CommonOptions & {
|
|
|
395
330
|
* });
|
|
396
331
|
* ```
|
|
397
332
|
*/
|
|
398
|
-
export declare const userPromptSubmitOutput: (
|
|
399
|
-
options?: CommonOptions & {
|
|
333
|
+
export declare const userPromptSubmitOutput: (options?: CommonOptions & {
|
|
400
334
|
hookSpecificOutput?: UserPromptSubmitHookSpecificOutput | undefined;
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
stdout: SyncHookJSONOutput;
|
|
335
|
+
}) => {
|
|
336
|
+
readonly _type: "UserPromptSubmit";
|
|
337
|
+
stdout: SyncHookJSONOutput;
|
|
405
338
|
};
|
|
406
339
|
/**
|
|
407
340
|
* Options for the SessionStart output builder.
|
|
408
341
|
*/
|
|
409
342
|
export type SessionStartOptions = CommonOptions & {
|
|
410
|
-
|
|
411
|
-
|
|
343
|
+
/** Hook-specific output matching the wire format. */
|
|
344
|
+
hookSpecificOutput?: SessionStartHookSpecificOutput;
|
|
412
345
|
};
|
|
413
346
|
/**
|
|
414
347
|
* Creates an output for SessionStart hooks.
|
|
@@ -423,13 +356,11 @@ export type SessionStartOptions = CommonOptions & {
|
|
|
423
356
|
* });
|
|
424
357
|
* ```
|
|
425
358
|
*/
|
|
426
|
-
export declare const sessionStartOutput: (
|
|
427
|
-
options?: CommonOptions & {
|
|
359
|
+
export declare const sessionStartOutput: (options?: CommonOptions & {
|
|
428
360
|
hookSpecificOutput?: SessionStartHookSpecificOutput | undefined;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
stdout: SyncHookJSONOutput;
|
|
361
|
+
}) => {
|
|
362
|
+
readonly _type: "SessionStart";
|
|
363
|
+
stdout: SyncHookJSONOutput;
|
|
433
364
|
};
|
|
434
365
|
/**
|
|
435
366
|
* Options for the SessionEnd output builder.
|
|
@@ -446,17 +377,17 @@ export type SessionEndOptions = CommonOptions;
|
|
|
446
377
|
* ```
|
|
447
378
|
*/
|
|
448
379
|
export declare const sessionEndOutput: (options?: CommonOptions) => {
|
|
449
|
-
|
|
450
|
-
|
|
380
|
+
readonly _type: "SessionEnd";
|
|
381
|
+
stdout: SyncHookJSONOutput;
|
|
451
382
|
};
|
|
452
383
|
/**
|
|
453
384
|
* Options for the Stop output builder.
|
|
454
385
|
*/
|
|
455
386
|
export interface StopOptions extends CommonOptions {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
387
|
+
/** Decision: 'approve' allows stop, 'block' prevents it. */
|
|
388
|
+
decision?: "approve" | "block";
|
|
389
|
+
/** Reason for the decision (shown to Claude when blocking). */
|
|
390
|
+
reason?: string;
|
|
460
391
|
}
|
|
461
392
|
/**
|
|
462
393
|
* Creates an output for Stop hooks.
|
|
@@ -475,15 +406,15 @@ export interface StopOptions extends CommonOptions {
|
|
|
475
406
|
* ```
|
|
476
407
|
*/
|
|
477
408
|
export declare const stopOutput: (options?: DecisionOptions) => {
|
|
478
|
-
|
|
479
|
-
|
|
409
|
+
readonly _type: "Stop";
|
|
410
|
+
stdout: SyncHookJSONOutput;
|
|
480
411
|
};
|
|
481
412
|
/**
|
|
482
413
|
* Options for the SubagentStart output builder.
|
|
483
414
|
*/
|
|
484
415
|
export type SubagentStartOptions = CommonOptions & {
|
|
485
|
-
|
|
486
|
-
|
|
416
|
+
/** Hook-specific output matching the wire format. */
|
|
417
|
+
hookSpecificOutput?: SubagentStartHookSpecificOutput;
|
|
487
418
|
};
|
|
488
419
|
/**
|
|
489
420
|
* Creates an output for SubagentStart hooks.
|
|
@@ -498,22 +429,20 @@ export type SubagentStartOptions = CommonOptions & {
|
|
|
498
429
|
* });
|
|
499
430
|
* ```
|
|
500
431
|
*/
|
|
501
|
-
export declare const subagentStartOutput: (
|
|
502
|
-
options?: CommonOptions & {
|
|
432
|
+
export declare const subagentStartOutput: (options?: CommonOptions & {
|
|
503
433
|
hookSpecificOutput?: SubagentStartHookSpecificOutput | undefined;
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
stdout: SyncHookJSONOutput;
|
|
434
|
+
}) => {
|
|
435
|
+
readonly _type: "SubagentStart";
|
|
436
|
+
stdout: SyncHookJSONOutput;
|
|
508
437
|
};
|
|
509
438
|
/**
|
|
510
439
|
* Options for the SubagentStop output builder.
|
|
511
440
|
*/
|
|
512
441
|
export interface SubagentStopOptions extends CommonOptions {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
442
|
+
/** Decision: 'approve' allows stop, 'block' prevents it. */
|
|
443
|
+
decision?: "approve" | "block";
|
|
444
|
+
/** Reason for the decision (shown to subagent when blocking). */
|
|
445
|
+
reason?: string;
|
|
517
446
|
}
|
|
518
447
|
/**
|
|
519
448
|
* Creates an output for SubagentStop hooks.
|
|
@@ -529,15 +458,15 @@ export interface SubagentStopOptions extends CommonOptions {
|
|
|
529
458
|
* ```
|
|
530
459
|
*/
|
|
531
460
|
export declare const subagentStopOutput: (options?: DecisionOptions) => {
|
|
532
|
-
|
|
533
|
-
|
|
461
|
+
readonly _type: "SubagentStop";
|
|
462
|
+
stdout: SyncHookJSONOutput;
|
|
534
463
|
};
|
|
535
464
|
/**
|
|
536
465
|
* Options for the Notification output builder.
|
|
537
466
|
*/
|
|
538
467
|
export type NotificationOptions = CommonOptions & {
|
|
539
|
-
|
|
540
|
-
|
|
468
|
+
/** Hook-specific output matching the wire format. */
|
|
469
|
+
hookSpecificOutput?: NotificationHookSpecificOutput;
|
|
541
470
|
};
|
|
542
471
|
/**
|
|
543
472
|
* Creates an output for Notification hooks.
|
|
@@ -556,13 +485,11 @@ export type NotificationOptions = CommonOptions & {
|
|
|
556
485
|
* notificationOutput({ suppressOutput: true });
|
|
557
486
|
* ```
|
|
558
487
|
*/
|
|
559
|
-
export declare const notificationOutput: (
|
|
560
|
-
options?: CommonOptions & {
|
|
488
|
+
export declare const notificationOutput: (options?: CommonOptions & {
|
|
561
489
|
hookSpecificOutput?: NotificationHookSpecificOutput | undefined;
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
stdout: SyncHookJSONOutput;
|
|
490
|
+
}) => {
|
|
491
|
+
readonly _type: "Notification";
|
|
492
|
+
stdout: SyncHookJSONOutput;
|
|
566
493
|
};
|
|
567
494
|
/**
|
|
568
495
|
* Options for the PreCompact output builder.
|
|
@@ -581,15 +508,15 @@ export type PreCompactOptions = CommonOptions;
|
|
|
581
508
|
* ```
|
|
582
509
|
*/
|
|
583
510
|
export declare const preCompactOutput: (options?: CommonOptions) => {
|
|
584
|
-
|
|
585
|
-
|
|
511
|
+
readonly _type: "PreCompact";
|
|
512
|
+
stdout: SyncHookJSONOutput;
|
|
586
513
|
};
|
|
587
514
|
/**
|
|
588
515
|
* Options for the PermissionRequest output builder.
|
|
589
516
|
*/
|
|
590
517
|
export type PermissionRequestOptions = CommonOptions & {
|
|
591
|
-
|
|
592
|
-
|
|
518
|
+
/** Hook-specific output matching the wire format. */
|
|
519
|
+
hookSpecificOutput?: PermissionRequestHookSpecificOutput;
|
|
593
520
|
};
|
|
594
521
|
/**
|
|
595
522
|
* Creates an output for PermissionRequest hooks.
|
|
@@ -629,13 +556,11 @@ export type PermissionRequestOptions = CommonOptions & {
|
|
|
629
556
|
* permissionRequestOutput({});
|
|
630
557
|
* ```
|
|
631
558
|
*/
|
|
632
|
-
export declare const permissionRequestOutput: (
|
|
633
|
-
options?: CommonOptions & {
|
|
559
|
+
export declare const permissionRequestOutput: (options?: CommonOptions & {
|
|
634
560
|
hookSpecificOutput?: PermissionRequestHookSpecificOutput | undefined;
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
stdout: SyncHookJSONOutput;
|
|
561
|
+
}) => {
|
|
562
|
+
readonly _type: "PermissionRequest";
|
|
563
|
+
stdout: SyncHookJSONOutput;
|
|
639
564
|
};
|
|
640
565
|
/**
|
|
641
566
|
* @deprecated Use CommonOptions instead
|
package/types/runtime.d.ts
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* ```
|
|
19
19
|
* @see https://code.claude.com/docs/en/hooks
|
|
20
20
|
*/
|
|
21
|
-
import type { HookFunction } from
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
21
|
+
import type { HookFunction } from "./hooks.js";
|
|
22
|
+
import type { HookOutput, SpecificHookOutput } from "./outputs.js";
|
|
23
|
+
import type { HookInput } from "./types.js";
|
|
24
24
|
/**
|
|
25
25
|
* Converts a SpecificHookOutput to HookOutput for wire format.
|
|
26
26
|
*
|
|
@@ -70,6 +70,4 @@ export declare function convertToHookOutput(specificOutput: SpecificHookOutput):
|
|
|
70
70
|
* ```
|
|
71
71
|
* @see https://code.claude.com/docs/en/hooks
|
|
72
72
|
*/
|
|
73
|
-
export declare function execute<TInput extends HookInput, TOutput extends SpecificHookOutput>(
|
|
74
|
-
hookFn: HookFunction<TInput, TOutput>
|
|
75
|
-
): Promise<void>;
|
|
73
|
+
export declare function execute<TInput extends HookInput, TOutput extends SpecificHookOutput>(hookFn: HookFunction<TInput, TOutput>): Promise<void>;
|