cc-hooks-ts 2.1.116 → 2.1.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +48 -6
- package/dist/index.mjs +8 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { AgentInput, AgentOutput, AskUserQuestionInput, AskUserQuestionOutput, BashInput, BashOutput,
|
|
2
|
+
import { AgentInput, AgentOutput, AskUserQuestionInput, AskUserQuestionOutput, BashInput, BashOutput, EnterWorktreeInput, EnterWorktreeOutput, ExitPlanModeInput, ExitPlanModeOutput, ExitWorktreeInput, ExitWorktreeOutput, FileEditInput, FileEditOutput, FileReadInput, FileReadOutput, FileWriteInput, FileWriteOutput, GlobInput, GlobOutput, GrepInput, GrepOutput, ListMcpResourcesInput, ListMcpResourcesOutput, McpInput, McpOutput, NotebookEditInput, NotebookEditOutput, ReadMcpResourceInput, ReadMcpResourceOutput, TaskOutputInput, TaskStopInput, TaskStopOutput, TodoWriteInput, TodoWriteOutput, WebFetchInput, WebFetchOutput, WebSearchInput, WebSearchOutput } from "@anthropic-ai/claude-agent-sdk/sdk-tools";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/types.d.ts
|
|
5
5
|
type Awaitable<T> = Promise<T> | T;
|
|
@@ -33,6 +33,7 @@ declare const HookInputSchemas: {
|
|
|
33
33
|
readonly hook_event_name: v.LiteralSchema<"PostToolUse", undefined>;
|
|
34
34
|
} & {
|
|
35
35
|
tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
|
|
36
|
+
duration_ms: v.ExactOptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
36
37
|
tool_input: v.UnknownSchema;
|
|
37
38
|
tool_response: v.UnknownSchema;
|
|
38
39
|
tool_use_id: v.StringSchema<undefined>;
|
|
@@ -47,11 +48,28 @@ declare const HookInputSchemas: {
|
|
|
47
48
|
readonly hook_event_name: v.LiteralSchema<"PostToolUseFailure", undefined>;
|
|
48
49
|
} & {
|
|
49
50
|
tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
|
|
51
|
+
duration_ms: v.ExactOptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
50
52
|
error: v.StringSchema<undefined>;
|
|
51
53
|
is_interrupt: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
52
54
|
tool_input: v.UnknownSchema;
|
|
53
55
|
tool_use_id: v.StringSchema<undefined>;
|
|
54
56
|
}, undefined>;
|
|
57
|
+
readonly PostToolBatch: v.ObjectSchema<{
|
|
58
|
+
readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
59
|
+
readonly agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
60
|
+
readonly cwd: v.StringSchema<undefined>;
|
|
61
|
+
readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
62
|
+
readonly session_id: v.StringSchema<undefined>;
|
|
63
|
+
readonly transcript_path: v.StringSchema<undefined>;
|
|
64
|
+
readonly hook_event_name: v.LiteralSchema<"PostToolBatch", undefined>;
|
|
65
|
+
} & {
|
|
66
|
+
tool_calls: v.ArraySchema<v.ObjectSchema<{
|
|
67
|
+
readonly tool_input: v.UnknownSchema;
|
|
68
|
+
readonly tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
|
|
69
|
+
readonly tool_response: v.ExactOptionalSchema<v.UnknownSchema, undefined>;
|
|
70
|
+
readonly tool_use_id: v.StringSchema<undefined>;
|
|
71
|
+
}, undefined>, undefined>;
|
|
72
|
+
}, undefined>;
|
|
55
73
|
readonly Notification: v.ObjectSchema<{
|
|
56
74
|
readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
57
75
|
readonly agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -422,7 +440,7 @@ declare const HookInputSchemas: {
|
|
|
422
440
|
*
|
|
423
441
|
* @package
|
|
424
442
|
*/
|
|
425
|
-
type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "UserPromptExpansion" | "SessionStart" | "SessionEnd" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PostCompact" | "PermissionRequest" | "PermissionDenied" | "Setup" | "TeammateIdle" | "TaskCreated" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "Elicitation" | "ElicitationResult" | "InstructionsLoaded" | "CwdChanged" | "FileChanged";
|
|
443
|
+
type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "PostToolBatch" | "Notification" | "UserPromptSubmit" | "UserPromptExpansion" | "SessionStart" | "SessionEnd" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PostCompact" | "PermissionRequest" | "PermissionDenied" | "Setup" | "TeammateIdle" | "TaskCreated" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "Elicitation" | "ElicitationResult" | "InstructionsLoaded" | "CwdChanged" | "FileChanged";
|
|
426
444
|
//#endregion
|
|
427
445
|
//#region src/hooks/input/types.d.ts
|
|
428
446
|
/**
|
|
@@ -446,6 +464,8 @@ type HookInput = { [EventKey in SupportedHookEvent]: EventKey extends "PreToolUs
|
|
|
446
464
|
default: BaseHookInputs["PermissionRequest"];
|
|
447
465
|
} : EventKey extends "PermissionDenied" ? ToolSpecificPermissionDeniedInput & {
|
|
448
466
|
default: BaseHookInputs["PermissionDenied"];
|
|
467
|
+
} : EventKey extends "PostToolBatch" ? {
|
|
468
|
+
default: PostToolBatchInput;
|
|
449
469
|
} : {
|
|
450
470
|
default: BaseHookInputs[EventKey];
|
|
451
471
|
} };
|
|
@@ -514,6 +534,15 @@ type ToolSpecificPermissionDeniedInput = { [K in keyof ToolSchema]: Omit<BaseHoo
|
|
|
514
534
|
tool_input: ToolSchema[K]["input"];
|
|
515
535
|
tool_name: K;
|
|
516
536
|
} };
|
|
537
|
+
type BatchedToolCall = { [K in keyof ToolSchema]: {
|
|
538
|
+
tool_input: ToolSchema[K]["input"];
|
|
539
|
+
tool_name: K;
|
|
540
|
+
tool_response?: ToolSchema[K]["response"];
|
|
541
|
+
tool_use_id: string;
|
|
542
|
+
} }[keyof ToolSchema];
|
|
543
|
+
type PostToolBatchInput = Omit<BaseHookInputs["PostToolBatch"], "tool_calls"> & {
|
|
544
|
+
tool_calls: BatchedToolCall[];
|
|
545
|
+
};
|
|
517
546
|
//#endregion
|
|
518
547
|
//#region src/hooks/permission.d.ts
|
|
519
548
|
/**
|
|
@@ -566,6 +595,7 @@ type HookOutput = {
|
|
|
566
595
|
PreToolUse: PreToolUseHookOutput;
|
|
567
596
|
PostToolUse: PostToolUseHookOutput;
|
|
568
597
|
PostToolUseFailure: PostToolUseFailureHookOutput;
|
|
598
|
+
PostToolBatch: PostToolBatchHookOutput;
|
|
569
599
|
UserPromptExpansion: UserPromptExpansionHookOutput;
|
|
570
600
|
UserPromptSubmit: UserPromptSubmitHookOutput;
|
|
571
601
|
Stop: StopHookOutput;
|
|
@@ -692,6 +722,13 @@ interface PostToolUseHookOutput extends CommonHookOutputs {
|
|
|
692
722
|
* Adds context for Claude to consider.
|
|
693
723
|
*/
|
|
694
724
|
additionalContext?: string;
|
|
725
|
+
/**
|
|
726
|
+
* Replaces the tool output before it is sent to the model.
|
|
727
|
+
*/
|
|
728
|
+
updatedToolOutput?: unknown;
|
|
729
|
+
/**
|
|
730
|
+
* Replaces the output for MCP tools only. Prefer `updatedToolOutput`, which works for all tools.
|
|
731
|
+
*/
|
|
695
732
|
updatedMCPToolOutput?: unknown;
|
|
696
733
|
};
|
|
697
734
|
reason?: string;
|
|
@@ -705,6 +742,15 @@ interface PostToolUseFailureHookOutput extends CommonHookOutputs {
|
|
|
705
742
|
additionalContext?: string;
|
|
706
743
|
};
|
|
707
744
|
}
|
|
745
|
+
interface PostToolBatchHookOutput extends CommonHookOutputs {
|
|
746
|
+
hookSpecificOutput?: {
|
|
747
|
+
hookEventName: "PostToolBatch";
|
|
748
|
+
/**
|
|
749
|
+
* Adds context for Claude to consider.
|
|
750
|
+
*/
|
|
751
|
+
additionalContext?: string;
|
|
752
|
+
};
|
|
753
|
+
}
|
|
708
754
|
/**
|
|
709
755
|
* @see {@link https://docs.anthropic.com/en/docs/claude-code/hooks#userpromptsubmit-decision-control}
|
|
710
756
|
*/
|
|
@@ -1241,10 +1287,6 @@ interface ToolSchema {
|
|
|
1241
1287
|
input: BashInput;
|
|
1242
1288
|
response: BashOutput;
|
|
1243
1289
|
};
|
|
1244
|
-
Config: {
|
|
1245
|
-
input: ConfigInput;
|
|
1246
|
-
response: ConfigOutput;
|
|
1247
|
-
};
|
|
1248
1290
|
Edit: {
|
|
1249
1291
|
input: FileEditInput;
|
|
1250
1292
|
response: FileEditOutput;
|
package/dist/index.mjs
CHANGED
|
@@ -186,17 +186,25 @@ const HookInputSchemas = {
|
|
|
186
186
|
}),
|
|
187
187
|
PostToolUse: buildHookInputSchema("PostToolUse", {
|
|
188
188
|
tool_name: v.pipe(v.string(), v.guard((s) => true)),
|
|
189
|
+
duration_ms: v.exactOptional(v.number()),
|
|
189
190
|
tool_input: v.unknown(),
|
|
190
191
|
tool_response: v.unknown(),
|
|
191
192
|
tool_use_id: v.string()
|
|
192
193
|
}),
|
|
193
194
|
PostToolUseFailure: buildHookInputSchema("PostToolUseFailure", {
|
|
194
195
|
tool_name: v.pipe(v.string(), v.guard((s) => true)),
|
|
196
|
+
duration_ms: v.exactOptional(v.number()),
|
|
195
197
|
error: v.string(),
|
|
196
198
|
is_interrupt: v.exactOptional(v.boolean()),
|
|
197
199
|
tool_input: v.unknown(),
|
|
198
200
|
tool_use_id: v.string()
|
|
199
201
|
}),
|
|
202
|
+
PostToolBatch: buildHookInputSchema("PostToolBatch", { tool_calls: v.array(v.object({
|
|
203
|
+
tool_input: v.unknown(),
|
|
204
|
+
tool_name: v.pipe(v.string(), v.guard((s) => true)),
|
|
205
|
+
tool_response: v.exactOptional(v.unknown()),
|
|
206
|
+
tool_use_id: v.string()
|
|
207
|
+
})) }),
|
|
200
208
|
Notification: buildHookInputSchema("Notification", {
|
|
201
209
|
message: v.string(),
|
|
202
210
|
notification_type: v.string(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-hooks-ts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.121",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Write claude code hooks with type safety",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vitest": "4.1.2"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.121",
|
|
66
66
|
"get-stdin": "10.0.0",
|
|
67
67
|
"valibot": "^1.1.0"
|
|
68
68
|
},
|