@goodfoot/claude-code-hooks 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cli.js +0 -1
- package/dist/constants.js +1 -0
- package/dist/hooks.js +35 -0
- package/dist/index.js +2 -2
- package/dist/outputs.js +14 -0
- package/dist/scaffold.js +1 -0
- package/dist/types.js +1 -0
- package/package.json +2 -2
- package/types/hooks.d.ts +32 -2
- package/types/index.d.ts +4 -4
- package/types/outputs.d.ts +28 -1
- package/types/types.d.ts +16 -4
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ npm test # Run tests
|
|
|
107
107
|
|
|
108
108
|
### Available Hook Types
|
|
109
109
|
|
|
110
|
-
The `--hooks` argument accepts a comma-separated list of any of these
|
|
110
|
+
The `--hooks` argument accepts a comma-separated list of any of these 18 event types:
|
|
111
111
|
|
|
112
112
|
| Hook Type | Description |
|
|
113
113
|
| -------------------- | ------------------------------------------------------------------------ |
|
|
@@ -126,6 +126,7 @@ The `--hooks` argument accepts a comma-separated list of any of these 17 event t
|
|
|
126
126
|
| `PostCompact` | After context compaction completes |
|
|
127
127
|
| `PermissionRequest` | When permission is requested |
|
|
128
128
|
| `Setup` | On init, install, or update events |
|
|
129
|
+
| `TaskCreated` | When a new task is created and assigned to a teammate |
|
|
129
130
|
| `CwdChanged` | When Claude Code's working directory changes; return `watchPaths` to register paths for `FileChanged` |
|
|
130
131
|
| `FileChanged` | When a watched file changes on disk (`change`, `add`, or `unlink`); return `watchPaths` to update the watched set |
|
|
131
132
|
|
package/dist/cli.js
CHANGED
package/dist/constants.js
CHANGED
|
@@ -22,6 +22,7 @@ export const HOOK_FACTORY_TO_EVENT = {
|
|
|
22
22
|
permissionRequestHook: "PermissionRequest",
|
|
23
23
|
setupHook: "Setup",
|
|
24
24
|
teammateIdleHook: "TeammateIdle",
|
|
25
|
+
taskCreatedHook: "TaskCreated",
|
|
25
26
|
taskCompletedHook: "TaskCompleted",
|
|
26
27
|
elicitationHook: "Elicitation",
|
|
27
28
|
elicitationResultHook: "ElicitationResult",
|
package/dist/hooks.js
CHANGED
|
@@ -530,6 +530,41 @@ export function teammateIdleHook(config, handler) {
|
|
|
530
530
|
return createHookFunction("TeammateIdle", config, handler);
|
|
531
531
|
}
|
|
532
532
|
// ============================================================================
|
|
533
|
+
// TaskCreated Hook Factory
|
|
534
|
+
// ============================================================================
|
|
535
|
+
/**
|
|
536
|
+
* Creates a TaskCreated hook handler.
|
|
537
|
+
*
|
|
538
|
+
* TaskCreated hooks fire when a new task is created and assigned to a teammate,
|
|
539
|
+
* allowing you to:
|
|
540
|
+
* - Observe task creation events
|
|
541
|
+
* - Log task assignments for auditing
|
|
542
|
+
* - React to new work being assigned
|
|
543
|
+
*
|
|
544
|
+
* **Matcher**: No matcher support - fires on all task creation events
|
|
545
|
+
* @param config - Hook configuration with optional timeout (matcher is ignored)
|
|
546
|
+
* @param handler - The handler function to execute
|
|
547
|
+
* @returns A hook function that can be exported as the default export
|
|
548
|
+
* @example
|
|
549
|
+
* ```typescript
|
|
550
|
+
* import { taskCreatedHook, taskCreatedOutput } from '@goodfoot/claude-code-hooks';
|
|
551
|
+
*
|
|
552
|
+
* // Log task creation
|
|
553
|
+
* export default taskCreatedHook({}, async (input, { logger }) => {
|
|
554
|
+
* logger.info('Task created', {
|
|
555
|
+
* taskId: input.task_id,
|
|
556
|
+
* taskSubject: input.task_subject
|
|
557
|
+
* });
|
|
558
|
+
*
|
|
559
|
+
* return taskCreatedOutput({});
|
|
560
|
+
* });
|
|
561
|
+
* ```
|
|
562
|
+
* @see https://code.claude.com/docs/en/hooks#taskcreated
|
|
563
|
+
*/
|
|
564
|
+
export function taskCreatedHook(config, handler) {
|
|
565
|
+
return createHookFunction("TaskCreated", config, handler);
|
|
566
|
+
}
|
|
567
|
+
// ============================================================================
|
|
533
568
|
// TaskCompleted Hook Factory
|
|
534
569
|
// ============================================================================
|
|
535
570
|
/**
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ CLAUDE_ENV_VARS, getEnvFilePath,
|
|
|
12
12
|
// Getters
|
|
13
13
|
getProjectDir, isRemoteEnvironment, } from "./env.js";
|
|
14
14
|
// Hook factory functions - all 25 hook types
|
|
15
|
-
export { configChangeHook, cwdChangedHook, elicitationHook, elicitationResultHook, fileChangedHook, instructionsLoadedHook, notificationHook, permissionRequestHook, postCompactHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopFailureHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
|
|
15
|
+
export { configChangeHook, cwdChangedHook, elicitationHook, elicitationResultHook, fileChangedHook, instructionsLoadedHook, notificationHook, permissionRequestHook, postCompactHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopFailureHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, taskCreatedHook, teammateIdleHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
|
|
16
16
|
// Logger exports
|
|
17
17
|
export { LOG_LEVELS, Logger, logger } from "./logger.js";
|
|
18
18
|
// Output builder functions
|
|
@@ -20,7 +20,7 @@ export { configChangeOutput, cwdChangedOutput,
|
|
|
20
20
|
// Exit codes
|
|
21
21
|
EXIT_CODES, elicitationOutput, elicitationResultOutput, fileChangedOutput, instructionsLoadedOutput, notificationOutput, permissionRequestOutput, postCompactOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput,
|
|
22
22
|
// All 25 output builder functions
|
|
23
|
-
preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopFailureOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
|
|
23
|
+
preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopFailureOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, taskCreatedOutput, teammateIdleOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
|
|
24
24
|
// Runtime exports - execute function
|
|
25
25
|
export {
|
|
26
26
|
// Main execute function for compiled hooks
|
package/dist/outputs.js
CHANGED
|
@@ -348,6 +348,20 @@ export const setupOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("Setu
|
|
|
348
348
|
* ```
|
|
349
349
|
*/
|
|
350
350
|
export const teammateIdleOutput = /* @__PURE__ */ createExitCodeOutputBuilder("TeammateIdle");
|
|
351
|
+
/**
|
|
352
|
+
* Creates an output for TaskCreated hooks.
|
|
353
|
+
* @param options - Configuration options for the hook output
|
|
354
|
+
* @returns A TaskCreatedOutput object ready for the runtime
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* // Allow task creation
|
|
358
|
+
* taskCreatedOutput({});
|
|
359
|
+
*
|
|
360
|
+
* // Block with feedback
|
|
361
|
+
* taskCreatedOutput({ stderr: 'Cannot create task: missing required fields.' });
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
export const taskCreatedOutput = /* @__PURE__ */ createExitCodeOutputBuilder("TaskCreated");
|
|
351
365
|
/**
|
|
352
366
|
* Creates an output for TaskCompleted hooks.
|
|
353
367
|
* @param options - Configuration options for the hook output
|
package/dist/scaffold.js
CHANGED
|
@@ -53,6 +53,7 @@ const EVENT_TO_OUTPUT_FUNCTION = {
|
|
|
53
53
|
PermissionRequest: "permissionRequestOutput",
|
|
54
54
|
Setup: "setupOutput",
|
|
55
55
|
TeammateIdle: "teammateIdleOutput",
|
|
56
|
+
TaskCreated: "taskCreatedOutput",
|
|
56
57
|
TaskCompleted: "taskCompletedOutput",
|
|
57
58
|
Elicitation: "elicitationOutput",
|
|
58
59
|
ElicitationResult: "elicitationResultOutput",
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodfoot/claude-code-hooks",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
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": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"typescript": "^5.9.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
54
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.86",
|
|
55
55
|
"@biomejs/biome": "2.4.9",
|
|
56
56
|
"@types/node": "^24",
|
|
57
57
|
"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 { ConfigChangeOutput, CwdChangedOutput, ElicitationOutput, ElicitationResultOutput, FileChangedOutput, InstructionsLoadedOutput, NotificationOutput, PermissionRequestOutput, PostCompactOutput, PostToolUseFailureOutput, PostToolUseOutput, PreCompactOutput, PreToolUseOutput, SessionEndOutput, SessionStartOutput, SetupOutput, SpecificHookOutput, StopFailureOutput, StopOutput, SubagentStartOutput, SubagentStopOutput, TaskCompletedOutput, TeammateIdleOutput, UserPromptSubmitOutput, WorktreeCreateOutput, WorktreeRemoveOutput } from "./outputs.js";
|
|
26
|
-
import type { ConfigChangeInput, CwdChangedInput, ElicitationInput, ElicitationResultInput, FileChangedInput, HookEventName, InstructionsLoadedInput, KnownToolName, NotificationInput, PermissionRequestInput, PostCompactInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseInput, SessionEndInput, SessionStartInput, SetupInput, StopFailureInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, WorktreeCreateInput, WorktreeRemoveInput } from "./types.js";
|
|
25
|
+
import type { ConfigChangeOutput, CwdChangedOutput, ElicitationOutput, ElicitationResultOutput, FileChangedOutput, InstructionsLoadedOutput, NotificationOutput, PermissionRequestOutput, PostCompactOutput, PostToolUseFailureOutput, PostToolUseOutput, PreCompactOutput, PreToolUseOutput, SessionEndOutput, SessionStartOutput, SetupOutput, SpecificHookOutput, StopFailureOutput, StopOutput, SubagentStartOutput, SubagentStopOutput, TaskCompletedOutput, TaskCreatedOutput, TeammateIdleOutput, UserPromptSubmitOutput, WorktreeCreateOutput, WorktreeRemoveOutput } from "./outputs.js";
|
|
26
|
+
import type { ConfigChangeInput, CwdChangedInput, ElicitationInput, ElicitationResultInput, FileChangedInput, HookEventName, InstructionsLoadedInput, KnownToolName, NotificationInput, PermissionRequestInput, PostCompactInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseInput, SessionEndInput, SessionStartInput, SetupInput, StopFailureInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TaskCreatedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, WorktreeCreateInput, WorktreeRemoveInput } from "./types.js";
|
|
27
27
|
/**
|
|
28
28
|
* Configuration options for hook factories.
|
|
29
29
|
*
|
|
@@ -895,6 +895,36 @@ export declare function setupHook(config: HookConfig, handler: HookHandler<Setup
|
|
|
895
895
|
* @see https://code.claude.com/docs/en/hooks#teammateidle
|
|
896
896
|
*/
|
|
897
897
|
export declare function teammateIdleHook(config: HookConfig, handler: HookHandler<TeammateIdleInput, TeammateIdleOutput>): HookFunction<TeammateIdleInput, TeammateIdleOutput>;
|
|
898
|
+
/**
|
|
899
|
+
* Creates a TaskCreated hook handler.
|
|
900
|
+
*
|
|
901
|
+
* TaskCreated hooks fire when a new task is created and assigned to a teammate,
|
|
902
|
+
* allowing you to:
|
|
903
|
+
* - Observe task creation events
|
|
904
|
+
* - Log task assignments for auditing
|
|
905
|
+
* - React to new work being assigned
|
|
906
|
+
*
|
|
907
|
+
* **Matcher**: No matcher support - fires on all task creation events
|
|
908
|
+
* @param config - Hook configuration with optional timeout (matcher is ignored)
|
|
909
|
+
* @param handler - The handler function to execute
|
|
910
|
+
* @returns A hook function that can be exported as the default export
|
|
911
|
+
* @example
|
|
912
|
+
* ```typescript
|
|
913
|
+
* import { taskCreatedHook, taskCreatedOutput } from '@goodfoot/claude-code-hooks';
|
|
914
|
+
*
|
|
915
|
+
* // Log task creation
|
|
916
|
+
* export default taskCreatedHook({}, async (input, { logger }) => {
|
|
917
|
+
* logger.info('Task created', {
|
|
918
|
+
* taskId: input.task_id,
|
|
919
|
+
* taskSubject: input.task_subject
|
|
920
|
+
* });
|
|
921
|
+
*
|
|
922
|
+
* return taskCreatedOutput({});
|
|
923
|
+
* });
|
|
924
|
+
* ```
|
|
925
|
+
* @see https://code.claude.com/docs/en/hooks#taskcreated
|
|
926
|
+
*/
|
|
927
|
+
export declare function taskCreatedHook(config: HookConfig, handler: HookHandler<TaskCreatedInput, TaskCreatedOutput>): HookFunction<TaskCreatedInput, TaskCreatedOutput>;
|
|
898
928
|
/**
|
|
899
929
|
* Creates a TaskCompleted hook handler.
|
|
900
930
|
*
|
package/types/index.d.ts
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
export type * from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
|
9
9
|
export { CLAUDE_ENV_VARS, getEnvFilePath, getProjectDir, isRemoteEnvironment, } from "./env.js";
|
|
10
10
|
export type { HookConfig, HookContext, HookFunction, HookHandler, SessionStartContext, TypedHookConfig, TypedPermissionRequestInput, TypedPostToolUseFailureHookInput, TypedPostToolUseHookInput, TypedPreToolUseHookInput, } from "./hooks.js";
|
|
11
|
-
export { configChangeHook, cwdChangedHook, elicitationHook, elicitationResultHook, fileChangedHook, instructionsLoadedHook, notificationHook, permissionRequestHook, postCompactHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopFailureHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
|
|
11
|
+
export { configChangeHook, cwdChangedHook, elicitationHook, elicitationResultHook, fileChangedHook, instructionsLoadedHook, notificationHook, permissionRequestHook, postCompactHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopFailureHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, taskCreatedHook, teammateIdleHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
|
|
12
12
|
export type { LogEvent, LogEventError, LogEventHandler, LoggerConfig, LogLevel, Unsubscribe } from "./logger.js";
|
|
13
13
|
export { LOG_LEVELS, Logger, logger } from "./logger.js";
|
|
14
14
|
export type {
|
|
15
15
|
/** @deprecated Use CommonOptions instead */
|
|
16
|
-
BaseOptions, CommonOptions, ConfigChangeOptions, CwdChangedHookSpecificOutput, CwdChangedOptions, ElicitationHookSpecificOutput, ElicitationOptions, ElicitationResultHookSpecificOutput, ElicitationResultOptions, ExitCode, ExitCodeOptions, FileChangedHookSpecificOutput, FileChangedOptions, HookOutput, HookSpecificOutput, InstructionsLoadedOptions, NotificationHookSpecificOutput, NotificationOptions, PermissionRequestAllowDecision, PermissionRequestDecision, PermissionRequestDenyDecision, PermissionRequestHookSpecificOutput, PermissionRequestOptions, PostCompactOptions, PostToolUseFailureHookSpecificOutput, PostToolUseFailureOptions, PostToolUseHookSpecificOutput, PostToolUseOptions, PreCompactOptions, PreToolUseHookSpecificOutput, PreToolUseOptions, SessionEndOptions, SessionStartHookSpecificOutput, SessionStartOptions, SetupHookSpecificOutput, SetupOptions, StopFailureOptions, StopOptions, SubagentStartHookSpecificOutput, SubagentStartOptions, SubagentStopOptions, SyncHookJSONOutput, TaskCompletedOptions, TeammateIdleOptions, UserPromptSubmitHookSpecificOutput, UserPromptSubmitOptions, WorktreeCreateOptions, WorktreeRemoveOptions, } from "./outputs.js";
|
|
17
|
-
export { configChangeOutput, cwdChangedOutput, EXIT_CODES, elicitationOutput, elicitationResultOutput, fileChangedOutput, instructionsLoadedOutput, notificationOutput, permissionRequestOutput, postCompactOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopFailureOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
|
|
16
|
+
BaseOptions, CommonOptions, ConfigChangeOptions, CwdChangedHookSpecificOutput, CwdChangedOptions, ElicitationHookSpecificOutput, ElicitationOptions, ElicitationResultHookSpecificOutput, ElicitationResultOptions, ExitCode, ExitCodeOptions, FileChangedHookSpecificOutput, FileChangedOptions, HookOutput, HookSpecificOutput, InstructionsLoadedOptions, NotificationHookSpecificOutput, NotificationOptions, PermissionRequestAllowDecision, PermissionRequestDecision, PermissionRequestDenyDecision, PermissionRequestHookSpecificOutput, PermissionRequestOptions, PostCompactOptions, PostToolUseFailureHookSpecificOutput, PostToolUseFailureOptions, PostToolUseHookSpecificOutput, PostToolUseOptions, PreCompactOptions, PreToolUseHookSpecificOutput, PreToolUseOptions, SessionEndOptions, SessionStartHookSpecificOutput, SessionStartOptions, SetupHookSpecificOutput, SetupOptions, StopFailureOptions, StopOptions, SubagentStartHookSpecificOutput, SubagentStartOptions, SubagentStopOptions, SyncHookJSONOutput, TaskCompletedOptions, TaskCreatedOptions, TeammateIdleOptions, UserPromptSubmitHookSpecificOutput, UserPromptSubmitOptions, WorktreeCreateOptions, WorktreeRemoveOptions, } from "./outputs.js";
|
|
17
|
+
export { configChangeOutput, cwdChangedOutput, EXIT_CODES, elicitationOutput, elicitationResultOutput, fileChangedOutput, instructionsLoadedOutput, notificationOutput, permissionRequestOutput, postCompactOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopFailureOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, taskCreatedOutput, teammateIdleOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
|
|
18
18
|
export { execute, } from "./runtime.js";
|
|
19
19
|
export type { ContentContext, PatternCheckResult, ToolUseInput } from "./tool-helpers.js";
|
|
20
20
|
export { checkContentForPattern, forEachContent, getFilePath, isAskUserQuestionTool, isBashTool, isConfigTool, isEditTool, isExitPlanModeTool, isFileModifyingTool, isGlobTool, isGrepTool, isJsTsFile, isKillShellTool, isListMcpResourcesTool, isMcpTool, isMultiEditTool, isNotebookEditTool, isReadMcpResourceTool, isReadTool, isTaskOutputTool, isTaskTool, isTodoWriteTool, isTsFile, isWebFetchTool, isWebSearchTool, isWriteTool, } from "./tool-helpers.js";
|
|
21
|
-
export type { BaseHookInput, ConfigChangeInput, ConfigInput, CwdChangedInput, ElicitationInput, ElicitationResultInput, FileChangedInput, FileModifyingToolInput, FileModifyingToolName, HookEventName, HookInput, InstructionsLoadedInput, KnownToolInput, KnownToolName, ListMcpResourcesInput, McpInput, MultiEditEntry, MultiEditToolInput, NotificationInput, PermissionMode, PermissionRequestInput, PermissionUpdate, PostCompactInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreCompactTrigger, PreToolUseInput, ReadMcpResourceInput, SessionEndInput, SessionEndReason, SessionStartInput, SessionStartSource, SetupInput, SetupTrigger, StopFailureInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, WorktreeCreateInput, WorktreeRemoveInput, } from "./types.js";
|
|
21
|
+
export type { BaseHookInput, ConfigChangeInput, ConfigInput, CwdChangedInput, ElicitationInput, ElicitationResultInput, FileChangedInput, FileModifyingToolInput, FileModifyingToolName, HookEventName, HookInput, InstructionsLoadedInput, KnownToolInput, KnownToolName, ListMcpResourcesInput, McpInput, MultiEditEntry, MultiEditToolInput, NotificationInput, PermissionMode, PermissionRequestInput, PermissionUpdate, PostCompactInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreCompactTrigger, PreToolUseInput, ReadMcpResourceInput, SessionEndInput, SessionEndReason, SessionStartInput, SessionStartSource, SetupInput, SetupTrigger, StopFailureInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TaskCreatedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, WorktreeCreateInput, WorktreeRemoveInput, } from "./types.js";
|
|
22
22
|
export { HOOK_EVENT_NAMES } from "./types.js";
|
package/types/outputs.d.ts
CHANGED
|
@@ -252,6 +252,10 @@ export type SetupOutput = BaseSpecificOutput<"Setup">;
|
|
|
252
252
|
*
|
|
253
253
|
*/
|
|
254
254
|
export type TeammateIdleOutput = BaseSpecificOutput<"TeammateIdle">;
|
|
255
|
+
/**
|
|
256
|
+
*
|
|
257
|
+
*/
|
|
258
|
+
export type TaskCreatedOutput = BaseSpecificOutput<"TaskCreated">;
|
|
255
259
|
/**
|
|
256
260
|
*
|
|
257
261
|
*/
|
|
@@ -291,7 +295,7 @@ export type FileChangedOutput = BaseSpecificOutput<"FileChanged">;
|
|
|
291
295
|
/**
|
|
292
296
|
* Union of all specific output types.
|
|
293
297
|
*/
|
|
294
|
-
export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | StopFailureOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PostCompactOutput | PermissionRequestOutput | SetupOutput | TeammateIdleOutput | TaskCompletedOutput | ElicitationOutput | ElicitationResultOutput | ConfigChangeOutput | InstructionsLoadedOutput | WorktreeCreateOutput | WorktreeRemoveOutput | CwdChangedOutput | FileChangedOutput;
|
|
298
|
+
export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | StopFailureOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PostCompactOutput | PermissionRequestOutput | SetupOutput | TeammateIdleOutput | TaskCreatedOutput | TaskCompletedOutput | ElicitationOutput | ElicitationResultOutput | ConfigChangeOutput | InstructionsLoadedOutput | WorktreeCreateOutput | WorktreeRemoveOutput | CwdChangedOutput | FileChangedOutput;
|
|
295
299
|
/**
|
|
296
300
|
* Options for decision-based hooks (Stop, SubagentStop).
|
|
297
301
|
*/
|
|
@@ -737,6 +741,29 @@ export declare const teammateIdleOutput: ({ stderr }?: ExitCodeOptions) => {
|
|
|
737
741
|
stdout: SyncHookJSONOutput;
|
|
738
742
|
stderr?: string;
|
|
739
743
|
};
|
|
744
|
+
/**
|
|
745
|
+
* Options for the TaskCreated output builder.
|
|
746
|
+
* TaskCreated hooks use exit codes only, not JSON decision control.
|
|
747
|
+
*/
|
|
748
|
+
export type TaskCreatedOptions = ExitCodeOptions;
|
|
749
|
+
/**
|
|
750
|
+
* Creates an output for TaskCreated hooks.
|
|
751
|
+
* @param options - Configuration options for the hook output
|
|
752
|
+
* @returns A TaskCreatedOutput object ready for the runtime
|
|
753
|
+
* @example
|
|
754
|
+
* ```typescript
|
|
755
|
+
* // Allow task creation
|
|
756
|
+
* taskCreatedOutput({});
|
|
757
|
+
*
|
|
758
|
+
* // Block with feedback
|
|
759
|
+
* taskCreatedOutput({ stderr: 'Cannot create task: missing required fields.' });
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
export declare const taskCreatedOutput: ({ stderr }?: ExitCodeOptions) => {
|
|
763
|
+
readonly _type: "TaskCreated";
|
|
764
|
+
stdout: SyncHookJSONOutput;
|
|
765
|
+
stderr?: string;
|
|
766
|
+
};
|
|
740
767
|
/**
|
|
741
768
|
* Options for the TaskCompleted output builder.
|
|
742
769
|
* TaskCompleted hooks use exit codes only, not JSON decision control.
|
package/types/types.d.ts
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* Re-exports types from @anthropic-ai/claude-agent-sdk with "SDK" prefix.
|
|
13
13
|
* These are used as base types for extension, ensuring synchronization with the SDK.
|
|
14
14
|
*/
|
|
15
|
-
export type { BaseHookInput as SDKBaseHookInput, ConfigChangeHookInput as SDKConfigChangeHookInput, CwdChangedHookInput as SDKCwdChangedHookInput, ElicitationHookInput as SDKElicitationHookInput, ElicitationResultHookInput as SDKElicitationResultHookInput, FileChangedHookInput as SDKFileChangedHookInput, HookEvent as SDKHookEvent, HookInput as SDKHookInput, InstructionsLoadedHookInput as SDKInstructionsLoadedHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostCompactHookInput as SDKPostCompactHookInput, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopFailureHookInput as SDKStopFailureHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, WorktreeCreateHookInput as SDKWorktreeCreateHookInput, WorktreeRemoveHookInput as SDKWorktreeRemoveHookInput, } from "@anthropic-ai/claude-agent-sdk";
|
|
16
|
-
import type { BaseHookInput as SDKBaseHookInput, ConfigChangeHookInput as SDKConfigChangeHookInput, CwdChangedHookInput as SDKCwdChangedHookInput, ElicitationHookInput as SDKElicitationHookInput, ElicitationResultHookInput as SDKElicitationResultHookInput, FileChangedHookInput as SDKFileChangedHookInput, InstructionsLoadedHookInput as SDKInstructionsLoadedHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostCompactHookInput as SDKPostCompactHookInput, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopFailureHookInput as SDKStopFailureHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, WorktreeCreateHookInput as SDKWorktreeCreateHookInput, WorktreeRemoveHookInput as SDKWorktreeRemoveHookInput } from "@anthropic-ai/claude-agent-sdk";
|
|
15
|
+
export type { BaseHookInput as SDKBaseHookInput, ConfigChangeHookInput as SDKConfigChangeHookInput, CwdChangedHookInput as SDKCwdChangedHookInput, ElicitationHookInput as SDKElicitationHookInput, ElicitationResultHookInput as SDKElicitationResultHookInput, FileChangedHookInput as SDKFileChangedHookInput, HookEvent as SDKHookEvent, HookInput as SDKHookInput, InstructionsLoadedHookInput as SDKInstructionsLoadedHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostCompactHookInput as SDKPostCompactHookInput, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopFailureHookInput as SDKStopFailureHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TaskCreatedHookInput as SDKTaskCreatedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, WorktreeCreateHookInput as SDKWorktreeCreateHookInput, WorktreeRemoveHookInput as SDKWorktreeRemoveHookInput, } from "@anthropic-ai/claude-agent-sdk";
|
|
16
|
+
import type { BaseHookInput as SDKBaseHookInput, ConfigChangeHookInput as SDKConfigChangeHookInput, CwdChangedHookInput as SDKCwdChangedHookInput, ElicitationHookInput as SDKElicitationHookInput, ElicitationResultHookInput as SDKElicitationResultHookInput, FileChangedHookInput as SDKFileChangedHookInput, InstructionsLoadedHookInput as SDKInstructionsLoadedHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostCompactHookInput as SDKPostCompactHookInput, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopFailureHookInput as SDKStopFailureHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TaskCreatedHookInput as SDKTaskCreatedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, WorktreeCreateHookInput as SDKWorktreeCreateHookInput, WorktreeRemoveHookInput as SDKWorktreeRemoveHookInput } from "@anthropic-ai/claude-agent-sdk";
|
|
17
17
|
import type { AgentInput, AskUserQuestionInput, BashInput, ConfigInput, ExitPlanModeInput, FileEditInput, FileReadInput, FileWriteInput, GlobInput, GrepInput, TaskStopInput as KillShellInput, ListMcpResourcesInput, McpInput, NotebookEditInput, ReadMcpResourceInput, TaskOutputInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
|
18
18
|
/**
|
|
19
19
|
* Permission mode for controlling how tool executions are handled.
|
|
@@ -183,6 +183,18 @@ export type SetupInput = {
|
|
|
183
183
|
export type TeammateIdleInput = {
|
|
184
184
|
[K in keyof SDKTeammateIdleHookInput]: SDKTeammateIdleHookInput[K];
|
|
185
185
|
} & {};
|
|
186
|
+
/**
|
|
187
|
+
* Input for TaskCreated hooks.
|
|
188
|
+
*
|
|
189
|
+
* Fires when a new task is created and assigned to a teammate, allowing you to:
|
|
190
|
+
* - Observe task creation events
|
|
191
|
+
* - Log task assignments for auditing
|
|
192
|
+
* - React to new work being assigned
|
|
193
|
+
* @see https://code.claude.com/docs/en/hooks#taskcreated
|
|
194
|
+
*/
|
|
195
|
+
export type TaskCreatedInput = {
|
|
196
|
+
[K in keyof SDKTaskCreatedHookInput]: SDKTaskCreatedHookInput[K];
|
|
197
|
+
} & {};
|
|
186
198
|
/**
|
|
187
199
|
* Input for TaskCompleted hooks.
|
|
188
200
|
* @see https://code.claude.com/docs/en/hooks#taskcompleted
|
|
@@ -381,7 +393,7 @@ export type SetupTrigger = "init" | "maintenance";
|
|
|
381
393
|
* ```
|
|
382
394
|
* @see https://code.claude.com/docs/en/hooks
|
|
383
395
|
*/
|
|
384
|
-
export type HookInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | NotificationInput | UserPromptSubmitInput | SessionStartInput | SessionEndInput | StopInput | StopFailureInput | SubagentStartInput | SubagentStopInput | PreCompactInput | PostCompactInput | PermissionRequestInput | SetupInput | TeammateIdleInput | TaskCompletedInput | ElicitationInput | ElicitationResultInput | ConfigChangeInput | InstructionsLoadedInput | WorktreeCreateInput | WorktreeRemoveInput | CwdChangedInput | FileChangedInput;
|
|
396
|
+
export type HookInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | NotificationInput | UserPromptSubmitInput | SessionStartInput | SessionEndInput | StopInput | StopFailureInput | SubagentStartInput | SubagentStopInput | PreCompactInput | PostCompactInput | PermissionRequestInput | SetupInput | TeammateIdleInput | TaskCreatedInput | TaskCompletedInput | ElicitationInput | ElicitationResultInput | ConfigChangeInput | InstructionsLoadedInput | WorktreeCreateInput | WorktreeRemoveInput | CwdChangedInput | FileChangedInput;
|
|
385
397
|
/**
|
|
386
398
|
* Hook event name literal union.
|
|
387
399
|
*
|
|
@@ -399,7 +411,7 @@ export type HookEventName = HookInput["hook_event_name"];
|
|
|
399
411
|
* }
|
|
400
412
|
* ```
|
|
401
413
|
*/
|
|
402
|
-
export declare const HOOK_EVENT_NAMES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "Setup", "TeammateIdle", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "InstructionsLoaded", "WorktreeCreate", "WorktreeRemove", "CwdChanged", "FileChanged"];
|
|
414
|
+
export declare const HOOK_EVENT_NAMES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "InstructionsLoaded", "WorktreeCreate", "WorktreeRemove", "CwdChanged", "FileChanged"];
|
|
403
415
|
export type { SDKPermissionUpdate as PermissionUpdate };
|
|
404
416
|
/**
|
|
405
417
|
* Re-export all tool input types from the official Claude Agent SDK.
|