@goodfoot/claude-code-hooks 1.0.20 → 1.0.21

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/index.js CHANGED
@@ -34,9 +34,13 @@ getFilePath,
34
34
  // Type guards - User interaction
35
35
  isAskUserQuestionTool,
36
36
  // Type guards - Commands
37
- isBashTool, isEditTool, isExitPlanModeTool, isFileModifyingTool,
37
+ isBashTool,
38
+ // Type guards - Config
39
+ isConfigTool, isEditTool, isExitPlanModeTool, isFileModifyingTool,
38
40
  // Type guards - Search
39
- isGlobTool, isGrepTool, isJsTsFile, isKillShellTool, isMultiEditTool, isNotebookEditTool, isReadTool, isTaskOutputTool,
41
+ isGlobTool, isGrepTool, isJsTsFile, isKillShellTool,
42
+ // Type guards - MCP
43
+ isListMcpResourcesTool, isMcpTool, isMultiEditTool, isNotebookEditTool, isReadMcpResourceTool, isReadTool, isTaskOutputTool,
40
44
  // Type guards - Agents
41
45
  isTaskTool, isTodoWriteTool, isTsFile,
42
46
  // Type guards - Web
@@ -321,6 +321,72 @@ export function isWebSearchTool(input) {
321
321
  export function isAskUserQuestionTool(input) {
322
322
  return input.tool_name === "AskUserQuestion";
323
323
  }
324
+ /**
325
+ * Type guard for ListMcpResources tool inputs.
326
+ *
327
+ * Narrows the input type to include a typed ListMcpResourcesInput.
328
+ * @param input - The hook input to check
329
+ * @returns True if the input is for a ListMcpResources tool
330
+ * @example
331
+ * ```typescript
332
+ * if (isListMcpResourcesTool(input)) {
333
+ * console.log(input.tool_input.server);
334
+ * }
335
+ * ```
336
+ */
337
+ export function isListMcpResourcesTool(input) {
338
+ return input.tool_name === "ListMcpResources";
339
+ }
340
+ /**
341
+ * Type guard for Mcp tool inputs.
342
+ *
343
+ * Narrows the input type to include a typed McpInput.
344
+ * @param input - The hook input to check
345
+ * @returns True if the input is for an Mcp tool
346
+ * @example
347
+ * ```typescript
348
+ * if (isMcpTool(input)) {
349
+ * // input.tool_input is now typed as McpInput
350
+ * }
351
+ * ```
352
+ */
353
+ export function isMcpTool(input) {
354
+ return input.tool_name === "Mcp";
355
+ }
356
+ /**
357
+ * Type guard for ReadMcpResource tool inputs.
358
+ *
359
+ * Narrows the input type to include a typed ReadMcpResourceInput.
360
+ * @param input - The hook input to check
361
+ * @returns True if the input is for a ReadMcpResource tool
362
+ * @example
363
+ * ```typescript
364
+ * if (isReadMcpResourceTool(input)) {
365
+ * console.log(input.tool_input.server);
366
+ * console.log(input.tool_input.uri);
367
+ * }
368
+ * ```
369
+ */
370
+ export function isReadMcpResourceTool(input) {
371
+ return input.tool_name === "ReadMcpResource";
372
+ }
373
+ /**
374
+ * Type guard for Config tool inputs.
375
+ *
376
+ * Narrows the input type to include a typed ConfigInput.
377
+ * @param input - The hook input to check
378
+ * @returns True if the input is for a Config tool
379
+ * @example
380
+ * ```typescript
381
+ * if (isConfigTool(input)) {
382
+ * console.log(input.tool_input.setting);
383
+ * console.log(input.tool_input.value);
384
+ * }
385
+ * ```
386
+ */
387
+ export function isConfigTool(input) {
388
+ return input.tool_name === "Config";
389
+ }
324
390
  // ============================================================================
325
391
  // File Path Utilities
326
392
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodfoot/claude-code-hooks",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
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,7 +53,7 @@
53
53
  "typescript": "^5.9.3"
54
54
  },
