cc-hooks-ts 2.0.0 → 2.0.42
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 +25 -47
- package/dist/index.mjs +6 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { BashInput, ExitPlanModeInput, FileEditInput, FileReadInput, FileWriteInput, GlobInput, GrepInput, NotebookEditInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "@anthropic-ai/claude-
|
|
2
|
+
import { AgentInput, BashInput, BashOutputInput, ExitPlanModeInput, FileEditInput, FileReadInput, FileWriteInput, GlobInput, GrepInput, KillShellInput, ListMcpResourcesInput, NotebookEditInput, ReadMcpResourceInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools";
|
|
3
3
|
|
|
4
|
-
//#region src/utils/types.d.ts
|
|
5
|
-
type Awaitable<T> = Promise<T> | T;
|
|
6
|
-
type AutoComplete<T extends string> = Record<string, never> & T;
|
|
7
|
-
//#endregion
|
|
8
4
|
//#region src/event.d.ts
|
|
9
5
|
declare const SUPPORTED_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStop", "PreCompact"];
|
|
10
6
|
/**
|
|
@@ -80,6 +76,7 @@ interface PreToolUseHookOutput extends CommonHookOutputs {
|
|
|
80
76
|
*/
|
|
81
77
|
permissionDecision?: "allow" | "ask" | "deny";
|
|
82
78
|
permissionDecisionReason?: string;
|
|
79
|
+
updatedInput?: Record<string, unknown>;
|
|
83
80
|
};
|
|
84
81
|
}
|
|
85
82
|
/**
|
|
@@ -97,6 +94,7 @@ interface PostToolUseHookOutput extends CommonHookOutputs {
|
|
|
97
94
|
* Adds context for Claude to consider.
|
|
98
95
|
*/
|
|
99
96
|
additionalContext?: string;
|
|
97
|
+
updatedMCPToolOutput?: unknown;
|
|
100
98
|
};
|
|
101
99
|
reason?: string;
|
|
102
100
|
}
|
|
@@ -156,6 +154,10 @@ interface SessionStartHookOutput extends CommonHookOutputs {
|
|
|
156
154
|
};
|
|
157
155
|
}
|
|
158
156
|
//#endregion
|
|
157
|
+
//#region src/utils/types.d.ts
|
|
158
|
+
type Awaitable<T> = Promise<T> | T;
|
|
159
|
+
type AutoComplete<T extends string> = Record<string, never> & T;
|
|
160
|
+
//#endregion
|
|
159
161
|
//#region src/input/schemas.d.ts
|
|
160
162
|
/**
|
|
161
163
|
* @package
|
|
@@ -190,6 +192,7 @@ declare const HookInputSchemas: {
|
|
|
190
192
|
readonly hook_event_name: v.LiteralSchema<"Notification", undefined>;
|
|
191
193
|
} & {
|
|
192
194
|
message: v.StringSchema<undefined>;
|
|
195
|
+
notification_type: v.StringSchema<undefined>;
|
|
193
196
|
title: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
194
197
|
}, undefined>;
|
|
195
198
|
readonly UserPromptSubmit: v.ObjectSchema<{
|
|
@@ -217,6 +220,8 @@ declare const HookInputSchemas: {
|
|
|
217
220
|
readonly transcript_path: v.StringSchema<undefined>;
|
|
218
221
|
readonly hook_event_name: v.LiteralSchema<"SubagentStop", undefined>;
|
|
219
222
|
} & {
|
|
223
|
+
agent_id: v.StringSchema<undefined>;
|
|
224
|
+
agent_transcript_path: v.StringSchema<undefined>;
|
|
220
225
|
stop_hook_active: v.BooleanSchema<undefined>;
|
|
221
226
|
}, undefined>;
|
|
222
227
|
readonly PreCompact: v.ObjectSchema<{
|
|
@@ -570,6 +575,10 @@ interface ToolSchema {
|
|
|
570
575
|
stdout: string;
|
|
571
576
|
};
|
|
572
577
|
};
|
|
578
|
+
BashOutput: {
|
|
579
|
+
input: BashOutputInput;
|
|
580
|
+
response: unknown;
|
|
581
|
+
};
|
|
573
582
|
Edit: {
|
|
574
583
|
input: FileEditInput;
|
|
575
584
|
response: {
|
|
@@ -610,44 +619,13 @@ interface ToolSchema {
|
|
|
610
619
|
numLines: number;
|
|
611
620
|
};
|
|
612
621
|
};
|
|
613
|
-
|
|
614
|
-
input:
|
|
615
|
-
|
|
616
|
-
};
|
|
617
|
-
response: string;
|
|
622
|
+
KillBash: {
|
|
623
|
+
input: KillShellInput;
|
|
624
|
+
response: unknown;
|
|
618
625
|
};
|
|
619
|
-
|
|
620
|
-
input:
|
|
621
|
-
|
|
622
|
-
new_string: string;
|
|
623
|
-
old_string: string;
|
|
624
|
-
/**
|
|
625
|
-
* @default false
|
|
626
|
-
*/
|
|
627
|
-
replace_all?: boolean;
|
|
628
|
-
}>;
|
|
629
|
-
file_path: string;
|
|
630
|
-
};
|
|
631
|
-
response: {
|
|
632
|
-
edits: Array<{
|
|
633
|
-
new_string: string;
|
|
634
|
-
old_string: string;
|
|
635
|
-
/**
|
|
636
|
-
* @default false
|
|
637
|
-
*/
|
|
638
|
-
replace_all?: boolean;
|
|
639
|
-
}>;
|
|
640
|
-
filePath: string;
|
|
641
|
-
originalFileContents: string;
|
|
642
|
-
structuredPatch: Array<{
|
|
643
|
-
lines: string[];
|
|
644
|
-
newLines: number;
|
|
645
|
-
newStart: number;
|
|
646
|
-
oldLines: number;
|
|
647
|
-
oldStart: number;
|
|
648
|
-
}>;
|
|
649
|
-
userModified: boolean;
|
|
650
|
-
};
|
|
626
|
+
ListMcpResources: {
|
|
627
|
+
input: ListMcpResourcesInput;
|
|
628
|
+
response: unknown;
|
|
651
629
|
};
|
|
652
630
|
NotebookEdit: {
|
|
653
631
|
input: NotebookEditInput;
|
|
@@ -687,12 +665,12 @@ interface ToolSchema {
|
|
|
687
665
|
type: "text";
|
|
688
666
|
};
|
|
689
667
|
};
|
|
668
|
+
ReadMcpResource: {
|
|
669
|
+
input: ReadMcpResourceInput;
|
|
670
|
+
response: unknown;
|
|
671
|
+
};
|
|
690
672
|
Task: {
|
|
691
|
-
input:
|
|
692
|
-
description: string;
|
|
693
|
-
prompt: string;
|
|
694
|
-
subagent_type: AutoComplete<"general-purpose" | "output-style-setup" | "statusline-setup">;
|
|
695
|
-
};
|
|
673
|
+
input: AgentInput;
|
|
696
674
|
response: {
|
|
697
675
|
content: Array<{
|
|
698
676
|
text: string;
|
package/dist/index.mjs
CHANGED
|
@@ -53,11 +53,16 @@ const HookInputSchemas = {
|
|
|
53
53
|
}),
|
|
54
54
|
Notification: buildHookInputSchema("Notification", {
|
|
55
55
|
message: v.string(),
|
|
56
|
+
notification_type: v.string(),
|
|
56
57
|
title: v.exactOptional(v.string())
|
|
57
58
|
}),
|
|
58
59
|
UserPromptSubmit: buildHookInputSchema("UserPromptSubmit", { prompt: v.string() }),
|
|
59
60
|
Stop: buildHookInputSchema("Stop", { stop_hook_active: v.boolean() }),
|
|
60
|
-
SubagentStop: buildHookInputSchema("SubagentStop", {
|
|
61
|
+
SubagentStop: buildHookInputSchema("SubagentStop", {
|
|
62
|
+
agent_id: v.string(),
|
|
63
|
+
agent_transcript_path: v.string(),
|
|
64
|
+
stop_hook_active: v.boolean()
|
|
65
|
+
}),
|
|
61
66
|
PreCompact: buildHookInputSchema("PreCompact", {
|
|
62
67
|
custom_instructions: v.nullable(v.string()),
|
|
63
68
|
trigger: v.union([v.literal("manual"), v.literal("auto")])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-hooks-ts",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.42",
|
|
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.0.7"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@anthropic-ai/claude-
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk": "0.1.42",
|
|
66
66
|
"valibot": "^1.1.0"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|