@goodfoot/claude-code-hooks 1.2.1 → 1.2.3
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/README.md +3 -1
- package/dist/cli.js +2 -1
- package/dist/constants.js +2 -0
- package/dist/hooks.js +65 -0
- package/dist/index.js +5 -5
- package/dist/outputs.js +20 -0
- package/dist/scaffold.js +4 -2
- package/dist/types.js +2 -0
- package/package.json +3 -3
- package/types/cli.d.ts +2 -2
- package/types/hooks.d.ts +57 -2
- package/types/index.d.ts +4 -4
- package/types/outputs.d.ts +46 -3
- package/types/types.d.ts +30 -5
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ npm test # Run tests
|
|
|
107
107
|
|
|
108
108
|
### Available Hook Types
|
|
109
109
|
|
|
110
|
-
The `--hooks` argument accepts a comma-separated list of any of these
|
|
110
|
+
The `--hooks` argument accepts a comma-separated list of any of these 15 event types:
|
|
111
111
|
|
|
112
112
|
| Hook Type | Description |
|
|
113
113
|
| -------------------- | ------------------------------------------ |
|
|
@@ -119,9 +119,11 @@ The `--hooks` argument accepts a comma-separated list of any of these 13 event t
|
|
|
119
119
|
| `SessionStart` | When session begins |
|
|
120
120
|
| `SessionEnd` | When session terminates |
|
|
121
121
|
| `Stop` | After main agent finishes |
|
|
122
|
+
| `StopFailure` | When session stops due to an error |
|
|
122
123
|
| `SubagentStart` | When an Agent tool starts |
|
|
123
124
|
| `SubagentStop` | When an Agent tool completes |
|
|
124
125
|
| `PreCompact` | Before context compaction |
|
|
126
|
+
| `PostCompact` | After context compaction completes |
|
|
125
127
|
| `PermissionRequest` | When permission is requested |
|
|
126
128
|
| `Setup` | On init, install, or update events |
|
|
127
129
|
|
package/dist/cli.js
CHANGED
|
@@ -435,6 +435,7 @@ execute(hook);
|
|
|
435
435
|
target: "node20",
|
|
436
436
|
bundle: true,
|
|
437
437
|
minify: false,
|
|
438
|
+
treeShaking: true,
|
|
438
439
|
write: false, // Return content directly via outputFiles
|
|
439
440
|
banner: { js: esmRequireBanner },
|
|
440
441
|
// Keep node built-ins external
|
|
@@ -950,4 +951,4 @@ if (isDirectExecution) {
|
|
|
950
951
|
});
|
|
951
952
|
}
|
|
952
953
|
// Export for testing
|
|
953
|
-
export {
|
|
954
|
+
export { analyzeHookFile, compileHook, detectHookContext, discoverHookFiles, extractPreservedHooks, generateCommandPath, generateContentHash, generateHooksJson, groupHooksByEventAndMatcher, HOOK_FACTORY_TO_EVENT, mergeHooksJson, parseArgs, readExistingHooksJson, removeOldGeneratedFiles, validateArgs, };
|
package/dist/constants.js
CHANGED
|
@@ -14,9 +14,11 @@ export const HOOK_FACTORY_TO_EVENT = {
|
|
|
14
14
|
sessionStartHook: "SessionStart",
|
|
15
15
|
sessionEndHook: "SessionEnd",
|
|
16
16
|
stopHook: "Stop",
|
|
17
|
+
stopFailureHook: "StopFailure",
|
|
17
18
|
subagentStartHook: "SubagentStart",
|
|
18
19
|
subagentStopHook: "SubagentStop",
|
|
19
20
|
preCompactHook: "PreCompact",
|
|
21
|
+
postCompactHook: "PostCompact",
|
|
20
22
|
permissionRequestHook: "PermissionRequest",
|
|
21
23
|
setupHook: "Setup",
|
|
22
24
|
teammateIdleHook: "TeammateIdle",
|
package/dist/hooks.js
CHANGED
|
@@ -267,6 +267,39 @@ export function stopHook(config, handler) {
|
|
|
267
267
|
return createHookFunction("Stop", config, handler);
|
|
268
268
|
}
|
|
269
269
|
// ============================================================================
|
|
270
|
+
// StopFailure Hook Factory
|
|
271
|
+
// ============================================================================
|
|
272
|
+
/**
|
|
273
|
+
* Creates a StopFailure hook handler.
|
|
274
|
+
*
|
|
275
|
+
* StopFailure hooks fire when Claude Code encounters an error while stopping
|
|
276
|
+
* (e.g., API errors, authentication failures, rate limits), allowing you to:
|
|
277
|
+
* - Log stop failure events and error details
|
|
278
|
+
* - Alert on unexpected session termination errors
|
|
279
|
+
* - Observe what error caused the failure
|
|
280
|
+
*
|
|
281
|
+
* **Matcher**: No matcher support - fires on all stop failure events
|
|
282
|
+
* @param config - Hook configuration with optional timeout (matcher is ignored)
|
|
283
|
+
* @param handler - The handler function to execute
|
|
284
|
+
* @returns A hook function that can be exported as the default export
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* import { stopFailureHook, stopFailureOutput } from '@goodfoot/claude-code-hooks';
|
|
288
|
+
*
|
|
289
|
+
* export default stopFailureHook({}, async (input, { logger }) => {
|
|
290
|
+
* logger.error('Session stopped due to error', {
|
|
291
|
+
* error: input.error,
|
|
292
|
+
* details: input.error_details
|
|
293
|
+
* });
|
|
294
|
+
* return stopFailureOutput({});
|
|
295
|
+
* });
|
|
296
|
+
* ```
|
|
297
|
+
* @see https://code.claude.com/docs/en/hooks#stopfailure
|
|
298
|
+
*/
|
|
299
|
+
export function stopFailureHook(config, handler) {
|
|
300
|
+
return createHookFunction("StopFailure", config, handler);
|
|
301
|
+
}
|
|
302
|
+
// ============================================================================
|
|
270
303
|
// SubagentStart Hook Factory
|
|
271
304
|
// ============================================================================
|
|
272
305
|
/**
|
|
@@ -385,6 +418,38 @@ export function subagentStopHook(config, handler) {
|
|
|
385
418
|
export function preCompactHook(config, handler) {
|
|
386
419
|
return createHookFunction("PreCompact", config, handler);
|
|
387
420
|
}
|
|
421
|
+
// ============================================================================
|
|
422
|
+
// PostCompact Hook Factory
|
|
423
|
+
// ============================================================================
|
|
424
|
+
/**
|
|
425
|
+
* Creates a PostCompact hook handler.
|
|
426
|
+
*
|
|
427
|
+
* PostCompact hooks fire after context compaction completes, allowing you to:
|
|
428
|
+
* - Observe the compaction summary and details
|
|
429
|
+
* - Log compaction events
|
|
430
|
+
* - React to the new compacted state
|
|
431
|
+
*
|
|
432
|
+
* **Matcher**: Matches against `trigger` ('manual', 'auto')
|
|
433
|
+
* @param config - Hook configuration with optional matcher and timeout
|
|
434
|
+
* @param handler - The handler function to execute
|
|
435
|
+
* @returns A hook function that can be exported as the default export
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* import { postCompactHook, postCompactOutput } from '@goodfoot/claude-code-hooks';
|
|
439
|
+
*
|
|
440
|
+
* export default postCompactHook({}, async (input, { logger }) => {
|
|
441
|
+
* logger.info('Context compaction completed', {
|
|
442
|
+
* trigger: input.trigger,
|
|
443
|
+
* summary: input.compact_summary
|
|
444
|
+
* });
|
|
445
|
+
* return postCompactOutput({});
|
|
446
|
+
* });
|
|
447
|
+
* ```
|
|
448
|
+
* @see https://code.claude.com/docs/en/hooks#postcompact
|
|
449
|
+
*/
|
|
450
|
+
export function postCompactHook(config, handler) {
|
|
451
|
+
return createHookFunction("PostCompact", config, handler);
|
|
452
|
+
}
|
|
388
453
|
/** @inheritdoc */
|
|
389
454
|
export function permissionRequestHook(config, handler) {
|
|
390
455
|
return createHookFunction("PermissionRequest", config, handler);
|
package/dist/index.js
CHANGED
|
@@ -11,16 +11,16 @@ export {
|
|
|
11
11
|
CLAUDE_ENV_VARS, getEnvFilePath,
|
|
12
12
|
// Getters
|
|
13
13
|
getProjectDir, isRemoteEnvironment, } from "./env.js";
|
|
14
|
-
// Hook factory functions - all
|
|
15
|
-
export { configChangeHook, elicitationHook, elicitationResultHook, instructionsLoadedHook, notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
|
|
14
|
+
// Hook factory functions - all 23 hook types
|
|
15
|
+
export { configChangeHook, elicitationHook, elicitationResultHook, instructionsLoadedHook, notificationHook, permissionRequestHook, postCompactHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopFailureHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
|
|
16
16
|
// Logger exports
|
|
17
17
|
export { LOG_LEVELS, Logger, logger } from "./logger.js";
|
|
18
18
|
// Output builder functions
|
|
19
19
|
export { configChangeOutput,
|
|
20
20
|
// Exit codes
|
|
21
|
-
EXIT_CODES, elicitationOutput, elicitationResultOutput, instructionsLoadedOutput, notificationOutput, permissionRequestOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput,
|
|
22
|
-
// All
|
|
23
|
-
preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
|
|
21
|
+
EXIT_CODES, elicitationOutput, elicitationResultOutput, instructionsLoadedOutput, notificationOutput, permissionRequestOutput, postCompactOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput,
|
|
22
|
+
// All 23 output builder functions
|
|
23
|
+
preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopFailureOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
|
|
24
24
|
// Runtime exports - execute function
|
|
25
25
|
export {
|
|
26
26
|
// Main execute function for compiled hooks
|
package/dist/outputs.js
CHANGED
|
@@ -199,6 +199,16 @@ export const sessionEndOutput = /* @__PURE__ */ createSimpleOutputBuilder("Sessi
|
|
|
199
199
|
* ```
|
|
200
200
|
*/
|
|
201
201
|
export const stopOutput = /* @__PURE__ */ createDecisionOutputBuilder("Stop");
|
|
202
|
+
/**
|
|
203
|
+
* Creates an output for StopFailure hooks.
|
|
204
|
+
* @param options - Configuration options for the hook output
|
|
205
|
+
* @returns A StopFailureOutput object ready for the runtime
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* stopFailureOutput({});
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export const stopFailureOutput = /* @__PURE__ */ createSimpleOutputBuilder("StopFailure");
|
|
202
212
|
/**
|
|
203
213
|
* Creates an output for SubagentStart hooks.
|
|
204
214
|
* @param options - Configuration options for the hook output
|
|
@@ -257,6 +267,16 @@ export const notificationOutput = /* @__PURE__ */ createHookSpecificOutputBuilde
|
|
|
257
267
|
* ```
|
|
258
268
|
*/
|
|
259
269
|
export const preCompactOutput = /* @__PURE__ */ createSimpleOutputBuilder("PreCompact");
|
|
270
|
+
/**
|
|
271
|
+
* Creates an output for PostCompact hooks.
|
|
272
|
+
* @param options - Configuration options for the hook output
|
|
273
|
+
* @returns A PostCompactOutput object ready for the runtime
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* postCompactOutput({});
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
export const postCompactOutput = /* @__PURE__ */ createSimpleOutputBuilder("PostCompact");
|
|
260
280
|
/**
|
|
261
281
|
* Creates an output for PermissionRequest hooks.
|
|
262
282
|
* @param options - Configuration options for the hook output
|
package/dist/scaffold.js
CHANGED
|
@@ -45,9 +45,11 @@ const EVENT_TO_OUTPUT_FUNCTION = {
|
|
|
45
45
|
SessionStart: "sessionStartOutput",
|
|
46
46
|
SessionEnd: "sessionEndOutput",
|
|
47
47
|
Stop: "stopOutput",
|
|
48
|
+
StopFailure: "stopFailureOutput",
|
|
48
49
|
SubagentStart: "subagentStartOutput",
|
|
49
50
|
SubagentStop: "subagentStopOutput",
|
|
50
51
|
PreCompact: "preCompactOutput",
|
|
52
|
+
PostCompact: "postCompactOutput",
|
|
51
53
|
PermissionRequest: "permissionRequestOutput",
|
|
52
54
|
Setup: "setupOutput",
|
|
53
55
|
TeammateIdle: "teammateIdleOutput",
|
|
@@ -125,7 +127,7 @@ function generatePackageJson(projectName, outputPath) {
|
|
|
125
127
|
"@goodfoot/claude-code-hooks": "^1.0.9",
|
|
126
128
|
},
|
|
127
129
|
devDependencies: {
|
|
128
|
-
"@biomejs/biome": "2.4.
|
|
130
|
+
"@biomejs/biome": "2.4.8",
|
|
129
131
|
"@types/node": "^22.0.0",
|
|
130
132
|
typescript: "^5.9.3",
|
|
131
133
|
vitest: "^4.0.16",
|
|
@@ -168,7 +170,7 @@ function generateTsConfig() {
|
|
|
168
170
|
*/
|
|
169
171
|
function generateBiomeConfig() {
|
|
170
172
|
return `{
|
|
171
|
-
"$schema": "https://biomejs.dev/schemas/2.4.
|
|
173
|
+
"$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
|
|
172
174
|
"formatter": {
|
|
173
175
|
"enabled": true,
|
|
174
176
|
"indentStyle": "space",
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodfoot/claude-code-hooks",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Type-safe Claude Code hooks library with camelCase types and output builders",
|
|
5
5
|
"homepage": "https://github.com/goodfoot-io/marketplace/tree/main/packages/claude-code-hooks",
|
|
6
6
|
"repository": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"typescript": "^5.9.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
57
|
-
"@biomejs/biome": "2.4.
|
|
56
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.80",
|
|
57
|
+
"@biomejs/biome": "2.4.8",
|
|
58
58
|
"@types/node": "^24",
|
|
59
59
|
"ts-morph": "^25.0.0",
|
|
60
60
|
"tsx": "^4.20.3",
|
package/types/cli.d.ts
CHANGED
|
@@ -262,5 +262,5 @@ declare function extractPreservedHooks(existingHooksJson: HooksJson): Partial<Re
|
|
|
262
262
|
* @returns Merged HooksJson
|
|
263
263
|
*/
|
|
264
264
|
declare function mergeHooksJson(newHooksJson: HooksJson, preservedHooks: Partial<Record<HookEventName, MatcherEntry[]>>): HooksJson;
|
|
265
|
-
export {
|
|
266
|
-
export
|
|
265
|
+
export type { CliArgs, CompiledHook, HookConfig, HookMetadata, HooksJson, MatcherEntry };
|
|
266
|
+
export { analyzeHookFile, compileHook, detectHookContext, discoverHookFiles, extractPreservedHooks, generateCommandPath, generateContentHash, generateHooksJson, groupHooksByEventAndMatcher, HOOK_FACTORY_TO_EVENT, mergeHooksJson, parseArgs, readExistingHooksJson, removeOldGeneratedFiles, validateArgs, };
|
package/types/hooks.d.ts
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* @see https://code.claude.com/docs/en/hooks
|
|
23
23
|
*/
|
|
24
24
|
import type { Logger } from "./logger.js";
|
|
25
|
-
import type { ConfigChangeOutput, ElicitationOutput, ElicitationResultOutput, InstructionsLoadedOutput, NotificationOutput, PermissionRequestOutput, PostToolUseFailureOutput, PostToolUseOutput, PreCompactOutput, PreToolUseOutput, SessionEndOutput, SessionStartOutput, SetupOutput, SpecificHookOutput, StopOutput, SubagentStartOutput, SubagentStopOutput, TaskCompletedOutput, TeammateIdleOutput, UserPromptSubmitOutput, WorktreeCreateOutput, WorktreeRemoveOutput } from "./outputs.js";
|
|
26
|
-
import type { ConfigChangeInput, ElicitationInput, ElicitationResultInput, HookEventName, InstructionsLoadedInput, KnownToolName, NotificationInput, PermissionRequestInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseInput, SessionEndInput, SessionStartInput, SetupInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, WorktreeCreateInput, WorktreeRemoveInput } from "./types.js";
|
|
25
|
+
import type { ConfigChangeOutput, ElicitationOutput, ElicitationResultOutput, InstructionsLoadedOutput, NotificationOutput, PermissionRequestOutput, PostCompactOutput, PostToolUseFailureOutput, PostToolUseOutput, PreCompactOutput, PreToolUseOutput, SessionEndOutput, SessionStartOutput, SetupOutput, SpecificHookOutput, StopFailureOutput, StopOutput, SubagentStartOutput, SubagentStopOutput, TaskCompletedOutput, TeammateIdleOutput, UserPromptSubmitOutput, WorktreeCreateOutput, WorktreeRemoveOutput } from "./outputs.js";
|
|
26
|
+
import type { ConfigChangeInput, ElicitationInput, ElicitationResultInput, HookEventName, InstructionsLoadedInput, KnownToolName, NotificationInput, PermissionRequestInput, PostCompactInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseInput, SessionEndInput, SessionStartInput, SetupInput, StopFailureInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, WorktreeCreateInput, WorktreeRemoveInput } from "./types.js";
|
|
27
27
|
/**
|
|
28
28
|
* Configuration options for hook factories.
|
|
29
29
|
*
|
|
@@ -612,6 +612,34 @@ export declare function sessionEndHook(config: HookConfig, handler: HookHandler<
|
|
|
612
612
|
* @see https://code.claude.com/docs/en/hooks#stop
|
|
613
613
|
*/
|
|
614
614
|
export declare function stopHook(config: HookConfig, handler: HookHandler<StopInput, StopOutput>): HookFunction<StopInput, StopOutput>;
|
|
615
|
+
/**
|
|
616
|
+
* Creates a StopFailure hook handler.
|
|
617
|
+
*
|
|
618
|
+
* StopFailure hooks fire when Claude Code encounters an error while stopping
|
|
619
|
+
* (e.g., API errors, authentication failures, rate limits), allowing you to:
|
|
620
|
+
* - Log stop failure events and error details
|
|
621
|
+
* - Alert on unexpected session termination errors
|
|
622
|
+
* - Observe what error caused the failure
|
|
623
|
+
*
|
|
624
|
+
* **Matcher**: No matcher support - fires on all stop failure events
|
|
625
|
+
* @param config - Hook configuration with optional timeout (matcher is ignored)
|
|
626
|
+
* @param handler - The handler function to execute
|
|
627
|
+
* @returns A hook function that can be exported as the default export
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* import { stopFailureHook, stopFailureOutput } from '@goodfoot/claude-code-hooks';
|
|
631
|
+
*
|
|
632
|
+
* export default stopFailureHook({}, async (input, { logger }) => {
|
|
633
|
+
* logger.error('Session stopped due to error', {
|
|
634
|
+
* error: input.error,
|
|
635
|
+
* details: input.error_details
|
|
636
|
+
* });
|
|
637
|
+
* return stopFailureOutput({});
|
|
638
|
+
* });
|
|
639
|
+
* ```
|
|
640
|
+
* @see https://code.claude.com/docs/en/hooks#stopfailure
|
|
641
|
+
*/
|
|
642
|
+
export declare function stopFailureHook(config: HookConfig, handler: HookHandler<StopFailureInput, StopFailureOutput>): HookFunction<StopFailureInput, StopFailureOutput>;
|
|
615
643
|
/**
|
|
616
644
|
* Creates a SubagentStart hook handler.
|
|
617
645
|
*
|
|
@@ -716,6 +744,33 @@ export declare function subagentStopHook(config: HookConfig, handler: HookHandle
|
|
|
716
744
|
* @see https://code.claude.com/docs/en/hooks#precompact
|
|
717
745
|
*/
|
|
718
746
|
export declare function preCompactHook(config: HookConfig, handler: HookHandler<PreCompactInput, PreCompactOutput>): HookFunction<PreCompactInput, PreCompactOutput>;
|
|
747
|
+
/**
|
|
748
|
+
* Creates a PostCompact hook handler.
|
|
749
|
+
*
|
|
750
|
+
* PostCompact hooks fire after context compaction completes, allowing you to:
|
|
751
|
+
* - Observe the compaction summary and details
|
|
752
|
+
* - Log compaction events
|
|
753
|
+
* - React to the new compacted state
|
|
754
|
+
*
|
|
755
|
+
* **Matcher**: Matches against `trigger` ('manual', 'auto')
|
|
756
|
+
* @param config - Hook configuration with optional matcher and timeout
|
|
757
|
+
* @param handler - The handler function to execute
|
|
758
|
+
* @returns A hook function that can be exported as the default export
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* import { postCompactHook, postCompactOutput } from '@goodfoot/claude-code-hooks';
|
|
762
|
+
*
|
|
763
|
+
* export default postCompactHook({}, async (input, { logger }) => {
|
|
764
|
+
* logger.info('Context compaction completed', {
|
|
765
|
+
* trigger: input.trigger,
|
|
766
|
+
* summary: input.compact_summary
|
|
767
|
+
* });
|
|
768
|
+
* return postCompactOutput({});
|
|
769
|
+
* });
|
|
770
|
+
* ```
|
|
771
|
+
* @see https://code.claude.com/docs/en/hooks#postcompact
|
|
772
|
+
*/
|
|
773
|
+
export declare function postCompactHook(config: HookConfig, handler: HookHandler<PostCompactInput, PostCompactOutput>): HookFunction<PostCompactInput, PostCompactOutput>;
|
|
719
774
|
/**
|
|
720
775
|
* Creates a PermissionRequest hook handler.
|
|
721
776
|
*
|
package/types/index.d.ts
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
export type * from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
|
9
9
|
export { CLAUDE_ENV_VARS, getEnvFilePath, getProjectDir, isRemoteEnvironment, } from "./env.js";
|
|
10
10
|
export type { HookConfig, HookContext, HookFunction, HookHandler, SessionStartContext, TypedHookConfig, TypedPermissionRequestInput, TypedPostToolUseFailureHookInput, TypedPostToolUseHookInput, TypedPreToolUseHookInput, } from "./hooks.js";
|
|
11
|
-
export { configChangeHook, elicitationHook, elicitationResultHook, instructionsLoadedHook, notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
|
|
11
|
+
export { configChangeHook, elicitationHook, elicitationResultHook, instructionsLoadedHook, notificationHook, permissionRequestHook, postCompactHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopFailureHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
|
|
12
12
|
export type { LogEvent, LogEventError, LogEventHandler, LoggerConfig, LogLevel, Unsubscribe } from "./logger.js";
|
|
13
13
|
export { LOG_LEVELS, Logger, logger } from "./logger.js";
|
|
14
14
|
export type {
|
|
15
15
|
/** @deprecated Use CommonOptions instead */
|
|
16
|
-
BaseOptions, CommonOptions, ConfigChangeOptions, ElicitationHookSpecificOutput, ElicitationOptions, ElicitationResultHookSpecificOutput, ElicitationResultOptions, ExitCode, ExitCodeOptions, HookOutput, HookSpecificOutput, InstructionsLoadedOptions, NotificationHookSpecificOutput, NotificationOptions, PermissionRequestAllowDecision, PermissionRequestDecision, PermissionRequestDenyDecision, PermissionRequestHookSpecificOutput, PermissionRequestOptions, PostToolUseFailureHookSpecificOutput, PostToolUseFailureOptions, PostToolUseHookSpecificOutput, PostToolUseOptions, PreCompactOptions, PreToolUseHookSpecificOutput, PreToolUseOptions, SessionEndOptions, SessionStartHookSpecificOutput, SessionStartOptions, SetupHookSpecificOutput, SetupOptions, StopOptions, SubagentStartHookSpecificOutput, SubagentStartOptions, SubagentStopOptions, SyncHookJSONOutput, TaskCompletedOptions, TeammateIdleOptions, UserPromptSubmitHookSpecificOutput, UserPromptSubmitOptions, WorktreeCreateOptions, WorktreeRemoveOptions, } from "./outputs.js";
|
|
17
|
-
export { configChangeOutput, EXIT_CODES, elicitationOutput, elicitationResultOutput, instructionsLoadedOutput, notificationOutput, permissionRequestOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
|
|
16
|
+
BaseOptions, CommonOptions, ConfigChangeOptions, ElicitationHookSpecificOutput, ElicitationOptions, ElicitationResultHookSpecificOutput, ElicitationResultOptions, ExitCode, ExitCodeOptions, HookOutput, HookSpecificOutput, InstructionsLoadedOptions, NotificationHookSpecificOutput, NotificationOptions, PermissionRequestAllowDecision, PermissionRequestDecision, PermissionRequestDenyDecision, PermissionRequestHookSpecificOutput, PermissionRequestOptions, PostCompactOptions, PostToolUseFailureHookSpecificOutput, PostToolUseFailureOptions, PostToolUseHookSpecificOutput, PostToolUseOptions, PreCompactOptions, PreToolUseHookSpecificOutput, PreToolUseOptions, SessionEndOptions, SessionStartHookSpecificOutput, SessionStartOptions, SetupHookSpecificOutput, SetupOptions, StopFailureOptions, StopOptions, SubagentStartHookSpecificOutput, SubagentStartOptions, SubagentStopOptions, SyncHookJSONOutput, TaskCompletedOptions, TeammateIdleOptions, UserPromptSubmitHookSpecificOutput, UserPromptSubmitOptions, WorktreeCreateOptions, WorktreeRemoveOptions, } from "./outputs.js";
|
|
17
|
+
export { configChangeOutput, EXIT_CODES, elicitationOutput, elicitationResultOutput, instructionsLoadedOutput, notificationOutput, permissionRequestOutput, postCompactOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopFailureOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
|
|
18
18
|
export { execute, } from "./runtime.js";
|
|
19
19
|
export type { ContentContext, PatternCheckResult, ToolUseInput } from "./tool-helpers.js";
|
|
20
20
|
export { checkContentForPattern, forEachContent, getFilePath, isAskUserQuestionTool, isBashTool, isConfigTool, isEditTool, isExitPlanModeTool, isFileModifyingTool, isGlobTool, isGrepTool, isJsTsFile, isKillShellTool, isListMcpResourcesTool, isMcpTool, isMultiEditTool, isNotebookEditTool, isReadMcpResourceTool, isReadTool, isTaskOutputTool, isTaskTool, isTodoWriteTool, isTsFile, isWebFetchTool, isWebSearchTool, isWriteTool, } from "./tool-helpers.js";
|
|
21
|
-
export type { BaseHookInput, ConfigChangeInput, ConfigInput, ElicitationInput, ElicitationResultInput, FileModifyingToolInput, FileModifyingToolName, HookEventName, HookInput, InstructionsLoadedInput, KnownToolInput, KnownToolName, ListMcpResourcesInput, McpInput, MultiEditEntry, MultiEditToolInput, NotificationInput, PermissionMode, PermissionRequestInput, PermissionUpdate, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreCompactTrigger, PreToolUseInput, ReadMcpResourceInput, SessionEndInput, SessionEndReason, SessionStartInput, SessionStartSource, SetupInput, SetupTrigger, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, WorktreeCreateInput, WorktreeRemoveInput, } from "./types.js";
|
|
21
|
+
export type { BaseHookInput, ConfigChangeInput, ConfigInput, ElicitationInput, ElicitationResultInput, FileModifyingToolInput, FileModifyingToolName, HookEventName, HookInput, InstructionsLoadedInput, KnownToolInput, KnownToolName, ListMcpResourcesInput, McpInput, MultiEditEntry, MultiEditToolInput, NotificationInput, PermissionMode, PermissionRequestInput, PermissionUpdate, PostCompactInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreCompactTrigger, PreToolUseInput, ReadMcpResourceInput, SessionEndInput, SessionEndReason, SessionStartInput, SessionStartSource, SetupInput, SetupTrigger, StopFailureInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, WorktreeCreateInput, WorktreeRemoveInput, } from "./types.js";
|
|
22
22
|
export { HOOK_EVENT_NAMES } from "./types.js";
|
package/types/outputs.d.ts
CHANGED
|
@@ -33,11 +33,10 @@ export type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];
|
|
|
33
33
|
/**
|
|
34
34
|
* Re-export the SDK's SyncHookJSONOutput type.
|
|
35
35
|
*/
|
|
36
|
-
export type { SDKSyncHookJSONOutput };
|
|
37
36
|
/**
|
|
38
37
|
* Re-export SDK hook-specific output types (includes hookEventName discriminator).
|
|
39
38
|
*/
|
|
40
|
-
export type { SDKElicitationHookSpecificOutput, SDKElicitationResultHookSpecificOutput, SDKNotificationHookSpecificOutput,
|
|
39
|
+
export type { SDKElicitationHookSpecificOutput, SDKElicitationResultHookSpecificOutput, SDKNotificationHookSpecificOutput, SDKPermissionRequestHookSpecificOutput, SDKPostToolUseFailureHookSpecificOutput, SDKPostToolUseHookSpecificOutput, SDKPreToolUseHookSpecificOutput, SDKSessionStartHookSpecificOutput, SDKSetupHookSpecificOutput, SDKSubagentStartHookSpecificOutput, SDKSyncHookJSONOutput, SDKUserPromptSubmitHookSpecificOutput, };
|
|
41
40
|
/**
|
|
42
41
|
* PreToolUse hook-specific output fields.
|
|
43
42
|
* Omits `hookEventName` which is added automatically by the builder.
|
|
@@ -211,6 +210,10 @@ export type SessionEndOutput = BaseSpecificOutput<"SessionEnd">;
|
|
|
211
210
|
*
|
|
212
211
|
*/
|
|
213
212
|
export type StopOutput = BaseSpecificOutput<"Stop">;
|
|
213
|
+
/**
|
|
214
|
+
*
|
|
215
|
+
*/
|
|
216
|
+
export type StopFailureOutput = BaseSpecificOutput<"StopFailure">;
|
|
214
217
|
/**
|
|
215
218
|
*
|
|
216
219
|
*/
|
|
@@ -223,6 +226,10 @@ export type SubagentStopOutput = BaseSpecificOutput<"SubagentStop">;
|
|
|
223
226
|
*
|
|
224
227
|
*/
|
|
225
228
|
export type PreCompactOutput = BaseSpecificOutput<"PreCompact">;
|
|
229
|
+
/**
|
|
230
|
+
*
|
|
231
|
+
*/
|
|
232
|
+
export type PostCompactOutput = BaseSpecificOutput<"PostCompact">;
|
|
226
233
|
/**
|
|
227
234
|
*
|
|
228
235
|
*/
|
|
@@ -266,7 +273,7 @@ export type WorktreeRemoveOutput = BaseSpecificOutput<"WorktreeRemove">;
|
|
|
266
273
|
/**
|
|
267
274
|
* Union of all specific output types.
|
|
268
275
|
*/
|
|
269
|
-
export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PermissionRequestOutput | SetupOutput | TeammateIdleOutput | TaskCompletedOutput | ElicitationOutput | ElicitationResultOutput | ConfigChangeOutput | InstructionsLoadedOutput | WorktreeCreateOutput | WorktreeRemoveOutput;
|
|
276
|
+
export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | StopFailureOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PostCompactOutput | PermissionRequestOutput | SetupOutput | TeammateIdleOutput | TaskCompletedOutput | ElicitationOutput | ElicitationResultOutput | ConfigChangeOutput | InstructionsLoadedOutput | WorktreeCreateOutput | WorktreeRemoveOutput;
|
|
270
277
|
/**
|
|
271
278
|
* Options for decision-based hooks (Stop, SubagentStop).
|
|
272
279
|
*/
|
|
@@ -470,6 +477,24 @@ export declare const stopOutput: (options?: DecisionOptions) => {
|
|
|
470
477
|
readonly _type: "Stop";
|
|
471
478
|
stdout: SyncHookJSONOutput;
|
|
472
479
|
};
|
|
480
|
+
/**
|
|
481
|
+
* Options for the StopFailure output builder.
|
|
482
|
+
* StopFailure hooks only support common options.
|
|
483
|
+
*/
|
|
484
|
+
export type StopFailureOptions = CommonOptions;
|
|
485
|
+
/**
|
|
486
|
+
* Creates an output for StopFailure hooks.
|
|
487
|
+
* @param options - Configuration options for the hook output
|
|
488
|
+
* @returns A StopFailureOutput object ready for the runtime
|
|
489
|
+
* @example
|
|
490
|
+
* ```typescript
|
|
491
|
+
* stopFailureOutput({});
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
494
|
+
export declare const stopFailureOutput: (options?: CommonOptions) => {
|
|
495
|
+
readonly _type: "StopFailure";
|
|
496
|
+
stdout: SyncHookJSONOutput;
|
|
497
|
+
};
|
|
473
498
|
/**
|
|
474
499
|
* Options for the SubagentStart output builder.
|
|
475
500
|
*/
|
|
@@ -572,6 +597,24 @@ export declare const preCompactOutput: (options?: CommonOptions) => {
|
|
|
572
597
|
readonly _type: "PreCompact";
|
|
573
598
|
stdout: SyncHookJSONOutput;
|
|
574
599
|
};
|
|
600
|
+
/**
|
|
601
|
+
* Options for the PostCompact output builder.
|
|
602
|
+
* PostCompact hooks only support common options.
|
|
603
|
+
*/
|
|
604
|
+
export type PostCompactOptions = CommonOptions;
|
|
605
|
+
/**
|
|
606
|
+
* Creates an output for PostCompact hooks.
|
|
607
|
+
* @param options - Configuration options for the hook output
|
|
608
|
+
* @returns A PostCompactOutput object ready for the runtime
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* postCompactOutput({});
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
export declare const postCompactOutput: (options?: CommonOptions) => {
|
|
615
|
+
readonly _type: "PostCompact";
|
|
616
|
+
stdout: SyncHookJSONOutput;
|
|
617
|
+
};
|
|
575
618
|
/**
|
|
576
619
|
* Options for the PermissionRequest output builder.
|
|
577
620
|
*/
|
package/types/types.d.ts
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* Re-exports types from @anthropic-ai/claude-agent-sdk with "SDK" prefix.
|
|
13
13
|
* These are used as base types for extension, ensuring synchronization with the SDK.
|
|
14
14
|
*/
|
|
15
|
-
export type { BaseHookInput as SDKBaseHookInput, ConfigChangeHookInput as SDKConfigChangeHookInput, ElicitationHookInput as SDKElicitationHookInput, ElicitationResultHookInput as SDKElicitationResultHookInput, HookEvent as SDKHookEvent, HookInput as SDKHookInput, InstructionsLoadedHookInput as SDKInstructionsLoadedHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, WorktreeCreateHookInput as SDKWorktreeCreateHookInput, WorktreeRemoveHookInput as SDKWorktreeRemoveHookInput, } from "@anthropic-ai/claude-agent-sdk";
|
|
16
|
-
import type { BaseHookInput as SDKBaseHookInput, ConfigChangeHookInput as SDKConfigChangeHookInput, ElicitationHookInput as SDKElicitationHookInput, ElicitationResultHookInput as SDKElicitationResultHookInput, InstructionsLoadedHookInput as SDKInstructionsLoadedHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, WorktreeCreateHookInput as SDKWorktreeCreateHookInput, WorktreeRemoveHookInput as SDKWorktreeRemoveHookInput } from "@anthropic-ai/claude-agent-sdk";
|
|
15
|
+
export type { BaseHookInput as SDKBaseHookInput, ConfigChangeHookInput as SDKConfigChangeHookInput, ElicitationHookInput as SDKElicitationHookInput, ElicitationResultHookInput as SDKElicitationResultHookInput, HookEvent as SDKHookEvent, HookInput as SDKHookInput, InstructionsLoadedHookInput as SDKInstructionsLoadedHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostCompactHookInput as SDKPostCompactHookInput, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopFailureHookInput as SDKStopFailureHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, WorktreeCreateHookInput as SDKWorktreeCreateHookInput, WorktreeRemoveHookInput as SDKWorktreeRemoveHookInput, } from "@anthropic-ai/claude-agent-sdk";
|
|
16
|
+
import type { BaseHookInput as SDKBaseHookInput, ConfigChangeHookInput as SDKConfigChangeHookInput, ElicitationHookInput as SDKElicitationHookInput, ElicitationResultHookInput as SDKElicitationResultHookInput, InstructionsLoadedHookInput as SDKInstructionsLoadedHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostCompactHookInput as SDKPostCompactHookInput, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopFailureHookInput as SDKStopFailureHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, WorktreeCreateHookInput as SDKWorktreeCreateHookInput, WorktreeRemoveHookInput as SDKWorktreeRemoveHookInput } from "@anthropic-ai/claude-agent-sdk";
|
|
17
17
|
import type { AgentInput, AskUserQuestionInput, BashInput, ConfigInput, ExitPlanModeInput, FileEditInput, FileReadInput, FileWriteInput, GlobInput, GrepInput, TaskStopInput as KillShellInput, ListMcpResourcesInput, McpInput, NotebookEditInput, ReadMcpResourceInput, TaskOutputInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
|
18
18
|
/**
|
|
19
19
|
* Permission mode for controlling how tool executions are handled.
|
|
@@ -42,6 +42,7 @@ export type PreCompactTrigger = "manual" | "auto";
|
|
|
42
42
|
* Reason for session end events.
|
|
43
43
|
*
|
|
44
44
|
* - `'clear'` - Session cleared by user
|
|
45
|
+
* - `'resume'` - Session resumed from a previous session
|
|
45
46
|
* - `'logout'` - User logged out
|
|
46
47
|
* - `'prompt_input_exit'` - User exited at prompt input
|
|
47
48
|
* - `'other'` - Other reasons
|
|
@@ -49,7 +50,7 @@ export type PreCompactTrigger = "manual" | "auto";
|
|
|
49
50
|
*
|
|
50
51
|
* Note: SDK's ExitReason resolves to string. This type provides concrete literals for better DX.
|
|
51
52
|
*/
|
|
52
|
-
export type SessionEndReason = "clear" | "logout" | "prompt_input_exit" | "other" | "bypass_permissions_disabled";
|
|
53
|
+
export type SessionEndReason = "clear" | "resume" | "logout" | "prompt_input_exit" | "other" | "bypass_permissions_disabled";
|
|
53
54
|
/**
|
|
54
55
|
* Common fields present in all hook inputs.
|
|
55
56
|
*
|
|
@@ -123,6 +124,18 @@ export type SessionStartInput = {
|
|
|
123
124
|
export type StopInput = {
|
|
124
125
|
[K in keyof SDKStopHookInput]: SDKStopHookInput[K];
|
|
125
126
|
} & {};
|
|
127
|
+
/**
|
|
128
|
+
* Input for StopFailure hooks.
|
|
129
|
+
*
|
|
130
|
+
* Fires when Claude Code encounters an error while stopping (e.g., API errors,
|
|
131
|
+
* rate limits, authentication failures), allowing you to:
|
|
132
|
+
* - Log stop failure events and error details
|
|
133
|
+
* - Alert on unexpected session termination errors
|
|
134
|
+
* @see https://code.claude.com/docs/en/hooks#stopfailure
|
|
135
|
+
*/
|
|
136
|
+
export type StopFailureInput = {
|
|
137
|
+
[K in keyof SDKStopFailureHookInput]: SDKStopFailureHookInput[K];
|
|
138
|
+
} & {};
|
|
126
139
|
/**
|
|
127
140
|
* Input for SubagentStart hooks.
|
|
128
141
|
* @see https://code.claude.com/docs/en/hooks#subagentstart
|
|
@@ -144,6 +157,18 @@ export type SubagentStopInput = {
|
|
|
144
157
|
export type PreCompactInput = {
|
|
145
158
|
[K in keyof SDKPreCompactHookInput]: SDKPreCompactHookInput[K];
|
|
146
159
|
} & {};
|
|
160
|
+
/**
|
|
161
|
+
* Input for PostCompact hooks.
|
|
162
|
+
*
|
|
163
|
+
* Fires after context compaction completes, allowing you to:
|
|
164
|
+
* - Observe the compaction summary
|
|
165
|
+
* - Log compaction events with context details
|
|
166
|
+
* - React to the new compacted state
|
|
167
|
+
* @see https://code.claude.com/docs/en/hooks#postcompact
|
|
168
|
+
*/
|
|
169
|
+
export type PostCompactInput = {
|
|
170
|
+
[K in keyof SDKPostCompactHookInput]: SDKPostCompactHookInput[K];
|
|
171
|
+
} & {};
|
|
147
172
|
/**
|
|
148
173
|
* Input for Setup hooks.
|
|
149
174
|
* @see https://code.claude.com/docs/en/hooks#setup
|
|
@@ -327,7 +352,7 @@ export type SetupTrigger = "init" | "maintenance";
|
|
|
327
352
|
* ```
|
|
328
353
|
* @see https://code.claude.com/docs/en/hooks
|
|
329
354
|
*/
|
|
330
|
-
export type HookInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | NotificationInput | UserPromptSubmitInput | SessionStartInput | SessionEndInput | StopInput | SubagentStartInput | SubagentStopInput | PreCompactInput | PermissionRequestInput | SetupInput | TeammateIdleInput | TaskCompletedInput | ElicitationInput | ElicitationResultInput | ConfigChangeInput | InstructionsLoadedInput | WorktreeCreateInput | WorktreeRemoveInput;
|
|
355
|
+
export type HookInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | NotificationInput | UserPromptSubmitInput | SessionStartInput | SessionEndInput | StopInput | StopFailureInput | SubagentStartInput | SubagentStopInput | PreCompactInput | PostCompactInput | PermissionRequestInput | SetupInput | TeammateIdleInput | TaskCompletedInput | ElicitationInput | ElicitationResultInput | ConfigChangeInput | InstructionsLoadedInput | WorktreeCreateInput | WorktreeRemoveInput;
|
|
331
356
|
/**
|
|
332
357
|
* Hook event name literal union.
|
|
333
358
|
*
|
|
@@ -345,7 +370,7 @@ export type HookEventName = HookInput["hook_event_name"];
|
|
|
345
370
|
* }
|
|
346
371
|
* ```
|
|
347
372
|
*/
|
|
348
|
-
export declare const HOOK_EVENT_NAMES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest", "Setup", "TeammateIdle", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "InstructionsLoaded", "WorktreeCreate", "WorktreeRemove"];
|
|
373
|
+
export declare const HOOK_EVENT_NAMES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "Setup", "TeammateIdle", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "InstructionsLoaded", "WorktreeCreate", "WorktreeRemove"];
|
|
349
374
|
export type { SDKPermissionUpdate as PermissionUpdate };
|
|
350
375
|
/**
|
|
351
376
|
* Re-export all tool input types from the official Claude Agent SDK.
|