cc-hooks-ts 2.0.45 → 2.0.55
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 +81 -0
- package/dist/index.mjs +58 -0
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -118,6 +118,43 @@ declare const HookInputSchemas: {
|
|
|
118
118
|
readonly transcript_path: v.StringSchema<undefined>;
|
|
119
119
|
readonly hook_event_name: v.LiteralSchema<"PermissionRequest", undefined>;
|
|
120
120
|
} & {
|
|
121
|
+
permission_suggestions: v.ExactOptionalSchema<v.ArraySchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
122
|
+
readonly behavior: v.UnionSchema<[v.LiteralSchema<"allow", undefined>, v.LiteralSchema<"deny", undefined>, v.LiteralSchema<"ask", undefined>], undefined>;
|
|
123
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
124
|
+
readonly rules: v.ArraySchema<v.ObjectSchema<{
|
|
125
|
+
readonly ruleContent: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
126
|
+
readonly toolName: v.StringSchema<undefined>;
|
|
127
|
+
}, undefined>, undefined>;
|
|
128
|
+
readonly type: v.LiteralSchema<"addRules", undefined>;
|
|
129
|
+
}, undefined>, v.ObjectSchema<{
|
|
130
|
+
readonly behavior: v.UnionSchema<[v.LiteralSchema<"allow", undefined>, v.LiteralSchema<"deny", undefined>, v.LiteralSchema<"ask", undefined>], undefined>;
|
|
131
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
132
|
+
readonly rules: v.ArraySchema<v.ObjectSchema<{
|
|
133
|
+
readonly ruleContent: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
134
|
+
readonly toolName: v.StringSchema<undefined>;
|
|
135
|
+
}, undefined>, undefined>;
|
|
136
|
+
readonly type: v.LiteralSchema<"replaceRules", undefined>;
|
|
137
|
+
}, undefined>, v.ObjectSchema<{
|
|
138
|
+
readonly behavior: v.UnionSchema<[v.LiteralSchema<"allow", undefined>, v.LiteralSchema<"deny", undefined>, v.LiteralSchema<"ask", undefined>], undefined>;
|
|
139
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
140
|
+
readonly rules: v.ArraySchema<v.ObjectSchema<{
|
|
141
|
+
readonly ruleContent: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
142
|
+
readonly toolName: v.StringSchema<undefined>;
|
|
143
|
+
}, undefined>, undefined>;
|
|
144
|
+
readonly type: v.LiteralSchema<"removeRules", undefined>;
|
|
145
|
+
}, undefined>, v.ObjectSchema<{
|
|
146
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
147
|
+
readonly mode: v.UnionSchema<[v.LiteralSchema<"acceptEdits", undefined>, v.LiteralSchema<"bypassPermissions", undefined>, v.LiteralSchema<"default", undefined>, v.LiteralSchema<"dontAsk", undefined>, v.LiteralSchema<"plan", undefined>], undefined>;
|
|
148
|
+
readonly type: v.LiteralSchema<"setMode", undefined>;
|
|
149
|
+
}, undefined>, v.ObjectSchema<{
|
|
150
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
151
|
+
readonly directories: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
152
|
+
readonly type: v.LiteralSchema<"addDirectories", undefined>;
|
|
153
|
+
}, undefined>, v.ObjectSchema<{
|
|
154
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
155
|
+
readonly directories: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
156
|
+
readonly type: v.LiteralSchema<"removeDirectories", undefined>;
|
|
157
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
121
158
|
tool_input: v.UnknownSchema;
|
|
122
159
|
tool_name: v.StringSchema<undefined>;
|
|
123
160
|
}, undefined>;
|
|
@@ -204,6 +241,49 @@ type ToolSpecificPostToolUseInput = { [K in keyof ToolSchema]: Omit<BaseHookInpu
|
|
|
204
241
|
tool_response: ToolSchema[K]["response"];
|
|
205
242
|
} };
|
|
206
243
|
//#endregion
|
|
244
|
+
//#region src/hooks/permission.d.ts
|
|
245
|
+
/**
|
|
246
|
+
* @package
|
|
247
|
+
*/
|
|
248
|
+
declare const permissionUpdateSchema: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
249
|
+
readonly behavior: v.UnionSchema<[v.LiteralSchema<"allow", undefined>, v.LiteralSchema<"deny", undefined>, v.LiteralSchema<"ask", undefined>], undefined>;
|
|
250
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
251
|
+
readonly rules: v.ArraySchema<v.ObjectSchema<{
|
|
252
|
+
readonly ruleContent: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
253
|
+
readonly toolName: v.StringSchema<undefined>;
|
|
254
|
+
}, undefined>, undefined>;
|
|
255
|
+
readonly type: v.LiteralSchema<"addRules", undefined>;
|
|
256
|
+
}, undefined>, v.ObjectSchema<{
|
|
257
|
+
readonly behavior: v.UnionSchema<[v.LiteralSchema<"allow", undefined>, v.LiteralSchema<"deny", undefined>, v.LiteralSchema<"ask", undefined>], undefined>;
|
|
258
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
259
|
+
readonly rules: v.ArraySchema<v.ObjectSchema<{
|
|
260
|
+
readonly ruleContent: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
261
|
+
readonly toolName: v.StringSchema<undefined>;
|
|
262
|
+
}, undefined>, undefined>;
|
|
263
|
+
readonly type: v.LiteralSchema<"replaceRules", undefined>;
|
|
264
|
+
}, undefined>, v.ObjectSchema<{
|
|
265
|
+
readonly behavior: v.UnionSchema<[v.LiteralSchema<"allow", undefined>, v.LiteralSchema<"deny", undefined>, v.LiteralSchema<"ask", undefined>], undefined>;
|
|
266
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
267
|
+
readonly rules: v.ArraySchema<v.ObjectSchema<{
|
|
268
|
+
readonly ruleContent: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
269
|
+
readonly toolName: v.StringSchema<undefined>;
|
|
270
|
+
}, undefined>, undefined>;
|
|
271
|
+
readonly type: v.LiteralSchema<"removeRules", undefined>;
|
|
272
|
+
}, undefined>, v.ObjectSchema<{
|
|
273
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
274
|
+
readonly mode: v.UnionSchema<[v.LiteralSchema<"acceptEdits", undefined>, v.LiteralSchema<"bypassPermissions", undefined>, v.LiteralSchema<"default", undefined>, v.LiteralSchema<"dontAsk", undefined>, v.LiteralSchema<"plan", undefined>], undefined>;
|
|
275
|
+
readonly type: v.LiteralSchema<"setMode", undefined>;
|
|
276
|
+
}, undefined>, v.ObjectSchema<{
|
|
277
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
278
|
+
readonly directories: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
279
|
+
readonly type: v.LiteralSchema<"addDirectories", undefined>;
|
|
280
|
+
}, undefined>, v.ObjectSchema<{
|
|
281
|
+
readonly destination: v.UnionSchema<[v.LiteralSchema<"userSettings", undefined>, v.LiteralSchema<"projectSettings", undefined>, v.LiteralSchema<"localSettings", undefined>, v.LiteralSchema<"session", undefined>, v.LiteralSchema<"cliArg", undefined>], undefined>;
|
|
282
|
+
readonly directories: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
283
|
+
readonly type: v.LiteralSchema<"removeDirectories", undefined>;
|
|
284
|
+
}, undefined>], undefined>;
|
|
285
|
+
type PermissionUpdate = v.InferOutput<typeof permissionUpdateSchema>;
|
|
286
|
+
//#endregion
|
|
207
287
|
//#region src/hooks/output/index.d.ts
|
|
208
288
|
/**
|
|
209
289
|
* @package
|
|
@@ -380,6 +460,7 @@ interface PermissionRequestHookOutput extends CommonHookOutputs {
|
|
|
380
460
|
decision: {
|
|
381
461
|
behavior: "allow";
|
|
382
462
|
updatedInput?: Record<string, unknown>;
|
|
463
|
+
updatedPermissions?: PermissionUpdate[];
|
|
383
464
|
} | {
|
|
384
465
|
behavior: "deny";
|
|
385
466
|
interrupt?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,63 @@ function createContext(input) {
|
|
|
28
28
|
})
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
const permissionBehaviorSchema = v.union([
|
|
32
|
+
v.literal("allow"),
|
|
33
|
+
v.literal("deny"),
|
|
34
|
+
v.literal("ask")
|
|
35
|
+
]);
|
|
36
|
+
const permissionUpdateDestinationSchema = v.union([
|
|
37
|
+
v.literal("userSettings"),
|
|
38
|
+
v.literal("projectSettings"),
|
|
39
|
+
v.literal("localSettings"),
|
|
40
|
+
v.literal("session"),
|
|
41
|
+
v.literal("cliArg")
|
|
42
|
+
]);
|
|
43
|
+
const permissionRuleValueSchema = v.object({
|
|
44
|
+
ruleContent: v.exactOptional(v.string()),
|
|
45
|
+
toolName: v.string()
|
|
46
|
+
});
|
|
47
|
+
const permissionUpdateSchema = v.variant("type", [
|
|
48
|
+
v.object({
|
|
49
|
+
behavior: permissionBehaviorSchema,
|
|
50
|
+
destination: permissionUpdateDestinationSchema,
|
|
51
|
+
rules: v.array(permissionRuleValueSchema),
|
|
52
|
+
type: v.literal("addRules")
|
|
53
|
+
}),
|
|
54
|
+
v.object({
|
|
55
|
+
behavior: permissionBehaviorSchema,
|
|
56
|
+
destination: permissionUpdateDestinationSchema,
|
|
57
|
+
rules: v.array(permissionRuleValueSchema),
|
|
58
|
+
type: v.literal("replaceRules")
|
|
59
|
+
}),
|
|
60
|
+
v.object({
|
|
61
|
+
behavior: permissionBehaviorSchema,
|
|
62
|
+
destination: permissionUpdateDestinationSchema,
|
|
63
|
+
rules: v.array(permissionRuleValueSchema),
|
|
64
|
+
type: v.literal("removeRules")
|
|
65
|
+
}),
|
|
66
|
+
v.object({
|
|
67
|
+
destination: permissionUpdateDestinationSchema,
|
|
68
|
+
mode: v.union([
|
|
69
|
+
v.literal("acceptEdits"),
|
|
70
|
+
v.literal("bypassPermissions"),
|
|
71
|
+
v.literal("default"),
|
|
72
|
+
v.literal("dontAsk"),
|
|
73
|
+
v.literal("plan")
|
|
74
|
+
]),
|
|
75
|
+
type: v.literal("setMode")
|
|
76
|
+
}),
|
|
77
|
+
v.object({
|
|
78
|
+
destination: permissionUpdateDestinationSchema,
|
|
79
|
+
directories: v.array(v.string()),
|
|
80
|
+
type: v.literal("addDirectories")
|
|
81
|
+
}),
|
|
82
|
+
v.object({
|
|
83
|
+
destination: permissionUpdateDestinationSchema,
|
|
84
|
+
directories: v.array(v.string()),
|
|
85
|
+
type: v.literal("removeDirectories")
|
|
86
|
+
})
|
|
87
|
+
]);
|
|
31
88
|
const baseHookInputSchema = v.object({
|
|
32
89
|
cwd: v.string(),
|
|
33
90
|
permission_mode: v.exactOptional(v.string()),
|
|
@@ -81,6 +138,7 @@ const HookInputSchemas = {
|
|
|
81
138
|
]) }),
|
|
82
139
|
SessionEnd: buildHookInputSchema("SessionEnd", { reason: v.string() }),
|
|
83
140
|
PermissionRequest: buildHookInputSchema("PermissionRequest", {
|
|
141
|
+
permission_suggestions: v.exactOptional(v.array(permissionUpdateSchema)),
|
|
84
142
|
tool_input: v.unknown(),
|
|
85
143
|
tool_name: v.string()
|
|
86
144
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-hooks-ts",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.55",
|
|
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
|
-
"@biomejs/biome": "2.3.
|
|
46
|
+
"@biomejs/biome": "2.3.7",
|
|
47
47
|
"@types/node": "24.10.1",
|
|
48
48
|
"@typescript/native-preview": "^7.0.0-dev.20251108.1",
|
|
49
49
|
"@virtual-live-lab/eslint-config": "2.3.1",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"publint": "0.3.15",
|
|
55
55
|
"release-it": "19.0.6",
|
|
56
56
|
"release-it-pnpm": "4.6.6",
|
|
57
|
-
"tsdown": "0.16.
|
|
57
|
+
"tsdown": "0.16.6",
|
|
58
58
|
"type-fest": "5.2.0",
|
|
59
59
|
"typescript": "5.9.3",
|
|
60
|
-
"typescript-eslint": "8.
|
|
60
|
+
"typescript-eslint": "8.47.0",
|
|
61
61
|
"unplugin-unused": "0.5.6",
|
|
62
|
-
"vitest": "4.0.
|
|
62
|
+
"vitest": "4.0.13"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@anthropic-ai/claude-agent-sdk": "0.1.
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk": "0.1.55",
|
|
66
66
|
"valibot": "^1.1.0"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|