cc-hooks-ts 2.1.50 → 2.1.63
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 +44 -1
- package/dist/index.mjs +23 -4
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -236,6 +236,33 @@ declare const HookInputSchemas: {
|
|
|
236
236
|
} & {
|
|
237
237
|
worktree_path: v.StringSchema<undefined>;
|
|
238
238
|
}, undefined>;
|
|
239
|
+
readonly Elicitation: v.ObjectSchema<{
|
|
240
|
+
readonly cwd: v.StringSchema<undefined>;
|
|
241
|
+
readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
242
|
+
readonly session_id: v.StringSchema<undefined>;
|
|
243
|
+
readonly transcript_path: v.StringSchema<undefined>;
|
|
244
|
+
readonly hook_event_name: v.LiteralSchema<"Elicitation", undefined>;
|
|
245
|
+
} & {
|
|
246
|
+
elicitation_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
247
|
+
mcp_server_name: v.StringSchema<undefined>;
|
|
248
|
+
message: v.StringSchema<undefined>;
|
|
249
|
+
mode: v.ExactOptionalSchema<v.PicklistSchema<["form", "url"], undefined>, undefined>;
|
|
250
|
+
requested_schema: v.ExactOptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
251
|
+
url: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
252
|
+
}, undefined>;
|
|
253
|
+
readonly ElicitationResult: v.ObjectSchema<{
|
|
254
|
+
readonly cwd: v.StringSchema<undefined>;
|
|
255
|
+
readonly permission_mode: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
256
|
+
readonly session_id: v.StringSchema<undefined>;
|
|
257
|
+
readonly transcript_path: v.StringSchema<undefined>;
|
|
258
|
+
readonly hook_event_name: v.LiteralSchema<"ElicitationResult", undefined>;
|
|
259
|
+
} & {
|
|
260
|
+
action: v.PicklistSchema<["accept", "decline", "cancel"], undefined>;
|
|
261
|
+
content: v.ExactOptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
262
|
+
elicitation_id: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
263
|
+
mcp_server_name: v.StringSchema<undefined>;
|
|
264
|
+
mode: v.ExactOptionalSchema<v.PicklistSchema<["form", "url"], undefined>, undefined>;
|
|
265
|
+
}, undefined>;
|
|
239
266
|
};
|
|
240
267
|
//#endregion
|
|
241
268
|
//#region src/hooks/event.d.ts
|
|
@@ -244,7 +271,7 @@ declare const HookInputSchemas: {
|
|
|
244
271
|
*
|
|
245
272
|
* @package
|
|
246
273
|
*/
|
|
247
|
-
type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove";
|
|
274
|
+
type SupportedHookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PermissionRequest" | "Setup" | "TeammateIdle" | "TaskCompleted" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "Elicitation" | "ElicitationResult";
|
|
248
275
|
//#endregion
|
|
249
276
|
//#region src/hooks/input/types.d.ts
|
|
250
277
|
/**
|
|
@@ -384,6 +411,8 @@ type HookOutput = {
|
|
|
384
411
|
PermissionRequest: PermissionRequestHookOutput;
|
|
385
412
|
Setup: SetupHookOutput;
|
|
386
413
|
Notification: NotificationHookOutput;
|
|
414
|
+
Elicitation: ElicitationHookOutput;
|
|
415
|
+
ElicitationResult: ElicitationResultHookOutput;
|
|
387
416
|
ConfigChange: CommonHookOutputs;
|
|
388
417
|
PreCompact: CommonHookOutputs;
|
|
389
418
|
SessionEnd: CommonHookOutputs;
|
|
@@ -608,6 +637,20 @@ interface PermissionRequestHookOutput extends CommonHookOutputs {
|
|
|
608
637
|
};
|
|
609
638
|
};
|
|
610
639
|
}
|
|
640
|
+
interface ElicitationHookOutput extends CommonHookOutputs {
|
|
641
|
+
hookSpecificOutput?: {
|
|
642
|
+
action?: "accept" | "decline" | "cancel";
|
|
643
|
+
content?: Record<string, unknown>;
|
|
644
|
+
hookEventName: "Elicitation";
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
interface ElicitationResultHookOutput extends CommonHookOutputs {
|
|
648
|
+
hookSpecificOutput?: {
|
|
649
|
+
action?: "accept" | "decline" | "cancel";
|
|
650
|
+
content?: Record<string, unknown>;
|
|
651
|
+
hookEventName: "ElicitationResult";
|
|
652
|
+
};
|
|
653
|
+
}
|
|
611
654
|
//#endregion
|
|
612
655
|
//#region src/types.d.ts
|
|
613
656
|
type HookTrigger = Partial<{ [TEvent in SupportedHookEvent]: true | Partial<{ [SchemaKey in ExtractExtendedSpecificKeys<TEvent>]?: true }> }>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import getStdin from "get-stdin";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
function defineHook(definition) {
|
|
@@ -192,7 +192,26 @@ const HookInputSchemas = {
|
|
|
192
192
|
])
|
|
193
193
|
}),
|
|
194
194
|
WorktreeCreate: buildHookInputSchema("WorktreeCreate", { name: v.string() }),
|
|
195
|
-
WorktreeRemove: buildHookInputSchema("WorktreeRemove", { worktree_path: v.string() })
|
|
195
|
+
WorktreeRemove: buildHookInputSchema("WorktreeRemove", { worktree_path: v.string() }),
|
|
196
|
+
Elicitation: buildHookInputSchema("Elicitation", {
|
|
197
|
+
elicitation_id: v.exactOptional(v.string()),
|
|
198
|
+
mcp_server_name: v.string(),
|
|
199
|
+
message: v.string(),
|
|
200
|
+
mode: v.exactOptional(v.picklist(["form", "url"])),
|
|
201
|
+
requested_schema: v.exactOptional(v.record(v.string(), v.unknown())),
|
|
202
|
+
url: v.exactOptional(v.string())
|
|
203
|
+
}),
|
|
204
|
+
ElicitationResult: buildHookInputSchema("ElicitationResult", {
|
|
205
|
+
action: v.picklist([
|
|
206
|
+
"accept",
|
|
207
|
+
"decline",
|
|
208
|
+
"cancel"
|
|
209
|
+
]),
|
|
210
|
+
content: v.exactOptional(v.record(v.string(), v.unknown())),
|
|
211
|
+
elicitation_id: v.exactOptional(v.string()),
|
|
212
|
+
mcp_server_name: v.string(),
|
|
213
|
+
mode: v.exactOptional(v.picklist(["form", "url"]))
|
|
214
|
+
})
|
|
196
215
|
};
|
|
197
216
|
function isNonEmptyString(value) {
|
|
198
217
|
return typeof value === "string" && value.length > 0;
|
|
@@ -205,9 +224,9 @@ async function runHook(def) {
|
|
|
205
224
|
kind: "success",
|
|
206
225
|
payload: {}
|
|
207
226
|
});
|
|
227
|
+
const stdin = await getStdin();
|
|
208
228
|
const inputSchema = extractInputSchemaFromTrigger(trigger);
|
|
209
|
-
const
|
|
210
|
-
const parsed = v.parse(inputSchema, JSON.parse(rawInput));
|
|
229
|
+
const parsed = v.parse(inputSchema, JSON.parse(stdin));
|
|
211
230
|
eventName = parsed.hook_event_name;
|
|
212
231
|
const result = await run(createContext(parsed));
|
|
213
232
|
await handleHookResult(eventName, result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-hooks-ts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.63",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Write claude code hooks with type safety",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
"vitest": "4.0.18"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.63",
|
|
66
|
+
"get-stdin": "10.0.0",
|
|
66
67
|
"valibot": "^1.1.0"
|
|
67
68
|
},
|
|
68
69
|
"scripts": {
|