cc-hooks-ts 2.1.34 → 2.1.49

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 CHANGED
@@ -98,25 +98,6 @@ Then, load defined hooks in your Claude Code settings at `~/.claude/settings.jso
98
98
  }
99
99
  ```
100
100
 
101
- If you are using native install, you can run hooks with Bun via `BUN_BE_BUN=1 claude`.
102
-
103
- ```json
104
- {
105
- "hooks": {
106
- "SessionStart": [
107
- {
108
- "hooks": [
109
- {
110
- "type": "command",
111
- "command": "BUN_BE_BUN=1 claude run -i --silent path/to/your/sessionHook.ts"
112
- }
113
- ]
114
- }
115
- ]
116
- }
117
- }
118
- ```
119
-
120
101
  ## Tool Specific Hooks
121
102
 
122
103
  In `PreToolUse`, `PostToolUse`, and `PostToolUseFailure` events, you can define hooks specific to tools by specifying tool names in the trigger configuration.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { AgentInput, BashInput, ExitPlanModeInput, FileEditInput, FileReadInput, FileWriteInput, GlobInput, GrepInput, ListMcpResourcesInput, NotebookEditInput, ReadMcpResourceInput, TaskOutputInput, TaskStopInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools";
2
+ import { AgentInput, AgentOutput, AskUserQuestionInput, AskUserQuestionOutput, BashInput, BashOutput, ExitPlanModeInput, ExitPlanModeOutput, FileEditInput, FileEditOutput, FileReadInput, FileReadOutput, FileWriteInput, FileWriteOutput, GlobInput, GlobOutput, GrepInput, GrepOutput, ListMcpResourcesInput, ListMcpResourcesOutput, 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;
@@ -73,6 +73,7 @@ declare const HookInputSchemas: {
73
73
  readonly transcript_path: v.StringSchema<undefined>;
74
74
  readonly hook_event_name: v.LiteralSchema<"Stop", undefined>;
75
75
  } & {
76
+ last_assistant_message: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
76
77
  stop_hook_active: v.BooleanSchema<undefined>;
77
78
  }, undefined>;
78
79
  readonly SubagentStart: v.ObjectSchema<{
@@ -95,6 +96,7 @@ declare const HookInputSchemas: {
95
96
  agent_id: v.StringSchema<undefined>;
96
97
  agent_transcript_path: v.StringSchema<undefined>;
97
98
  agent_type: v.StringSchema<undefined>;
99
+ last_assistant_message: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
98
100
  stop_hook_active: v.BooleanSchema<undefined>;
99
101
  }, undefined>;
100
102
  readonly PreCompact: v.ObjectSchema<{
@@ -160,7 +162,7 @@ declare const HookInputSchemas: {
160
162
  readonly type: v.LiteralSchema<"removeRules", undefined>;
161
163
  }, undefined>, v.ObjectSchema<{
162
164
  readonly destination: v.PicklistSchema<["userSettings", "projectSettings", "localSettings", "session", "cliArg"], undefined>;
163
- readonly mode: v.PicklistSchema<["acceptEdits", "bypassPermissions", "default", "dontAsk", "delegate", "plan"], undefined>;
165
+ readonly mode: v.PicklistSchema<["acceptEdits", "bypassPermissions", "default", "dontAsk", "plan"], undefined>;
164
166
  readonly type: v.LiteralSchema<"setMode", undefined>;
165
167
  }, undefined>, v.ObjectSchema<{
166
168
  readonly destination: v.PicklistSchema<["userSettings", "projectSettings", "localSettings", "session", "cliArg"], undefined>;
@@ -206,6 +208,16 @@ declare const HookInputSchemas: {
206
208
  team_name: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
207
209
  teammate_name: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
208
210
  }, undefined>;
211
+ readonly ConfigChange: v.ObjectSchema<{
212
+ readonly cwd: v.StringSchema<undefined>;
213
+ readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
214
+ readonly session_id: v.StringSchema<undefined>;
215
+ readonly transcript_path: v.StringSchema<undefined>;
216
+ readonly hook_event_name: v.LiteralSchema<"ConfigChange", undefined>;
217
+ } & {
218
+ file_path: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
219
+ source: v.PicklistSchema<["local_settings", "policy_settings", "project_settings", "skills", "user_settings"], undefined>;
220
+ }, undefined>;
209
221
  };
210
222
  //#endregion
211
223
  //#region src/hooks/event.d.ts
@@ -214,7 +226,7 @@ declare const HookInputSchemas: {
214
226
  *
215
227
  * @package
216
228
  */
217
- type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted";
229
+ type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted" | "ConfigChange";
218
230
  //#endregion
219
231
  //#region src/hooks/input/types.d.ts
220
232
  /**
@@ -325,7 +337,7 @@ declare const permissionUpdateSchema: v.VariantSchema<"type", [v.ObjectSchema<{
325
337
  readonly type: v.LiteralSchema<"removeRules", undefined>;
326
338
  }, undefined>, v.ObjectSchema<{
327
339
  readonly destination: v.PicklistSchema<["userSettings", "projectSettings", "localSettings", "session", "cliArg"], undefined>;
328
- readonly mode: v.PicklistSchema<["acceptEdits", "bypassPermissions", "default", "dontAsk", "delegate", "plan"], undefined>;
340
+ readonly mode: v.PicklistSchema<["acceptEdits", "bypassPermissions", "default", "dontAsk", "plan"], undefined>;
329
341
  readonly type: v.LiteralSchema<"setMode", undefined>;
330
342
  }, undefined>, v.ObjectSchema<{
331
343
  readonly destination: v.PicklistSchema<["userSettings", "projectSettings", "localSettings", "session", "cliArg"], undefined>;
@@ -354,6 +366,7 @@ type HookOutput = {
354
366
  PermissionRequest: PermissionRequestHookOutput;
355
367
  Setup: SetupHookOutput;
356
368
  Notification: NotificationHookOutput;
369
+ ConfigChange: CommonHookOutputs;
357
370
  PreCompact: CommonHookOutputs;
358
371
  SessionEnd: CommonHookOutputs;
359
372
  TaskCompleted: CommonHookOutputs;
@@ -946,122 +959,49 @@ declare function runHook<THookTrigger extends HookTrigger = HookTrigger>(def: Ho
946
959
  * ```
947
960
  */
948
961
  interface ToolSchema {
962
+ AskUserQuestion: {
963
+ input: AskUserQuestionInput;
964
+ response: AskUserQuestionOutput;
965
+ };
949
966
  Bash: {
950
967
  input: BashInput;
951
- response: {
952
- interrupted: boolean;
953
- isImage: boolean;
954
- stderr: string;
955
- stdout: string;
956
- };
968
+ response: BashOutput;
957
969
  };
958
970
  Edit: {
959
971
  input: FileEditInput;
960
- response: {
961
- filePath: string;
962
- newString: string;
963
- oldString: string;
964
- originalFile: string;
965
- replaceAll: boolean;
966
- structuredPatch: Array<{
967
- lines: string[];
968
- newLines: number;
969
- newStart: number;
970
- oldLines: number;
971
- oldStart: number;
972
- }>;
973
- userModified: boolean;
974
- };
972
+ response: FileEditOutput;
975
973
  };
976
974
  ExitPlanMode: {
977
975
  input: ExitPlanModeInput;
978
- response: unknown;
976
+ response: ExitPlanModeOutput;
979
977
  };
980
978
  Glob: {
981
979
  input: GlobInput;
982
- response: {
983
- durationMs: number;
984
- filenames: string[];
985
- numFiles: number;
986
- truncated: boolean;
987
- };
980
+ response: GlobOutput;
988
981
  };
989
982
  Grep: {
990
983
  input: GrepInput;
991
- response: {
992
- content: string;
993
- mode: "content" | "count" | "files_with_matches";
994
- numFiles: number;
995
- numLines: number;
996
- };
984
+ response: GrepOutput;
997
985
  };
998
986
  ListMcpResources: {
999
987
  input: ListMcpResourcesInput;
1000
- response: unknown;
988
+ response: ListMcpResourcesOutput;
1001
989
  };
1002
990
  NotebookEdit: {
1003
991
  input: NotebookEditInput;
1004
- response: {
1005
- cell_type: "code" | "markdown";
1006
- edit_mode: "delete" | "insert" | "replace";
1007
- error: string;
1008
- language: string;
1009
- new_source: string;
1010
- };
992
+ response: NotebookEditOutput;
1011
993
  };
1012
994
  Read: {
1013
995
  input: FileReadInput;
1014
- response: {
1015
- file: {
1016
- cells: Array<{
1017
- cell_id: string;
1018
- cellType: "code";
1019
- language: string;
1020
- source: string;
1021
- } | {
1022
- cell_id: string;
1023
- cellType: "markdown";
1024
- source: string;
1025
- }>;
1026
- filePath: string;
1027
- };
1028
- type: "notebook";
1029
- } | {
1030
- file: {
1031
- content: string;
1032
- filePath: string;
1033
- numLines: number;
1034
- startLine: number;
1035
- totalLines: number;
1036
- };
1037
- type: "text";
1038
- };
996
+ response: FileReadOutput;
1039
997
  };
1040
998
  ReadMcpResource: {
1041
999
  input: ReadMcpResourceInput;
1042
- response: unknown;
1000
+ response: ReadMcpResourceOutput;
1043
1001
  };
1044
1002
  Task: {
1045
1003
  input: AgentInput;
1046
- response: {
1047
- content: Array<{
1048
- text: string;
1049
- type: "text";
1050
- }>;
1051
- totalDurationMs: number;
1052
- totalTokens: number;
1053
- totalToolUseCount: number;
1054
- usage: {
1055
- cache_creation: {
1056
- ephemeral_1h_input_tokens: number;
1057
- ephemeral_5m_input_tokens: number;
1058
- };
1059
- cache_creation_input_tokens: number;
1060
- cache_read_input_tokens: number;
1061
- input_tokens: number;
1062
- output_tokens: number;
1063
- };
1064
- };
1004
+ response: AgentOutput;
1065
1005
  };
1066
1006
  TaskOutput: {
1067
1007
  input: TaskOutputInput;
@@ -1069,35 +1009,23 @@ interface ToolSchema {
1069
1009
  };
1070
1010
  TaskStop: {
1071
1011
  input: TaskStopInput;
1072
- response: unknown;
1012
+ response: TaskStopOutput;
1073
1013
  };
1074
1014
  TodoWrite: {
1075
1015
  input: TodoWriteInput;
1076
- response: unknown;
1016
+ response: TodoWriteOutput;
1077
1017
  };
1078
1018
  WebFetch: {
1079
1019
  input: WebFetchInput;
1080
- response: {
1081
- bytes: number;
1082
- code: number;
1083
- codeText: string;
1084
- durationMs: number;
1085
- result: string;
1086
- url: string;
1087
- };
1020
+ response: WebFetchOutput;
1088
1021
  };
1089
1022
  WebSearch: {
1090
1023
  input: WebSearchInput;
1091
- response: unknown;
1024
+ response: WebSearchOutput;
1092
1025
  };
1093
1026
  Write: {
1094
1027
  input: FileWriteInput;
1095
- response: {
1096
- content: string;
1097
- filePath: string;
1098
- structuredPatch: unknown[];
1099
- type: "create";
1100
- };
1028
+ response: FileWriteOutput;
1101
1029
  };
1102
1030
  }
1103
1031
  //#endregion
package/dist/index.mjs CHANGED
@@ -75,7 +75,6 @@ const permissionUpdateSchema = v.variant("type", [
75
75
  "bypassPermissions",
76
76
  "default",
77
77
  "dontAsk",
78
- "delegate",
79
78
  "plan"
80
79
  ]),
81
80
  type: v.literal("setMode")
@@ -129,7 +128,10 @@ const HookInputSchemas = {
129
128
  title: v.exactOptional(v.string())
130
129
  }),
131
130
  UserPromptSubmit: buildHookInputSchema("UserPromptSubmit", { prompt: v.string() }),
132
- Stop: buildHookInputSchema("Stop", { stop_hook_active: v.boolean() }),
131
+ Stop: buildHookInputSchema("Stop", {
132
+ last_assistant_message: v.exactOptional(v.string()),
133
+ stop_hook_active: v.boolean()
134
+ }),
133
135
  SubagentStart: buildHookInputSchema("SubagentStart", {
134
136
  agent_id: v.string(),
135
137
  agent_type: v.string()
@@ -138,6 +140,7 @@ const HookInputSchemas = {
138
140
  agent_id: v.string(),
139
141
  agent_transcript_path: v.string(),
140
142
  agent_type: v.string(),
143
+ last_assistant_message: v.exactOptional(v.string()),
141
144
  stop_hook_active: v.boolean()
142
145
  }),
143
146
  PreCompact: buildHookInputSchema("PreCompact", {
@@ -177,6 +180,16 @@ const HookInputSchemas = {
177
180
  task_subject: v.string(),
178
181
  team_name: v.exactOptional(v.string()),
179
182
  teammate_name: v.exactOptional(v.string())
183
+ }),
184
+ ConfigChange: buildHookInputSchema("ConfigChange", {
185
+ file_path: v.exactOptional(v.string()),
186
+ source: v.picklist([
187
+ "local_settings",
188
+ "policy_settings",
189
+ "project_settings",
190
+ "skills",
191
+ "user_settings"
192
+ ])
180
193
  })
181
194
  };
182
195
  function isNonEmptyString(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-hooks-ts",
3
- "version": "2.1.34",
3
+ "version": "2.1.49",
4
4
  "type": "module",
5
5
  "description": "Write claude code hooks with type safety",
6
6
  "sideEffects": false,
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@arethetypeswrong/core": "0.18.2",
46
- "@types/node": "25.2.0",
46
+ "@types/node": "25.2.1",
47
47
  "@typescript/native-preview": "^7.0.0-dev.20251108.1",
48
48
  "@virtual-live-lab/eslint-config": "2.3.1",
49
49
  "@virtual-live-lab/tsconfig": "2.1.21",
@@ -54,7 +54,7 @@
54
54
  "publint": "0.3.17",
55
55
  "release-it": "19.2.4",
56
56
  "release-it-pnpm": "4.6.6",
57
- "tsdown": "0.20.1",
57
+ "tsdown": "0.20.3",
58
58
  "type-fest": "5.4.3",
59
59
  "typescript": "5.9.3",
60
60
  "typescript-eslint": "8.54.0",
@@ -62,7 +62,7 @@
62
62
  "vitest": "4.0.18"
63
63
  },
64
64
  "dependencies": {
65
- "@anthropic-ai/claude-agent-sdk": "0.2.34",
65
+ "@anthropic-ai/claude-agent-sdk": "0.2.49",
66
66
  "valibot": "^1.1.0"
67
67
  },
68
68
  "scripts": {