55
55
  "devDependencies": {
56
- "@anthropic-ai/claude-agent-sdk": "^0.2.37",
56
+ "@anthropic-ai/claude-agent-sdk": "^0.2.39",
57
57
  "@biomejs/biome": "2.3.14",
58
58
  "@types/node": "^24",
59
59
  "ts-morph": "^25.0.0",
package/types/hooks.d.ts CHANGED
@@ -136,37 +136,49 @@ export interface TypedHookConfig<T extends KnownToolName> {
136
136
  timeout?: number;
137
137
  }
138
138
  /**
139
- * PreToolUseInput with typed tool_input for a specific tool.
139
+ * PreToolUseHookInput with typed tool_input for a specific tool.
140
140
  * @template T - The known tool name
141
141
  */
142
- export type TypedPreToolUseInput<T extends KnownToolName> = Omit<PreToolUseInput, "tool_name" | "tool_input"> & {
142
+ type _TypedPreToolUseHookInputBase<T extends KnownToolName> = Omit<PreToolUseInput, "tool_name" | "tool_input"> & {
143
143
  tool_name: T;
144
144
  tool_input: ToolInputMap[T];
145
145
  };
146
+ export type TypedPreToolUseHookInput<T extends KnownToolName> = {
147
+ [K in keyof _TypedPreToolUseHookInputBase<T>]: _TypedPreToolUseHookInputBase<T>[K];
148
+ } & {};
146
149
  /**
147
- * PostToolUseInput with typed tool_input for a specific tool.
150
+ * PostToolUseHookInput with typed tool_input for a specific tool.
148
151
  * @template T - The known tool name
149
152
  */
150
- export type TypedPostToolUseInput<T extends KnownToolName> = Omit<PostToolUseInput, "tool_name" | "tool_input"> & {
153
+ type _TypedPostToolUseHookInputBase<T extends KnownToolName> = Omit<PostToolUseInput, "tool_name" | "tool_input"> & {
151
154
  tool_name: T;
152
155
  tool_input: ToolInputMap[T];
153
156
  };
157
+ export type TypedPostToolUseHookInput<T extends KnownToolName> = {
158
+ [K in keyof _TypedPostToolUseHookInputBase<T>]: _TypedPostToolUseHookInputBase<T>[K];
159
+ } & {};
154
160
  /**
155
- * PostToolUseFailureInput with typed tool_input for a specific tool.
161
+ * PostToolUseFailureHookInput with typed tool_input for a specific tool.
156
162
  * @template T - The known tool name
157
163
  */
158
- export type TypedPostToolUseFailureInput<T extends KnownToolName> = Omit<PostToolUseFailureInput, "tool_name" | "tool_input"> & {
164
+ type _TypedPostToolUseFailureHookInputBase<T extends KnownToolName> = Omit<PostToolUseFailureInput, "tool_name" | "tool_input"> & {
159
165
  tool_name: T;
160
166
  tool_input: ToolInputMap[T];
161
167
  };
168
+ export type TypedPostToolUseFailureHookInput<T extends KnownToolName> = {
169
+ [K in keyof _TypedPostToolUseFailureHookInputBase<T>]: _TypedPostToolUseFailureHookInputBase<T>[K];
170
+ } & {};
162
171
  /**
163
172
  * PermissionRequestInput with typed tool_input for a specific tool.
164
173
  * @template T - The known tool name
165
174
  */
166
- export type TypedPermissionRequestInput<T extends KnownToolName> = Omit<PermissionRequestInput, "tool_name" | "tool_input"> & {
175
+ type _TypedPermissionRequestInputBase<T extends KnownToolName> = Omit<PermissionRequestInput, "tool_name" | "tool_input"> & {
167
176
  tool_name: T;
168
177
  tool_input: ToolInputMap[T];
169
178
  };
179
+ export type TypedPermissionRequestInput<T extends KnownToolName> = {
180
+ [K in keyof _TypedPermissionRequestInputBase<T>]: _TypedPermissionRequestInputBase<T>[K];
181
+ } & {};
170
182
  /**
171
183
  * Context provided to hook handlers.
172
184
  *
@@ -343,7 +355,7 @@ export interface HookFunction<TInput, TOutput extends SpecificHookOutput, TConte
343
355
  * ```
344
356
  * @see https://code.claude.com/docs/en/hooks#pretooluse
345
357
  */
346
- export declare function preToolUseHook<T extends KnownToolName>(config: TypedHookConfig<T>, handler: HookHandler<TypedPreToolUseInput<T>, PreToolUseOutput>): HookFunction<TypedPreToolUseInput<T>, PreToolUseOutput>;
358
+ export declare function preToolUseHook<T extends KnownToolName>(config: TypedHookConfig<T>, handler: HookHandler<TypedPreToolUseHookInput<T>, PreToolUseOutput>): HookFunction<TypedPreToolUseHookInput<T>, PreToolUseOutput>;
347
359
  export declare function preToolUseHook(config: HookConfig, handler: HookHandler<PreToolUseInput, PreToolUseOutput>): HookFunction<PreToolUseInput, PreToolUseOutput>;
348
360
  /**
349
361
  * Creates a PostToolUse hook handler.
@@ -378,7 +390,7 @@ export declare function preToolUseHook(config: HookConfig, handler: HookHandler<
378
390
  * ```
379
391
  * @see https://code.claude.com/docs/en/hooks#posttooluse
380
392
  */
381
- export declare function postToolUseHook<T extends KnownToolName>(config: TypedHookConfig<T>, handler: HookHandler<TypedPostToolUseInput<T>, PostToolUseOutput>): HookFunction<TypedPostToolUseInput<T>, PostToolUseOutput>;
393
+ export declare function postToolUseHook<T extends KnownToolName>(config: TypedHookConfig<T>, handler: HookHandler<TypedPostToolUseHookInput<T>, PostToolUseOutput>): HookFunction<TypedPostToolUseHookInput<T>, PostToolUseOutput>;
382
394
  export declare function postToolUseHook(config: HookConfig, handler: HookHandler<PostToolUseInput, PostToolUseOutput>): HookFunction<PostToolUseInput, PostToolUseOutput>;
383
395
  /**
384
396
  * Creates a PostToolUseFailure hook handler.
@@ -416,7 +428,7 @@ export declare function postToolUseHook(config: HookConfig, handler: HookHandler
416
428
  * ```
417
429
  * @see https://code.claude.com/docs/en/hooks#posttoolusefailure
418
430
  */
419
- export declare function postToolUseFailureHook<T extends KnownToolName>(config: TypedHookConfig<T>, handler: HookHandler<TypedPostToolUseFailureInput<T>, PostToolUseFailureOutput>): HookFunction<TypedPostToolUseFailureInput<T>, PostToolUseFailureOutput>;
431
+ export declare function postToolUseFailureHook<T extends KnownToolName>(config: TypedHookConfig<T>, handler: HookHandler<TypedPostToolUseFailureHookInput<T>, PostToolUseFailureOutput>): HookFunction<TypedPostToolUseFailureHookInput<T>, PostToolUseFailureOutput>;
420
432
  export declare function postToolUseFailureHook(config: HookConfig, handler: HookHandler<PostToolUseFailureInput, PostToolUseFailureOutput>): HookFunction<PostToolUseFailureInput, PostToolUseFailureOutput>;
421
433
  /**
422
434
  * Creates a Notification hook handler.
@@ -858,3 +870,4 @@ export declare function teammateIdleHook(config: HookConfig, handler: HookHandle
858
870
  * @see https://code.claude.com/docs/en/hooks#taskcompleted
859
871
  */
860
872
  export declare function taskCompletedHook(config: HookConfig, handler: HookHandler<TaskCompletedInput, TaskCompletedOutput>): HookFunction<TaskCompletedInput, TaskCompletedOutput>;
873
+ export {};
package/types/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
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
- export type { HookConfig, HookContext, HookFunction, HookHandler, SessionStartContext, TypedHookConfig, TypedPermissionRequestInput, TypedPostToolUseFailureInput, TypedPostToolUseInput, TypedPreToolUseInput, } from "./hooks.js";
10
+ export type { HookConfig, HookContext, HookFunction, HookHandler, SessionStartContext, TypedHookConfig, TypedPermissionRequestInput, TypedPostToolUseFailureHookInput, TypedPostToolUseHookInput, TypedPreToolUseHookInput, } from "./hooks.js";
11
11
  export { notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, } 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";
@@ -17,6 +17,6 @@ BaseOptions, CommonOptions, ExitCode, HookOutput, HookSpecificOutput, Notificati
17
17
  export { EXIT_CODES, notificationOutput, permissionRequestOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, } from "./outputs.js";
18
18
  export { execute, } from "./runtime.js";
19
19
  export type { ContentContext, PatternCheckResult, ToolUseInput } from "./tool-helpers.js";
20
- export { checkContentForPattern, forEachContent, getFilePath, isAskUserQuestionTool, isBashTool, isEditTool, isExitPlanModeTool, isFileModifyingTool, isGlobTool, isGrepTool, isJsTsFile, isKillShellTool, isMultiEditTool, isNotebookEditTool, isReadTool, isTaskOutputTool, isTaskTool, isTodoWriteTool, isTsFile, isWebFetchTool, isWebSearchTool, isWriteTool, } from "./tool-helpers.js";
21
- export type { BaseHookInput, FileModifyingToolInput, FileModifyingToolName, HookEventName, HookInput, KnownToolInput, KnownToolName, MultiEditEntry, MultiEditToolInput, NotificationInput, PermissionMode, PermissionRequestInput, PermissionUpdate, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreCompactTrigger, PreToolUseInput, SessionEndInput, SessionEndReason, SessionStartInput, SessionStartSource, SetupInput, SetupTrigger, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, } from "./types.js";
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, ConfigInput, FileModifyingToolInput, FileModifyingToolName, HookEventName, HookInput, 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, } from "./types.js";
22
22
  export { HOOK_EVENT_NAMES } from "./types.js";
@@ -34,11 +34,11 @@
34
34
  * @see https://code.claude.com/docs/en/hooks
35
35
  * @module
36
36
  */
37
- import type { AgentInput, AskUserQuestionInput, BashInput, ExitPlanModeInput, FileEditInput, FileModifyingToolInput, FileModifyingToolName, FileReadInput, FileWriteInput, GlobInput, GrepInput, KillShellInput, MultiEditToolInput, NotebookEditInput, PermissionRequestInput, PostToolUseFailureInput, PostToolUseInput, PreToolUseInput, TaskOutputInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "./types.js";
37
+ import type { AgentInput, AskUserQuestionInput, BashInput, ConfigInput, ExitPlanModeInput, FileEditInput, FileModifyingToolInput, FileModifyingToolName, FileReadInput, FileWriteInput, GlobInput, GrepInput, KillShellInput, ListMcpResourcesInput, McpInput, MultiEditToolInput, NotebookEditInput, PermissionRequestInput, ReadMcpResourceInput, SDKPostToolUseFailureHookInput, SDKPostToolUseHookInput, SDKPreToolUseHookInput, TaskOutputInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "./types.js";
38
38
  /**
39
39
  * Union of all hook input types that include tool_input.
40
40
  */
41
- export type ToolUseInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | PermissionRequestInput;
41
+ export type ToolUseInput = SDKPreToolUseHookInput | SDKPostToolUseHookInput | SDKPostToolUseFailureHookInput | PermissionRequestInput;
42
42
  /**
43
43
  * Type guard for Write tool inputs.
44
44
  *
@@ -340,6 +340,76 @@ export declare function isAskUserQuestionTool<T extends ToolUseInput>(input: T):
340
340
  tool_name: "AskUserQuestion";
341
341
  tool_input: AskUserQuestionInput;
342
342
  };
343
+ /**
344
+ * Type guard for ListMcpResources tool inputs.
345
+ *
346
+ * Narrows the input type to include a typed ListMcpResourcesInput.
347
+ * @param input - The hook input to check
348
+ * @returns True if the input is for a ListMcpResources tool
349
+ * @example
350
+ * ```typescript
351
+ * if (isListMcpResourcesTool(input)) {
352
+ * console.log(input.tool_input.server);
353
+ * }
354
+ * ```
355
+ */
356
+ export declare function isListMcpResourcesTool<T extends ToolUseInput>(input: T): input is T & {
357
+ tool_name: "ListMcpResources";
358
+ tool_input: ListMcpResourcesInput;
359
+ };
360
+ /**
361
+ * Type guard for Mcp tool inputs.
362
+ *
363
+ * Narrows the input type to include a typed McpInput.
364
+ * @param input - The hook input to check
365
+ * @returns True if the input is for an Mcp tool
366
+ * @example
367
+ * ```typescript
368
+ * if (isMcpTool(input)) {
369
+ * // input.tool_input is now typed as McpInput
370
+ * }
371
+ * ```
372
+ */
373
+ export declare function isMcpTool<T extends ToolUseInput>(input: T): input is T & {
374
+ tool_name: "Mcp";
375
+ tool_input: McpInput;
376
+ };
377
+ /**
378
+ * Type guard for ReadMcpResource tool inputs.
379
+ *
380
+ * Narrows the input type to include a typed ReadMcpResourceInput.
381
+ * @param input - The hook input to check
382
+ * @returns True if the input is for a ReadMcpResource tool
383
+ * @example
384
+ * ```typescript
385
+ * if (isReadMcpResourceTool(input)) {
386
+ * console.log(input.tool_input.server);
387
+ * console.log(input.tool_input.uri);
388
+ * }
389
+ * ```
390
+ */
391
+ export declare function isReadMcpResourceTool<T extends ToolUseInput>(input: T): input is T & {
392
+ tool_name: "ReadMcpResource";
393
+ tool_input: ReadMcpResourceInput;
394
+ };
395
+ /**
396
+ * Type guard for Config tool inputs.
397
+ *
398
+ * Narrows the input type to include a typed ConfigInput.
399
+ * @param input - The hook input to check
400
+ * @returns True if the input is for a Config tool
401
+ * @example
402
+ * ```typescript
403
+ * if (isConfigTool(input)) {
404
+ * console.log(input.tool_input.setting);
405
+ * console.log(input.tool_input.value);
406
+ * }
407
+ * ```
408
+ */
409
+ export declare function isConfigTool<T extends ToolUseInput>(input: T): input is T & {
410
+ tool_name: "Config";
411
+ tool_input: ConfigInput;
412
+ };
343
413
  /**
344
414
  * Extracts the file path from a tool input.
345
415
  *
@@ -429,7 +499,7 @@ export interface PatternCheckResult {
429
499
  * }
430
500
  * ```
431
501
  */
432
- export declare function checkContentForPattern(input: PreToolUseInput, pattern: RegExp): PatternCheckResult | null;
502
+ export declare function checkContentForPattern(input: SDKPreToolUseHookInput, pattern: RegExp): PatternCheckResult | null;
433
503
  /**
434
504
  * Context passed to the forEachContent callback.
435
505
  */
@@ -462,4 +532,4 @@ export interface ContentContext {
462
532
  * });
463
533
  * ```
464
534
  */
465
- export declare function forEachContent(input: PreToolUseInput, callback: (ctx: ContentContext) => boolean): boolean;
535
+ export declare function forEachContent(input: SDKPreToolUseHookInput, callback: (ctx: ContentContext) => boolean): boolean;
package/types/types.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  */
15
15
  export type { BaseHookInput as SDKBaseHookInput, HookEvent as SDKHookEvent, HookInput as SDKHookInput, 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, } from "@anthropic-ai/claude-agent-sdk";
16
16
  import type { BaseHookInput as SDKBaseHookInput, 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 } from "@anthropic-ai/claude-agent-sdk";
17
- import type { AgentInput, AskUserQuestionInput, BashInput, ExitPlanModeInput, FileEditInput, FileReadInput, FileWriteInput, GlobInput, GrepInput, TaskStopInput as KillShellInput, NotebookEditInput, TaskOutputInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
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.
20
20
  * @see https://code.claude.com/docs/en/hooks#permission-modes
@@ -75,138 +75,95 @@ export interface BaseHookInput extends SDKBaseHookInput {
75
75
  }
76
76
  /**
77
77
  * Input for PreToolUse hooks.
78
- *
79
- * Fires before any tool is executed, allowing you to:
80
- * - Inspect and validate tool inputs
81
- * - Allow, deny, or modify the tool execution
82
- * - Add custom permission logic
83
- *
84
- * This hook uses `tool_name` for matcher matching.
85
- * @example
86
- * ```typescript
87
- * // Block dangerous Bash commands
88
- * preToolUseHook({ matcher: 'Bash' }, async (input: PreToolUseInput) => {
89
- * const command = input.tool_input.command as string;
90
- * if (command.includes('rm -rf')) {
91
- * return preToolUseOutput({
92
- * deny: 'Destructive commands are not allowed'
93
- * });
94
- * }
95
- * return preToolUseOutput({ allow: true });
96
- * });
97
- * ```
98
78
  * @see https://code.claude.com/docs/en/hooks#pretooluse
99
79
  */
100
- export type PreToolUseInput = SDKPreToolUseHookInput;
80
+ export type PreToolUseInput = {
81
+ [K in keyof SDKPreToolUseHookInput]: SDKPreToolUseHookInput[K];
82
+ } & {};
101
83
  /**
102
84
  * Input for PostToolUse hooks.
103
- *
104
- * Fires after a tool executes successfully, allowing you to:
105
- * - Inspect tool results
106
- * - Add additional context to the conversation
107
- * - Modify MCP tool output
108
- *
109
- * This hook uses `tool_name` for matcher matching.
110
- * @example
111
- * ```typescript
112
- * // Add context after file reads
113
- * postToolUseHook({ matcher: 'Read' }, async (input: PostToolUseInput) => {
114
- * const filePath = input.tool_input.file_path as string;
115
- * return postToolUseOutput({
116
- * additionalContext: `File ${filePath} was read successfully`
117
- * });
118
- * });
119
- * ```
120
85
  * @see https://code.claude.com/docs/en/hooks#posttooluse
121
86
  */
122
- export type PostToolUseInput = SDKPostToolUseHookInput;
87
+ export type PostToolUseInput = {
88
+ [K in keyof SDKPostToolUseHookInput]: SDKPostToolUseHookInput[K];
89
+ } & {};
123
90
  /**
124
91
  * Input for PostToolUseFailure hooks.
125
- *
126
- * Fires after a tool execution fails, allowing you to:
127
- * - Log or report tool failures
128
- * - Add context about the failure
129
- * - Take corrective action
130
- *
131
- * This hook uses `tool_name` for matcher matching.
132
- * @example
133
- * ```typescript
134
- * // Log tool failures
135
- * postToolUseFailureHook({ matcher: '.*' }, async (input: PostToolUseFailureInput) => {
136
- * console.error(`Tool ${input.tool_name} failed: ${input.error}`);
137
- * return postToolUseFailureOutput({
138
- * additionalContext: 'Please try an alternative approach'
139
- * });
140
- * });
141
- * ```
142
92
  * @see https://code.claude.com/docs/en/hooks#posttoolusefailure
143
93
  */
144
- export type PostToolUseFailureInput = SDKPostToolUseFailureHookInput;
94
+ export type PostToolUseFailureInput = {
95
+ [K in keyof SDKPostToolUseFailureHookInput]: SDKPostToolUseFailureHookInput[K];
96
+ } & {};
145
97
  /**
146
98
  * Input for Notification hooks.
147
- *
148
- * Fires when Claude Code sends a notification, allowing you to:
149
- * - Forward notifications to external systems
150
- * - Log important events
151
- * - Trigger custom alerting
152
- *
153
- * This hook uses `notification_type` for matcher matching.
154
- * @example
155
- * ```typescript
156
- * // Forward notifications to Slack
157
- * notificationHook({}, async (input: NotificationInput) => {
158
- * await sendSlackMessage(input.title, input.message);
159
- * return notificationOutput({});
160
- * });
161
- * ```
162
99
  * @see https://code.claude.com/docs/en/hooks#notification
163
100
  */
164
- export type NotificationInput = SDKNotificationHookInput;
101
+ export type NotificationInput = {
102
+ [K in keyof SDKNotificationHookInput]: SDKNotificationHookInput[K];
103
+ } & {};
165
104
  /**
166
105
  * Input for UserPromptSubmit hooks.
167
- *
168
- * Fires when a user submits a prompt, allowing you to:
169
- * - Add additional context or instructions
170
- * - Log user interactions
171
- * - Validate or transform prompts
172
- *
173
- * This hook does not support matchers; it fires on all prompt submissions.
174
- * @example
175
- * ```typescript
176
- * // Add project context to every prompt
177
- * userPromptSubmitHook({}, async (input: UserPromptSubmitInput) => {
178
- * return userPromptSubmitOutput({
179
- * additionalContext: await getProjectContext()
180
- * });
181
- * });
182
- * ```
183
106
  * @see https://code.claude.com/docs/en/hooks#userpromptsubmit
184
107
  */
185
- export type UserPromptSubmitInput = SDKUserPromptSubmitHookInput;
108
+ export type UserPromptSubmitInput = {
109
+ [K in keyof SDKUserPromptSubmitHookInput]: SDKUserPromptSubmitHookInput[K];
110
+ } & {};
186
111
  /**
187
112
  * Input for SessionStart hooks.
188
- *
189
- * Fires when a Claude Code session starts or restarts, allowing you to:
190
- * - Initialize session state
191
- * - Inject context or instructions
192
- * - Set up logging or monitoring
193
- *
194
- * This hook uses `source` for matcher matching.
195
- * @example
196
- * ```typescript
197
- * // Initialize context for new sessions
198
- * sessionStartHook({ matcher: 'startup' }, async (input: SessionStartInput) => {
199
- * return sessionStartOutput({
200
- * additionalContext: JSON.stringify({
201
- * project: 'my-project',
202
- * initialized: true
203
- * })
204
- * });
205
- * });
206
- * ```
207
113
  * @see https://code.claude.com/docs/en/hooks#sessionstart
208
114
  */
209
- export type SessionStartInput = SDKSessionStartHookInput;
115
+ export type SessionStartInput = {
116
+ [K in keyof SDKSessionStartHookInput]: SDKSessionStartHookInput[K];
117
+ } & {};
118
+ /**
119
+ * Input for Stop hooks.
120
+ * @see https://code.claude.com/docs/en/hooks#stop
121
+ */
122
+ export type StopInput = {
123
+ [K in keyof SDKStopHookInput]: SDKStopHookInput[K];
124
+ } & {};
125
+ /**
126
+ * Input for SubagentStart hooks.
127
+ * @see https://code.claude.com/docs/en/hooks#subagentstart
128
+ */
129
+ export type SubagentStartInput = {
130
+ [K in keyof SDKSubagentStartHookInput]: SDKSubagentStartHookInput[K];
131
+ } & {};
132
+ /**
133
+ * Input for SubagentStop hooks.
134
+ * @see https://code.claude.com/docs/en/hooks#subagentstop
135
+ */
136
+ export type SubagentStopInput = {
137
+ [K in keyof SDKSubagentStopHookInput]: SDKSubagentStopHookInput[K];
138
+ } & {};
139
+ /**
140
+ * Input for PreCompact hooks.
141
+ * @see https://code.claude.com/docs/en/hooks#precompact
142
+ */
143
+ export type PreCompactInput = {
144
+ [K in keyof SDKPreCompactHookInput]: SDKPreCompactHookInput[K];
145
+ } & {};
146
+ /**
147
+ * Input for Setup hooks.
148
+ * @see https://code.claude.com/docs/en/hooks#setup
149
+ */
150
+ export type SetupInput = {
151
+ [K in keyof SDKSetupHookInput]: SDKSetupHookInput[K];
152
+ } & {};
153
+ /**
154
+ * Input for TeammateIdle hooks.
155
+ * @see https://code.claude.com/docs/en/hooks#teammateidle
156
+ */
157
+ export type TeammateIdleInput = {
158
+ [K in keyof SDKTeammateIdleHookInput]: SDKTeammateIdleHookInput[K];
159
+ } & {};
160
+ /**
161
+ * Input for TaskCompleted hooks.
162
+ * @see https://code.claude.com/docs/en/hooks#taskcompleted
163
+ */
164
+ export type TaskCompletedInput = {
165
+ [K in keyof SDKTaskCompletedHookInput]: SDKTaskCompletedHookInput[K];
166
+ } & {};
210
167
  /**
211
168
  * Input for SessionEnd hooks.
212
169
  *
@@ -226,7 +183,7 @@ export type SessionStartInput = SDKSessionStartHookInput;
226
183
  * ```
227
184
  * @see https://code.claude.com/docs/en/hooks#sessionend
228
185
  */
229
- export interface SessionEndInput extends Omit<SDKSessionEndHookInput, "reason"> {
186
+ type _SessionEndInputBase = Omit<SDKSessionEndHookInput, "reason"> & {
230
187
  /**
231
188
  * The reason the session ended.
232
189
  *
@@ -236,98 +193,10 @@ export interface SessionEndInput extends Omit<SDKSessionEndHookInput, "reason">
236
193
  * - `'other'` - Other reasons
237
194
  */
238
195
  reason: SessionEndReason;
239
- }
240
- /**
241
- * Input for Stop hooks.
242
- *
243
- * Fires when Claude Code is about to stop, allowing you to:
244
- * - Block the stop and require additional action
245
- * - Confirm the user wants to stop
246
- * - Clean up resources before stopping
247
- *
248
- * This hook does not support matchers; it fires on all stop events.
249
- * @example
250
- * ```typescript
251
- * // Require confirmation before stopping with pending changes
252
- * stopHook({}, async (input: StopInput) => {
253
- * const pendingChanges = await checkPendingChanges();
254
- * if (pendingChanges.length > 0) {
255
- * return stopOutput({
256
- * decision: 'block',
257
- * reason: 'There are uncommitted changes'
258
- * });
259
- * }
260
- * return stopOutput({ decision: 'approve' });
261
- * });
262
- * ```
263
- * @see https://code.claude.com/docs/en/hooks#stop
264
- */
265
- export type StopInput = SDKStopHookInput;
266
- /**
267
- * Input for SubagentStart hooks.
268
- *
269
- * Fires when a subagent (Task tool) starts, allowing you to:
270
- * - Inject context for the subagent
271
- * - Log subagent invocations
272
- * - Configure subagent behavior
273
- *
274
- * This hook uses `agent_type` for matcher matching.
275
- * @example
276
- * ```typescript
277
- * // Add context for explore subagents
278
- * subagentStartHook({ matcher: 'explore' }, async (input: SubagentStartInput) => {
279
- * return subagentStartOutput({
280
- * additionalContext: 'Focus on finding patterns and conventions'
281
- * });
282
- * });
283
- * ```
284
- * @see https://code.claude.com/docs/en/hooks#subagentstart
285
- */
286
- export type SubagentStartInput = SDKSubagentStartHookInput;
287
- /**
288
- * Input for SubagentStop hooks.
289
- *
290
- * Fires when a subagent completes or stops, allowing you to:
291
- * - Process subagent results
292
- * - Clean up subagent resources
293
- * - Log subagent completion
294
- * - Block subagent from stopping
295
- *
296
- * This hook uses `agent_type` for matcher matching.
297
- * @example
298
- * ```typescript
299
- * // Block explore subagent if task incomplete
300
- * subagentStopHook({ matcher: 'explore' }, async (input: SubagentStopInput) => {
301
- * console.log(`Subagent ${input.agent_id} (${input.agent_type}) stopping`);
302
- * return subagentStopOutput({
303
- * decision: 'block',
304
- * reason: 'Please verify all files were explored'
305
- * });
306
- * });
307
- * ```
308
- * @see https://code.claude.com/docs/en/hooks#subagentstop
309
- */
310
- export type SubagentStopInput = SDKSubagentStopHookInput;
311
- /**
312
- * Input for PreCompact hooks.
313
- *
314
- * Fires before context compaction occurs, allowing you to:
315
- * - Preserve important information before compaction
316
- * - Log compaction events
317
- * - Modify custom instructions for the compacted context
318
- *
319
- * This hook uses `trigger` for matcher matching.
320
- * @example
321
- * ```typescript
322
- * // Log compaction events
323
- * preCompactHook({}, async (input: PreCompactInput) => {
324
- * console.log(`Compacting (${input.trigger})`);
325
- * return preCompactOutput({});
326
- * });
327
- * ```
328
- * @see https://code.claude.com/docs/en/hooks#precompact
329
- */
330
- export type PreCompactInput = SDKPreCompactHookInput;
196
+ };
197
+ export type SessionEndInput = {
198
+ [K in keyof _SessionEndInputBase]: _SessionEndInputBase[K];
199
+ } & {};
331
200
  /**
332
201
  * Input for PermissionRequest hooks.
333
202
  *
@@ -352,85 +221,19 @@ export type PreCompactInput = SDKPreCompactHookInput;
352
221
  * ```
353
222
  * @see https://code.claude.com/docs/en/hooks#permissionrequest
354
223
  */
355
- export interface PermissionRequestInput extends SDKPermissionRequestHookInput {
224
+ type _PermissionRequestInputBase = SDKPermissionRequestHookInput & {
356
225
  /**
357
226
  * Unique identifier for this specific tool invocation.
358
227
  */
359
228
  tool_use_id: string;
360
- }
361
- /**
362
- * Input for TeammateIdle hooks.
363
- *
364
- * Fires when a teammate in a team is about to go idle, allowing you to:
365
- * - Assign work to idle teammates
366
- * - Log team activity
367
- * - Coordinate multi-agent workflows
368
- *
369
- * This hook does not support matchers; it fires on all teammate idle events.
370
- * @example
371
- * ```typescript
372
- * // Assign work to an idle teammate
373
- * teammateIdleHook({}, async (input: TeammateIdleInput) => {
374
- * console.log(`${input.teammate_name} is idle in team ${input.team_name}`);
375
- * return teammateIdleOutput({});
376
- * });
377
- * ```
378
- * @see https://code.claude.com/docs/en/hooks#teammateidle
379
- */
380
- export type TeammateIdleInput = SDKTeammateIdleHookInput;
381
- /**
382
- * Input for TaskCompleted hooks.
383
- *
384
- * Fires when a task is being marked as completed, allowing you to:
385
- * - Verify task completion
386
- * - Log task metrics
387
- * - Trigger follow-up actions
388
- *
389
- * This hook does not support matchers; it fires on all task completion events.
390
- * @example
391
- * ```typescript
392
- * // Log task completion
393
- * taskCompletedHook({}, async (input: TaskCompletedInput) => {
394
- * console.log(`Task ${input.task_id}: ${input.task_subject} completed`);
395
- * return taskCompletedOutput({});
396
- * });
397
- * ```
398
- * @see https://code.claude.com/docs/en/hooks#taskcompleted
399
- */
400
- export type TaskCompletedInput = SDKTaskCompletedHookInput;
229
+ };
230
+ export type PermissionRequestInput = {
231
+ [K in keyof _PermissionRequestInputBase]: _PermissionRequestInputBase[K];
232
+ } & {};
401
233
  /**
402
234
  * Trigger type for Setup hooks.
403
235
  */
404
236
  export type SetupTrigger = "init" | "maintenance";
405
- /**
406
- * Input for Setup hooks.
407
- *
408
- * Fires during initialization or maintenance, allowing you to:
409
- * - Configure initial session state
410
- * - Perform setup tasks before the session starts
411
- * - Add context for maintenance operations
412
- *
413
- * This hook uses `trigger` for matcher matching.
414
- * @example
415
- * ```typescript
416
- * // Log setup events
417
- * setupHook({}, async (input: SetupInput) => {
418
- * console.log(`Setup triggered by: ${input.trigger}`);
419
- * return setupOutput({});
420
- * });
421
- *
422
- * // Only handle init triggers
423
- * setupHook({ matcher: 'init' }, async (input: SetupInput) => {
424
- * return setupOutput({
425
- * hookSpecificOutput: {
426
- * additionalContext: 'Initial setup complete'
427
- * }
428
- * });
429
- * });
430
- * ```
431
- * @see https://code.claude.com/docs/en/hooks#setup
432
- */
433
- export type SetupInput = SDKSetupHookInput;
434
237
  /**
435
238
  * Discriminated union of all hook input types.
436
239
  *
@@ -535,11 +338,11 @@ export type FileModifyingToolName = "Write" | "Edit" | "MultiEdit";
535
338
  *
536
339
  * This includes all tool inputs that have well-defined type structures.
537
340
  */
538
- export type KnownToolInput = FileWriteInput | FileEditInput | MultiEditToolInput | FileReadInput | BashInput | GlobInput | GrepInput | AgentInput | TaskOutputInput | ExitPlanModeInput | KillShellInput | NotebookEditInput | TodoWriteInput | WebFetchInput | WebSearchInput | AskUserQuestionInput;
341
+ export type KnownToolInput = FileWriteInput | FileEditInput | MultiEditToolInput | FileReadInput | BashInput | GlobInput | GrepInput | AgentInput | TaskOutputInput | ExitPlanModeInput | KillShellInput | NotebookEditInput | TodoWriteInput | WebFetchInput | WebSearchInput | AskUserQuestionInput | ListMcpResourcesInput | McpInput | ReadMcpResourceInput | ConfigInput;
539
342
  /**
540
343
  * Tool names for all known tools with typed inputs.
541
344
  */
542
- export type KnownToolName = "Write" | "Edit" | "MultiEdit" | "Read" | "Bash" | "Glob" | "Grep" | "Task" | "TaskOutput" | "ExitPlanMode" | "KillShell" | "NotebookEdit" | "TodoWrite" | "WebFetch" | "WebSearch" | "AskUserQuestion";
345
+ export type KnownToolName = "Write" | "Edit" | "MultiEdit" | "Read" | "Bash" | "Glob" | "Grep" | "Task" | "TaskOutput" | "ExitPlanMode" | "KillShell" | "NotebookEdit" | "TodoWrite" | "WebFetch" | "WebSearch" | "AskUserQuestion" | "ListMcpResources" | "Mcp" | "ReadMcpResource" | "Config";
543
346
  /**
544
347
  * Type mapping from tool name to tool input type.
545
348
  *
@@ -566,4 +369,8 @@ export interface ToolInputMap {
566
369
  WebFetch: WebFetchInput;
567
370
  WebSearch: WebSearchInput;
568
371
  AskUserQuestion: AskUserQuestionInput;
372
+ ListMcpResources: ListMcpResourcesInput;
373
+ Mcp: McpInput;
374
+ ReadMcpResource: ReadMcpResourceInput;
375
+ Config: ConfigInput;
569
376
  }