@goodfoot/claude-code-hooks 1.0.19 → 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/cli.js +11 -6
- package/dist/constants.js +2 -0
- package/dist/hooks.js +70 -0
- package/dist/index.js +10 -6
- package/dist/outputs.js +20 -0
- package/dist/scaffold.js +2 -0
- package/dist/tool-helpers.js +66 -0
- package/dist/types.js +2 -0
- package/package.json +2 -2
- package/types/hooks.d.ts +85 -12
- package/types/index.d.ts +6 -6
- package/types/outputs.d.ts +45 -1
- package/types/tool-helpers.d.ts +74 -4
- package/types/types.d.ts +88 -241
package/dist/cli.js
CHANGED
|
@@ -387,17 +387,22 @@ async function discoverHookFiles(pattern, cwd) {
|
|
|
387
387
|
*/
|
|
388
388
|
async function compileHook(options) {
|
|
389
389
|
const { sourcePath, logFilePath } = options;
|
|
390
|
-
// Get the path to the runtime module (
|
|
391
|
-
const
|
|
390
|
+
// Get the path to the runtime module (absolute, then converted to relative)
|
|
391
|
+
const runtimePathAbsolute = path.resolve(path.dirname(new URL(import.meta.url).pathname), "./runtime.js");
|
|
392
392
|
// Build log file injection code if specified
|
|
393
393
|
const logFileInjection = logFilePath !== undefined
|
|
394
394
|
? `process.env['CLAUDE_CODE_HOOKS_CLI_LOG_FILE'] = ${JSON.stringify(logFilePath)};\n`
|
|
395
395
|
: "";
|
|
396
|
+
// Compute relative paths from resolveDir to avoid absolute paths in source maps.
|
|
397
|
+
// This ensures reproducible builds regardless of checkout directory.
|
|
398
|
+
const resolveDir = path.dirname(sourcePath);
|
|
399
|
+
const relativeSourcePath = `./${path.basename(sourcePath)}`;
|
|
400
|
+
const relativeRuntimePath = path.relative(resolveDir, runtimePathAbsolute);
|
|
396
401
|
// Create wrapper content that imports the hook and calls execute
|
|
397
|
-
// Uses
|
|
402
|
+
// Uses relative paths to produce reproducible builds
|
|
398
403
|
const wrapperContent = `${logFileInjection}
|
|
399
|
-
import hook from '${
|
|
400
|
-
import { execute } from '${
|
|
404
|
+
import hook from '${relativeSourcePath.replace(/\\/g, "/")}';
|
|
405
|
+
import { execute } from '${relativeRuntimePath.replace(/\\/g, "/")}';
|
|
401
406
|
|
|
402
407
|
execute(hook);
|
|
403
408
|
`;
|
|
@@ -407,7 +412,7 @@ execute(hook);
|
|
|
407
412
|
const baseName = path.basename(sourcePath, path.extname(sourcePath));
|
|
408
413
|
const stdinOptions = {
|
|
409
414
|
contents: wrapperContent,
|
|
410
|
-
resolveDir
|
|
415
|
+
resolveDir,
|
|
411
416
|
sourcefile: `${baseName}-entry.ts`,
|
|
412
417
|
loader: "ts",
|
|
413
418
|
};
|
package/dist/constants.js
CHANGED
package/dist/hooks.js
CHANGED
|
@@ -429,3 +429,73 @@ export function permissionRequestHook(config, handler) {
|
|
|
429
429
|
export function setupHook(config, handler) {
|
|
430
430
|
return createHookFunction("Setup", config, handler);
|
|
431
431
|
}
|
|
432
|
+
// ============================================================================
|
|
433
|
+
// TeammateIdle Hook Factory
|
|
434
|
+
// ============================================================================
|
|
435
|
+
/**
|
|
436
|
+
* Creates a TeammateIdle hook handler.
|
|
437
|
+
*
|
|
438
|
+
* TeammateIdle hooks fire when a teammate in a team is about to go idle,
|
|
439
|
+
* allowing you to:
|
|
440
|
+
* - Assign work to idle teammates
|
|
441
|
+
* - Log team activity
|
|
442
|
+
* - Coordinate multi-agent workflows
|
|
443
|
+
*
|
|
444
|
+
* **Matcher**: No matcher support - fires on all teammate idle events
|
|
445
|
+
* @param config - Hook configuration with optional timeout (matcher is ignored)
|
|
446
|
+
* @param handler - The handler function to execute
|
|
447
|
+
* @returns A hook function that can be exported as the default export
|
|
448
|
+
* @example
|
|
449
|
+
* ```typescript
|
|
450
|
+
* import { teammateIdleHook, teammateIdleOutput } from '@goodfoot/claude-code-hooks';
|
|
451
|
+
*
|
|
452
|
+
* // Log when teammates go idle
|
|
453
|
+
* export default teammateIdleHook({}, async (input, { logger }) => {
|
|
454
|
+
* logger.info('Teammate going idle', {
|
|
455
|
+
* teammateName: input.teammate_name,
|
|
456
|
+
* teamName: input.team_name
|
|
457
|
+
* });
|
|
458
|
+
*
|
|
459
|
+
* return teammateIdleOutput({});
|
|
460
|
+
* });
|
|
461
|
+
* ```
|
|
462
|
+
* @see https://code.claude.com/docs/en/hooks#teammateidle
|
|
463
|
+
*/
|
|
464
|
+
export function teammateIdleHook(config, handler) {
|
|
465
|
+
return createHookFunction("TeammateIdle", config, handler);
|
|
466
|
+
}
|
|
467
|
+
// ============================================================================
|
|
468
|
+
// TaskCompleted Hook Factory
|
|
469
|
+
// ============================================================================
|
|
470
|
+
/**
|
|
471
|
+
* Creates a TaskCompleted hook handler.
|
|
472
|
+
*
|
|
473
|
+
* TaskCompleted hooks fire when a task is being marked as completed,
|
|
474
|
+
* allowing you to:
|
|
475
|
+
* - Verify task completion
|
|
476
|
+
* - Log task metrics
|
|
477
|
+
* - Trigger follow-up actions
|
|
478
|
+
*
|
|
479
|
+
* **Matcher**: No matcher support - fires on all task completion events
|
|
480
|
+
* @param config - Hook configuration with optional timeout (matcher is ignored)
|
|
481
|
+
* @param handler - The handler function to execute
|
|
482
|
+
* @returns A hook function that can be exported as the default export
|
|
483
|
+
* @example
|
|
484
|
+
* ```typescript
|
|
485
|
+
* import { taskCompletedHook, taskCompletedOutput } from '@goodfoot/claude-code-hooks';
|
|
486
|
+
*
|
|
487
|
+
* // Log task completion
|
|
488
|
+
* export default taskCompletedHook({}, async (input, { logger }) => {
|
|
489
|
+
* logger.info('Task completed', {
|
|
490
|
+
* taskId: input.task_id,
|
|
491
|
+
* taskSubject: input.task_subject
|
|
492
|
+
* });
|
|
493
|
+
*
|
|
494
|
+
* return taskCompletedOutput({});
|
|
495
|
+
* });
|
|
496
|
+
* ```
|
|
497
|
+
* @see https://code.claude.com/docs/en/hooks#taskcompleted
|
|
498
|
+
*/
|
|
499
|
+
export function taskCompletedHook(config, handler) {
|
|
500
|
+
return createHookFunction("TaskCompleted", config, handler);
|
|
501
|
+
}
|
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 { notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, userPromptSubmitHook, } from "./hooks.js";
|
|
14
|
+
// Hook factory functions - all 15 hook types
|
|
15
|
+
export { notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, } 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 {
|
|
20
20
|
// Exit codes
|
|
21
21
|
EXIT_CODES, notificationOutput, permissionRequestOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput,
|
|
22
|
-
// All
|
|
23
|
-
preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, userPromptSubmitOutput, } from "./outputs.js";
|
|
22
|
+
// All 15 output builder functions
|
|
23
|
+
preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, } from "./outputs.js";
|
|
24
24
|
// Runtime exports - execute function
|
|
25
25
|
export {
|
|
26
26
|
// Main execute function for compiled hooks
|
|
@@ -34,9 +34,13 @@ getFilePath,
|
|
|
34
34
|
// Type guards - User interaction
|
|
35
35
|
isAskUserQuestionTool,
|
|
36
36
|
// Type guards - Commands
|
|
37
|
-
isBashTool,
|
|
37
|
+
isBashTool,
|
|
38
|
+
// Type guards - Config
|
|
39
|
+
isConfigTool, isEditTool, isExitPlanModeTool, isFileModifyingTool,
|
|
38
40
|
// Type guards - Search
|
|
39
|
-
isGlobTool, isGrepTool, isJsTsFile, isKillShellTool,
|
|
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
|
package/dist/outputs.js
CHANGED
|
@@ -297,3 +297,23 @@ export const permissionRequestOutput = /* @__PURE__ */ createHookSpecificOutputB
|
|
|
297
297
|
* ```
|
|
298
298
|
*/
|
|
299
299
|
export const setupOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("Setup");
|
|
300
|
+
/**
|
|
301
|
+
* Creates an output for TeammateIdle hooks.
|
|
302
|
+
* @param options - Configuration options for the hook output
|
|
303
|
+
* @returns A TeammateIdleOutput object ready for the runtime
|
|
304
|
+
* @example
|
|
305
|
+
* ```typescript
|
|
306
|
+
* teammateIdleOutput({});
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
export const teammateIdleOutput = /* @__PURE__ */ createSimpleOutputBuilder("TeammateIdle");
|
|
310
|
+
/**
|
|
311
|
+
* Creates an output for TaskCompleted hooks.
|
|
312
|
+
* @param options - Configuration options for the hook output
|
|
313
|
+
* @returns A TaskCompletedOutput object ready for the runtime
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* taskCompletedOutput({});
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
export const taskCompletedOutput = /* @__PURE__ */ createSimpleOutputBuilder("TaskCompleted");
|
package/dist/scaffold.js
CHANGED
|
@@ -50,6 +50,8 @@ const EVENT_TO_OUTPUT_FUNCTION = {
|
|
|
50
50
|
PreCompact: "preCompactOutput",
|
|
51
51
|
PermissionRequest: "permissionRequestOutput",
|
|
52
52
|
Setup: "setupOutput",
|
|
53
|
+
TeammateIdle: "teammateIdleOutput",
|
|
54
|
+
TaskCompleted: "taskCompletedOutput",
|
|
53
55
|
};
|
|
54
56
|
// ============================================================================
|
|
55
57
|
// Validation
|
package/dist/tool-helpers.js
CHANGED
|
@@ -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/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodfoot/claude-code-hooks",
|
|
3
|
-
"version": "1.0.
|
|
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.
|
|
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
|
@@ -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 { NotificationOutput, PermissionRequestOutput, PostToolUseFailureOutput, PostToolUseOutput, PreCompactOutput, PreToolUseOutput, SessionEndOutput, SessionStartOutput, SetupOutput, SpecificHookOutput, StopOutput, SubagentStartOutput, SubagentStopOutput, UserPromptSubmitOutput } from "./outputs.js";
|
|
26
|
-
import type { HookEventName, KnownToolName, NotificationInput, PermissionRequestInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseInput, SessionEndInput, SessionStartInput, SetupInput, StopInput, SubagentStartInput, SubagentStopInput, ToolInputMap, UserPromptSubmitInput } from "./types.js";
|
|
25
|
+
import type { NotificationOutput, PermissionRequestOutput, PostToolUseFailureOutput, PostToolUseOutput, PreCompactOutput, PreToolUseOutput, SessionEndOutput, SessionStartOutput, SetupOutput, SpecificHookOutput, StopOutput, SubagentStartOutput, SubagentStopOutput, TaskCompletedOutput, TeammateIdleOutput, UserPromptSubmitOutput } from "./outputs.js";
|
|
26
|
+
import type { HookEventName, KnownToolName, NotificationInput, PermissionRequestInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseInput, SessionEndInput, SessionStartInput, SetupInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput } from "./types.js";
|
|
27
27
|
/**
|
|
28
28
|
* Configuration options for hook factories.
|
|
29
29
|
*
|
|
@@ -136,37 +136,49 @@ export interface TypedHookConfig<T extends KnownToolName> {
|
|
|
136
136
|
timeout?: number;
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* PreToolUseHookInput with typed tool_input for a specific tool.
|
|
140
140
|
* @template T - The known tool name
|
|
141
141
|
*/
|
|
142
|
-
|
|
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
|
-
*
|
|
150
|
+
* PostToolUseHookInput with typed tool_input for a specific tool.
|
|
148
151
|
* @template T - The known tool name
|
|
149
152
|
*/
|
|
150
|
-
|
|
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
|
-
*
|
|
161
|
+
* PostToolUseFailureHookInput with typed tool_input for a specific tool.
|
|
156
162
|
* @template T - The known tool name
|
|
157
163
|
*/
|
|
158
|
-
|
|
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
|
-
|
|
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<
|
|
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<
|
|
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<
|
|
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.
|
|
@@ -798,3 +810,64 @@ export declare function permissionRequestHook(config: HookConfig, handler: HookH
|
|
|
798
810
|
* @see https://code.claude.com/docs/en/hooks#setup
|
|
799
811
|
*/
|
|
800
812
|
export declare function setupHook(config: HookConfig, handler: HookHandler<SetupInput, SetupOutput>): HookFunction<SetupInput, SetupOutput>;
|
|
813
|
+
/**
|
|
814
|
+
* Creates a TeammateIdle hook handler.
|
|
815
|
+
*
|
|
816
|
+
* TeammateIdle hooks fire when a teammate in a team is about to go idle,
|
|
817
|
+
* allowing you to:
|
|
818
|
+
* - Assign work to idle teammates
|
|
819
|
+
* - Log team activity
|
|
820
|
+
* - Coordinate multi-agent workflows
|
|
821
|
+
*
|
|
822
|
+
* **Matcher**: No matcher support - fires on all teammate idle events
|
|
823
|
+
* @param config - Hook configuration with optional timeout (matcher is ignored)
|
|
824
|
+
* @param handler - The handler function to execute
|
|
825
|
+
* @returns A hook function that can be exported as the default export
|
|
826
|
+
* @example
|
|
827
|
+
* ```typescript
|
|
828
|
+
* import { teammateIdleHook, teammateIdleOutput } from '@goodfoot/claude-code-hooks';
|
|
829
|
+
*
|
|
830
|
+
* // Log when teammates go idle
|
|
831
|
+
* export default teammateIdleHook({}, async (input, { logger }) => {
|
|
832
|
+
* logger.info('Teammate going idle', {
|
|
833
|
+
* teammateName: input.teammate_name,
|
|
834
|
+
* teamName: input.team_name
|
|
835
|
+
* });
|
|
836
|
+
*
|
|
837
|
+
* return teammateIdleOutput({});
|
|
838
|
+
* });
|
|
839
|
+
* ```
|
|
840
|
+
* @see https://code.claude.com/docs/en/hooks#teammateidle
|
|
841
|
+
*/
|
|
842
|
+
export declare function teammateIdleHook(config: HookConfig, handler: HookHandler<TeammateIdleInput, TeammateIdleOutput>): HookFunction<TeammateIdleInput, TeammateIdleOutput>;
|
|
843
|
+
/**
|
|
844
|
+
* Creates a TaskCompleted hook handler.
|
|
845
|
+
*
|
|
846
|
+
* TaskCompleted hooks fire when a task is being marked as completed,
|
|
847
|
+
* allowing you to:
|
|
848
|
+
* - Verify task completion
|
|
849
|
+
* - Log task metrics
|
|
850
|
+
* - Trigger follow-up actions
|
|
851
|
+
*
|
|
852
|
+
* **Matcher**: No matcher support - fires on all task completion events
|
|
853
|
+
* @param config - Hook configuration with optional timeout (matcher is ignored)
|
|
854
|
+
* @param handler - The handler function to execute
|
|
855
|
+
* @returns A hook function that can be exported as the default export
|
|
856
|
+
* @example
|
|
857
|
+
* ```typescript
|
|
858
|
+
* import { taskCompletedHook, taskCompletedOutput } from '@goodfoot/claude-code-hooks';
|
|
859
|
+
*
|
|
860
|
+
* // Log task completion
|
|
861
|
+
* export default taskCompletedHook({}, async (input, { logger }) => {
|
|
862
|
+
* logger.info('Task completed', {
|
|
863
|
+
* taskId: input.task_id,
|
|
864
|
+
* taskSubject: input.task_subject
|
|
865
|
+
* });
|
|
866
|
+
*
|
|
867
|
+
* return taskCompletedOutput({});
|
|
868
|
+
* });
|
|
869
|
+
* ```
|
|
870
|
+
* @see https://code.claude.com/docs/en/hooks#taskcompleted
|
|
871
|
+
*/
|
|
872
|
+
export declare function taskCompletedHook(config: HookConfig, handler: HookHandler<TaskCompletedInput, TaskCompletedOutput>): HookFunction<TaskCompletedInput, TaskCompletedOutput>;
|
|
873
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
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,
|
|
11
|
-
export { notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, userPromptSubmitHook, } from "./hooks.js";
|
|
10
|
+
export type { HookConfig, HookContext, HookFunction, HookHandler, SessionStartContext, TypedHookConfig, TypedPermissionRequestInput, TypedPostToolUseFailureHookInput, TypedPostToolUseHookInput, TypedPreToolUseHookInput, } from "./hooks.js";
|
|
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";
|
|
14
14
|
export type {
|
|
15
15
|
/** @deprecated Use CommonOptions instead */
|
|
16
|
-
BaseOptions, CommonOptions, ExitCode, HookOutput, HookSpecificOutput, NotificationOptions, PermissionRequestAllowDecision, PermissionRequestDecision, PermissionRequestDenyDecision, PermissionRequestHookSpecificOutput, PermissionRequestOptions, PostToolUseFailureHookSpecificOutput, PostToolUseFailureOptions, PostToolUseHookSpecificOutput, PostToolUseOptions, PreCompactOptions, PreToolUseHookSpecificOutput, PreToolUseOptions, SessionEndOptions, SessionStartHookSpecificOutput, SessionStartOptions, SetupHookSpecificOutput, SetupOptions, StopOptions, SubagentStartHookSpecificOutput, SubagentStartOptions, SubagentStopOptions, SyncHookJSONOutput, UserPromptSubmitHookSpecificOutput, UserPromptSubmitOptions, } from "./outputs.js";
|
|
17
|
-
export { EXIT_CODES, notificationOutput, permissionRequestOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, userPromptSubmitOutput, } from "./outputs.js";
|
|
16
|
+
BaseOptions, CommonOptions, ExitCode, HookOutput, HookSpecificOutput, 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, } from "./outputs.js";
|
|
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, 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";
|
package/types/outputs.d.ts
CHANGED
|
@@ -211,10 +211,18 @@ export type PermissionRequestOutput = BaseSpecificOutput<"PermissionRequest">;
|
|
|
211
211
|
*
|
|
212
212
|
*/
|
|
213
213
|
export type SetupOutput = BaseSpecificOutput<"Setup">;
|
|
214
|
+
/**
|
|
215
|
+
*
|
|
216
|
+
*/
|
|
217
|
+
export type TeammateIdleOutput = BaseSpecificOutput<"TeammateIdle">;
|
|
218
|
+
/**
|
|
219
|
+
*
|
|
220
|
+
*/
|
|
221
|
+
export type TaskCompletedOutput = BaseSpecificOutput<"TaskCompleted">;
|
|
214
222
|
/**
|
|
215
223
|
* Union of all specific output types.
|
|
216
224
|
*/
|
|
217
|
-
export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PermissionRequestOutput | SetupOutput;
|
|
225
|
+
export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PermissionRequestOutput | SetupOutput | TeammateIdleOutput | TaskCompletedOutput;
|
|
218
226
|
/**
|
|
219
227
|
* Options for decision-based hooks (Stop, SubagentStop).
|
|
220
228
|
*/
|
|
@@ -601,6 +609,42 @@ export declare const setupOutput: (options?: CommonOptions & {
|
|
|
601
609
|
readonly _type: "Setup";
|
|
602
610
|
stdout: SyncHookJSONOutput;
|
|
603
611
|
};
|
|
612
|
+
/**
|
|
613
|
+
* Options for the TeammateIdle output builder.
|
|
614
|
+
* TeammateIdle hooks only support common options.
|
|
615
|
+
*/
|
|
616
|
+
export type TeammateIdleOptions = CommonOptions;
|
|
617
|
+
/**
|
|
618
|
+
* Creates an output for TeammateIdle hooks.
|
|
619
|
+
* @param options - Configuration options for the hook output
|
|
620
|
+
* @returns A TeammateIdleOutput object ready for the runtime
|
|
621
|
+
* @example
|
|
622
|
+
* ```typescript
|
|
623
|
+
* teammateIdleOutput({});
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
export declare const teammateIdleOutput: (options?: CommonOptions) => {
|
|
627
|
+
readonly _type: "TeammateIdle";
|
|
628
|
+
stdout: SyncHookJSONOutput;
|
|
629
|
+
};
|
|
630
|
+
/**
|
|
631
|
+
* Options for the TaskCompleted output builder.
|
|
632
|
+
* TaskCompleted hooks only support common options.
|
|
633
|
+
*/
|
|
634
|
+
export type TaskCompletedOptions = CommonOptions;
|
|
635
|
+
/**
|
|
636
|
+
* Creates an output for TaskCompleted hooks.
|
|
637
|
+
* @param options - Configuration options for the hook output
|
|
638
|
+
* @returns A TaskCompletedOutput object ready for the runtime
|
|
639
|
+
* @example
|
|
640
|
+
* ```typescript
|
|
641
|
+
* taskCompletedOutput({});
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
export declare const taskCompletedOutput: (options?: CommonOptions) => {
|
|
645
|
+
readonly _type: "TaskCompleted";
|
|
646
|
+
stdout: SyncHookJSONOutput;
|
|
647
|
+
};
|
|
604
648
|
/**
|
|
605
649
|
* @deprecated Use CommonOptions instead
|
|
606
650
|
*/
|
package/types/tool-helpers.d.ts
CHANGED
|
@@ -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,
|
|
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 =
|
|
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:
|
|
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:
|
|
535
|
+
export declare function forEachContent(input: SDKPreToolUseHookInput, callback: (ctx: ContentContext) => boolean): boolean;
|
package/types/types.d.ts
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
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, 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, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, } from "@anthropic-ai/claude-agent-sdk";
|
|
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, 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";
|
|
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
|
+
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, 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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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,45 +221,19 @@ export type PreCompactInput = SDKPreCompactHookInput;
|
|
|
352
221
|
* ```
|
|
353
222
|
* @see https://code.claude.com/docs/en/hooks#permissionrequest
|
|
354
223
|
*/
|
|
355
|
-
|
|
224
|
+
type _PermissionRequestInputBase = SDKPermissionRequestHookInput & {
|
|
356
225
|
/**
|
|
357
226
|
* Unique identifier for this specific tool invocation.
|
|
358
227
|
*/
|
|
359
228
|
tool_use_id: string;
|
|
360
|
-
}
|
|
229
|
+
};
|
|
230
|
+
export type PermissionRequestInput = {
|
|
231
|
+
[K in keyof _PermissionRequestInputBase]: _PermissionRequestInputBase[K];
|
|
232
|
+
} & {};
|
|
361
233
|
/**
|
|
362
234
|
* Trigger type for Setup hooks.
|
|
363
235
|
*/
|
|
364
236
|
export type SetupTrigger = "init" | "maintenance";
|
|
365
|
-
/**
|
|
366
|
-
* Input for Setup hooks.
|
|
367
|
-
*
|
|
368
|
-
* Fires during initialization or maintenance, allowing you to:
|
|
369
|
-
* - Configure initial session state
|
|
370
|
-
* - Perform setup tasks before the session starts
|
|
371
|
-
* - Add context for maintenance operations
|
|
372
|
-
*
|
|
373
|
-
* This hook uses `trigger` for matcher matching.
|
|
374
|
-
* @example
|
|
375
|
-
* ```typescript
|
|
376
|
-
* // Log setup events
|
|
377
|
-
* setupHook({}, async (input: SetupInput) => {
|
|
378
|
-
* console.log(`Setup triggered by: ${input.trigger}`);
|
|
379
|
-
* return setupOutput({});
|
|
380
|
-
* });
|
|
381
|
-
*
|
|
382
|
-
* // Only handle init triggers
|
|
383
|
-
* setupHook({ matcher: 'init' }, async (input: SetupInput) => {
|
|
384
|
-
* return setupOutput({
|
|
385
|
-
* hookSpecificOutput: {
|
|
386
|
-
* additionalContext: 'Initial setup complete'
|
|
387
|
-
* }
|
|
388
|
-
* });
|
|
389
|
-
* });
|
|
390
|
-
* ```
|
|
391
|
-
* @see https://code.claude.com/docs/en/hooks#setup
|
|
392
|
-
*/
|
|
393
|
-
export type SetupInput = SDKSetupHookInput;
|
|
394
237
|
/**
|
|
395
238
|
* Discriminated union of all hook input types.
|
|
396
239
|
*
|
|
@@ -415,7 +258,7 @@ export type SetupInput = SDKSetupHookInput;
|
|
|
415
258
|
* ```
|
|
416
259
|
* @see https://code.claude.com/docs/en/hooks
|
|
417
260
|
*/
|
|
418
|
-
export type HookInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | NotificationInput | UserPromptSubmitInput | SessionStartInput | SessionEndInput | StopInput | SubagentStartInput | SubagentStopInput | PreCompactInput | PermissionRequestInput | SetupInput;
|
|
261
|
+
export type HookInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | NotificationInput | UserPromptSubmitInput | SessionStartInput | SessionEndInput | StopInput | SubagentStartInput | SubagentStopInput | PreCompactInput | PermissionRequestInput | SetupInput | TeammateIdleInput | TaskCompletedInput;
|
|
419
262
|
/**
|
|
420
263
|
* Hook event name literal union.
|
|
421
264
|
*
|
|
@@ -433,7 +276,7 @@ export type HookEventName = HookInput["hook_event_name"];
|
|
|
433
276
|
* }
|
|
434
277
|
* ```
|
|
435
278
|
*/
|
|
436
|
-
export declare const HOOK_EVENT_NAMES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest", "Setup"];
|
|
279
|
+
export declare const HOOK_EVENT_NAMES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest", "Setup", "TeammateIdle", "TaskCompleted"];
|
|
437
280
|
export type { SDKPermissionUpdate as PermissionUpdate };
|
|
438
281
|
/**
|
|
439
282
|
* Re-export all tool input types from the official Claude Agent SDK.
|
|
@@ -495,11 +338,11 @@ export type FileModifyingToolName = "Write" | "Edit" | "MultiEdit";
|
|
|
495
338
|
*
|
|
496
339
|
* This includes all tool inputs that have well-defined type structures.
|
|
497
340
|
*/
|
|
498
|
-
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;
|
|
499
342
|
/**
|
|
500
343
|
* Tool names for all known tools with typed inputs.
|
|
501
344
|
*/
|
|
502
|
-
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";
|
|
503
346
|
/**
|
|
504
347
|
* Type mapping from tool name to tool input type.
|
|
505
348
|
*
|
|
@@ -526,4 +369,8 @@ export interface ToolInputMap {
|
|
|
526
369
|
WebFetch: WebFetchInput;
|
|
527
370
|
WebSearch: WebSearchInput;
|
|
528
371
|
AskUserQuestion: AskUserQuestionInput;
|
|
372
|
+
ListMcpResources: ListMcpResourcesInput;
|
|
373
|
+
Mcp: McpInput;
|
|
374
|
+
ReadMcpResource: ReadMcpResourceInput;
|
|
375
|
+
Config: ConfigInput;
|
|
529
376
|
}
|