cc-hooks-ts 2.1.77 → 2.1.81
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 +17 -6
- package/dist/index.d.mts +20 -5
- package/dist/index.mjs +17 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -277,19 +277,30 @@ pnpm typecheck
|
|
|
277
277
|
|
|
278
278
|
### How to follow the upstream changes
|
|
279
279
|
|
|
280
|
-
1.
|
|
281
|
-
- If the command passes without errors, there are no type changes.
|
|
280
|
+
1. Check installed version of `@anthropic-ai/claude-agent-sdk`:
|
|
282
281
|
|
|
283
|
-
|
|
282
|
+
```bash
|
|
283
|
+
npm list @anthropic-ai/claude-agent-sdk
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
2. Check the latest version of `@anthropic-ai/claude-agent-sdk`:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
npm view @anthropic-ai/claude-agent-sdk version
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
- If the latest version is the same as your installed version, then there is no upstream change and you are good to go!
|
|
293
|
+
|
|
294
|
+
3. Get diff of the types.
|
|
284
295
|
|
|
285
296
|
```bash
|
|
286
|
-
npm diff --diff=@anthropic-ai/claude-agent-sdk
|
|
297
|
+
npm diff --diff=@anthropic-ai/claude-agent-sdk@<old_version> --diff=@anthropic-ai/claude-agent-sdk@<new_version> '**/*.d.ts'
|
|
287
298
|
|
|
288
299
|
# Only for humans, You can use dandavison/delta for better diff visualization
|
|
289
|
-
npm diff --diff=@anthropic-ai/claude-agent-sdk
|
|
300
|
+
npm diff --diff=@anthropic-ai/claude-agent-sdk@<old_version> --diff=@anthropic-ai/claude-agent-sdk@<new_version> '**/*.d.ts' | delta --side-by-side
|
|
290
301
|
```
|
|
291
302
|
|
|
292
|
-
|
|
303
|
+
4. Reflect the changes.
|
|
293
304
|
- Edit `src/hooks/` for changed hook input / output types.
|
|
294
305
|
- No need for adding tests in most cases since we are testing the whole type definitions in these files:
|
|
295
306
|
- `src/hooks/input/schemas.test-d.ts`
|
package/dist/index.d.mts
CHANGED
|
@@ -19,7 +19,7 @@ declare const HookInputSchemas: {
|
|
|
19
19
|
readonly transcript_path: v.StringSchema<undefined>;
|
|
20
20
|
readonly hook_event_name: v.LiteralSchema<"PreToolUse", undefined>;
|
|
21
21
|
} & {
|
|
22
|
-
tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
22
|
+
tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
|
|
23
23
|
tool_input: v.UnknownSchema;
|
|
24
24
|
tool_use_id: v.StringSchema<undefined>;
|
|
25
25
|
}, undefined>;
|
|
@@ -32,7 +32,7 @@ declare const HookInputSchemas: {
|
|
|
32
32
|
readonly transcript_path: v.StringSchema<undefined>;
|
|
33
33
|
readonly hook_event_name: v.LiteralSchema<"PostToolUse", undefined>;
|
|
34
34
|
} & {
|
|
35
|
-
tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
35
|
+
tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
|
|
36
36
|
tool_input: v.UnknownSchema;
|
|
37
37
|
tool_response: v.UnknownSchema;
|
|
38
38
|
tool_use_id: v.StringSchema<undefined>;
|
|
@@ -46,7 +46,7 @@ declare const HookInputSchemas: {
|
|
|
46
46
|
readonly transcript_path: v.StringSchema<undefined>;
|
|
47
47
|
readonly hook_event_name: v.LiteralSchema<"PostToolUseFailure", undefined>;
|
|
48
48
|
} & {
|
|
49
|
-
tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
49
|
+
tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.GuardAction<string, (s: string) => s is AutoComplete<string>, undefined>]>;
|
|
50
50
|
error: v.StringSchema<undefined>;
|
|
51
51
|
is_interrupt: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
52
52
|
tool_input: v.UnknownSchema;
|
|
@@ -88,6 +88,19 @@ declare const HookInputSchemas: {
|
|
|
88
88
|
last_assistant_message: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
89
89
|
stop_hook_active: v.BooleanSchema<undefined>;
|
|
90
90
|
}, undefined>;
|
|
91
|
+
readonly StopFailure: v.ObjectSchema<{
|
|
92
|
+
readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
93
|
+
readonly agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
94
|
+
readonly cwd: v.StringSchema<undefined>;
|
|
95
|
+
readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
96
|
+
readonly session_id: v.StringSchema<undefined>;
|
|
97
|
+
readonly transcript_path: v.StringSchema<undefined>;
|
|
98
|
+
readonly hook_event_name: v.LiteralSchema<"StopFailure", undefined>;
|
|
99
|
+
} & {
|
|
100
|
+
error: v.PicklistSchema<["authentication_failed", "billing_error", "rate_limit", "invalid_request", "server_error", "unknown", "max_output_tokens"], undefined>;
|
|
101
|
+
error_details: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
102
|
+
last_assistant_message: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
103
|
+
}, undefined>;
|
|
91
104
|
readonly SubagentStart: v.ObjectSchema<Omit<{
|
|
92
105
|
readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
93
106
|
readonly agent_type: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -162,7 +175,7 @@ declare const HookInputSchemas: {
|
|
|
162
175
|
readonly transcript_path: v.StringSchema<undefined>;
|
|
163
176
|
readonly hook_event_name: v.LiteralSchema<"SessionEnd", undefined>;
|
|
164
177
|
} & {
|
|
165
|
-
reason: v.PicklistSchema<["clear", "logout", "prompt_input_exit", "other", "bypass_permissions_disabled"], undefined>;
|
|
178
|
+
reason: v.PicklistSchema<["clear", "resume", "logout", "prompt_input_exit", "other", "bypass_permissions_disabled"], undefined>;
|
|
166
179
|
}, undefined>;
|
|
167
180
|
readonly PermissionRequest: v.ObjectSchema<{
|
|
168
181
|
readonly agent_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -340,7 +353,7 @@ declare const HookInputSchemas: {
|
|
|
340
353
|
*
|
|
341
354
|
* @package
|
|
342
355
|
*/
|
|
343
|
-
type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PostCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "Elicitation" | "ElicitationResult" | "InstructionsLoaded";
|
|
356
|
+
type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PostCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "Elicitation" | "ElicitationResult" | "InstructionsLoaded";
|
|
344
357
|
//#endregion
|
|
345
358
|
//#region src/hooks/input/types.d.ts
|
|
346
359
|
/**
|
|
@@ -474,6 +487,7 @@ type HookOutput = {
|
|
|
474
487
|
PostToolUseFailure: PostToolUseFailureHookOutput;
|
|
475
488
|
UserPromptSubmit: UserPromptSubmitHookOutput;
|
|
476
489
|
Stop: StopHookOutput;
|
|
490
|
+
StopFailure: CommonHookOutputs;
|
|
477
491
|
SubagentStart: SubagentStartHookOutput;
|
|
478
492
|
SubagentStop: SubagentStopHookOutput;
|
|
479
493
|
SessionStart: SessionStartHookOutput;
|
|
@@ -675,6 +689,7 @@ interface SessionStartHookOutput extends CommonHookOutputs {
|
|
|
675
689
|
* Adds the string to the context.
|
|
676
690
|
*/
|
|
677
691
|
additionalContext?: string;
|
|
692
|
+
initialUserMessage?: string;
|
|
678
693
|
};
|
|
679
694
|
}
|
|
680
695
|
interface SetupHookOutput extends CommonHookOutputs {
|
package/dist/index.mjs
CHANGED
|
@@ -179,18 +179,18 @@ function buildSubagentInputSchema(hook_event_name, entries) {
|
|
|
179
179
|
*/
|
|
180
180
|
const HookInputSchemas = {
|
|
181
181
|
PreToolUse: buildHookInputSchema("PreToolUse", {
|
|
182
|
-
tool_name: v.pipe(v.string(), v.
|
|
182
|
+
tool_name: v.pipe(v.string(), v.guard((s) => true)),
|
|
183
183
|
tool_input: v.unknown(),
|
|
184
184
|
tool_use_id: v.string()
|
|
185
185
|
}),
|
|
186
186
|
PostToolUse: buildHookInputSchema("PostToolUse", {
|
|
187
|
-
tool_name: v.pipe(v.string(), v.
|
|
187
|
+
tool_name: v.pipe(v.string(), v.guard((s) => true)),
|
|
188
188
|
tool_input: v.unknown(),
|
|
189
189
|
tool_response: v.unknown(),
|
|
190
190
|
tool_use_id: v.string()
|
|
191
191
|
}),
|
|
192
192
|
PostToolUseFailure: buildHookInputSchema("PostToolUseFailure", {
|
|
193
|
-
tool_name: v.pipe(v.string(), v.
|
|
193
|
+
tool_name: v.pipe(v.string(), v.guard((s) => true)),
|
|
194
194
|
error: v.string(),
|
|
195
195
|
is_interrupt: v.exactOptional(v.boolean()),
|
|
196
196
|
tool_input: v.unknown(),
|
|
@@ -206,6 +206,19 @@ const HookInputSchemas = {
|
|
|
206
206
|
last_assistant_message: v.exactOptional(v.string()),
|
|
207
207
|
stop_hook_active: v.boolean()
|
|
208
208
|
}),
|
|
209
|
+
StopFailure: buildHookInputSchema("StopFailure", {
|
|
210
|
+
error: v.picklist([
|
|
211
|
+
"authentication_failed",
|
|
212
|
+
"billing_error",
|
|
213
|
+
"rate_limit",
|
|
214
|
+
"invalid_request",
|
|
215
|
+
"server_error",
|
|
216
|
+
"unknown",
|
|
217
|
+
"max_output_tokens"
|
|
218
|
+
]),
|
|
219
|
+
error_details: v.exactOptional(v.string()),
|
|
220
|
+
last_assistant_message: v.exactOptional(v.string())
|
|
221
|
+
}),
|
|
209
222
|
SubagentStart: buildSubagentInputSchema("SubagentStart", {}),
|
|
210
223
|
SubagentStop: buildSubagentInputSchema("SubagentStop", {
|
|
211
224
|
agent_transcript_path: v.string(),
|
|
@@ -232,6 +245,7 @@ const HookInputSchemas = {
|
|
|
232
245
|
}),
|
|
233
246
|
SessionEnd: buildHookInputSchema("SessionEnd", { reason: v.picklist([
|
|
234
247
|
"clear",
|
|
248
|
+
"resume",
|
|
235
249
|
"logout",
|
|
236
250
|
"prompt_input_exit",
|
|
237
251
|
"other",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-hooks-ts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.81",
|
|
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.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.81",
|
|
66
66
|
"get-stdin": "10.0.0",
|
|
67
67
|
"valibot": "^1.1.0"
|
|
68
68
|
},
|