@goodfoot/claude-code-hooks 1.0.21 → 1.1.0
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/cli.js +12 -0
- package/dist/outputs.js +27 -2
- package/dist/runtime.js +13 -5
- package/dist/scaffold.js +2 -2
- package/package.json +3 -3
- package/types/index.d.ts +1 -1
- package/types/outputs.d.ts +35 -16
- package/types/runtime.d.ts +3 -3
- package/types/types.d.ts +2 -1
package/dist/cli.js
CHANGED
|
@@ -416,6 +416,17 @@ execute(hook);
|
|
|
416
416
|
sourcefile: `${baseName}-entry.ts`,
|
|
417
417
|
loader: "ts",
|
|
418
418
|
};
|
|
419
|
+
// Banner to polyfill CJS globals for dependencies bundled into ESM.
|
|
420
|
+
// Some packages (e.g. typescript) use require(), __filename, and __dirname
|
|
421
|
+
// internally, which are unavailable in ESM scope.
|
|
422
|
+
const esmRequireBanner = [
|
|
423
|
+
`import { createRequire as __createRequire } from "node:module";`,
|
|
424
|
+
`import { fileURLToPath as __fileURLToPath } from "node:url";`,
|
|
425
|
+
`import { dirname as __pathDirname } from "node:path";`,
|
|
426
|
+
`const require = __createRequire(import.meta.url);`,
|
|
427
|
+
`const __filename = __fileURLToPath(import.meta.url);`,
|
|
428
|
+
`const __dirname = __pathDirname(__filename);`,
|
|
429
|
+
].join("\n");
|
|
419
430
|
// Common esbuild options
|
|
420
431
|
const commonOptions = {
|
|
421
432
|
stdin: stdinOptions,
|
|
@@ -425,6 +436,7 @@ execute(hook);
|
|
|
425
436
|
bundle: true,
|
|
426
437
|
minify: false,
|
|
427
438
|
write: false, // Return content directly via outputFiles
|
|
439
|
+
banner: { js: esmRequireBanner },
|
|
428
440
|
// Keep node built-ins external
|
|
429
441
|
external: [
|
|
430
442
|
"node:*",
|
package/dist/outputs.js
CHANGED
|
@@ -69,6 +69,23 @@ function createDecisionOutputBuilder(hookType) {
|
|
|
69
69
|
stdout: options,
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Factory for exit-code-based hooks (TeammateIdle, TaskCompleted).
|
|
74
|
+
*
|
|
75
|
+
* These hooks don't use JSON decision control (no CommonOptions).
|
|
76
|
+
* The only option is `stderr` — when present, it triggers exit code 2 (BLOCK).
|
|
77
|
+
* Stdout always receives `{}` (empty JSON object).
|
|
78
|
+
* @param hookType - The hook type name used as the _type discriminator
|
|
79
|
+
* @returns A builder function that creates the output object
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
function createExitCodeOutputBuilder(hookType) {
|
|
83
|
+
return ({ stderr } = {}) => ({
|
|
84
|
+
_type: hookType,
|
|
85
|
+
stdout: {},
|
|
86
|
+
...(stderr !== undefined ? { stderr } : {}),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
72
89
|
/**
|
|
73
90
|
* Creates an output for PreToolUse hooks.
|
|
74
91
|
* @param options - Configuration options for the hook output
|
|
@@ -303,17 +320,25 @@ export const setupOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("Setu
|
|
|
303
320
|
* @returns A TeammateIdleOutput object ready for the runtime
|
|
304
321
|
* @example
|
|
305
322
|
* ```typescript
|
|
323
|
+
* // Allow teammate to go idle
|
|
306
324
|
* teammateIdleOutput({});
|
|
325
|
+
*
|
|
326
|
+
* // Block with feedback
|
|
327
|
+
* teammateIdleOutput({ stderr: 'Continue working: unfinished tasks remain.' });
|
|
307
328
|
* ```
|
|
308
329
|
*/
|
|
309
|
-
export const teammateIdleOutput = /* @__PURE__ */
|
|
330
|
+
export const teammateIdleOutput = /* @__PURE__ */ createExitCodeOutputBuilder("TeammateIdle");
|
|
310
331
|
/**
|
|
311
332
|
* Creates an output for TaskCompleted hooks.
|
|
312
333
|
* @param options - Configuration options for the hook output
|
|
313
334
|
* @returns A TaskCompletedOutput object ready for the runtime
|
|
314
335
|
* @example
|
|
315
336
|
* ```typescript
|
|
337
|
+
* // Allow task completion
|
|
316
338
|
* taskCompletedOutput({});
|
|
339
|
+
*
|
|
340
|
+
* // Block with feedback
|
|
341
|
+
* taskCompletedOutput({ stderr: 'Cannot complete: tests are failing.' });
|
|
317
342
|
* ```
|
|
318
343
|
*/
|
|
319
|
-
export const taskCompletedOutput = /* @__PURE__ */
|
|
344
|
+
export const taskCompletedOutput = /* @__PURE__ */ createExitCodeOutputBuilder("TaskCompleted");
|
package/dist/runtime.js
CHANGED
|
@@ -106,8 +106,8 @@ function handleHandlerError(error) {
|
|
|
106
106
|
/**
|
|
107
107
|
* Converts a SpecificHookOutput to HookOutput for wire format.
|
|
108
108
|
*
|
|
109
|
-
* SpecificHookOutput types have: { _type,
|
|
110
|
-
* HookOutput has: {
|
|
109
|
+
* SpecificHookOutput types have: { _type, stdout, stderr? }
|
|
110
|
+
* HookOutput has: { stdout, stderr? }
|
|
111
111
|
*
|
|
112
112
|
* Since output builders now produce wire-format directly, this function
|
|
113
113
|
* simply strips the `_type` discriminator field.
|
|
@@ -118,11 +118,12 @@ function handleHandlerError(error) {
|
|
|
118
118
|
* ```typescript
|
|
119
119
|
* const specificOutput = preToolUseOutput({ hookSpecificOutput: { permissionDecision: 'allow' } });
|
|
120
120
|
* const hookOutput = convertToHookOutput(specificOutput);
|
|
121
|
-
* // hookOutput: {
|
|
121
|
+
* // hookOutput: { stdout: { hookSpecificOutput: { ... } } }
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
124
|
export function convertToHookOutput(specificOutput) {
|
|
125
|
-
|
|
125
|
+
const { stdout, stderr } = specificOutput;
|
|
126
|
+
return stderr !== undefined ? { stdout, stderr } : { stdout };
|
|
126
127
|
}
|
|
127
128
|
// ============================================================================
|
|
128
129
|
// Execute Function
|
|
@@ -216,9 +217,16 @@ export async function execute(hookFn) {
|
|
|
216
217
|
if (output !== undefined) {
|
|
217
218
|
writeStdout(output.stdout);
|
|
218
219
|
}
|
|
219
|
-
//
|
|
220
|
+
// Clean up logger (single cleanup path)
|
|
220
221
|
logger.clearContext();
|
|
221
222
|
logger.close();
|
|
223
|
+
// Exit-code BLOCK: unlike handler throw (no stdout), this path still writes
|
|
224
|
+
// structured JSON to stdout (as empty {}) alongside the stderr message.
|
|
225
|
+
// The caller controls stderr formatting (no appended newline).
|
|
226
|
+
if (output?.stderr !== undefined) {
|
|
227
|
+
process.stderr.write(output.stderr);
|
|
228
|
+
process.exit(EXIT_CODES.BLOCK);
|
|
229
|
+
}
|
|
222
230
|
// Exit with success (handler errors exit via handleHandlerError with code 2)
|
|
223
231
|
process.exit(EXIT_CODES.SUCCESS);
|
|
224
232
|
}
|
package/dist/scaffold.js
CHANGED
|
@@ -119,7 +119,7 @@ function generatePackageJson(projectName, outputPath) {
|
|
|
119
119
|
"@goodfoot/claude-code-hooks": "^1.0.9",
|
|
120
120
|
},
|
|
121
121
|
devDependencies: {
|
|
122
|
-
"@biomejs/biome": "2.
|
|
122
|
+
"@biomejs/biome": "2.4.1",
|
|
123
123
|
"@types/node": "^22.0.0",
|
|
124
124
|
typescript: "^5.9.3",
|
|
125
125
|
vitest: "^4.0.16",
|
|
@@ -162,7 +162,7 @@ function generateTsConfig() {
|
|
|
162
162
|
*/
|
|
163
163
|
function generateBiomeConfig() {
|
|
164
164
|
return `{
|
|
165
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
165
|
+
"$schema": "https://biomejs.dev/schemas/2.4.1/schema.json",
|
|
166
166
|
"formatter": {
|
|
167
167
|
"enabled": true,
|
|
168
168
|
"indentStyle": "space",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodfoot/claude-code-hooks",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Type-safe Claude Code hooks library with camelCase types and output builders",
|
|
5
5
|
"homepage": "https://github.com/goodfoot-io/marketplace/tree/main/packages/claude-code-hooks",
|
|
6
6
|
"repository": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"typescript": "^5.9.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
57
|
-
"@biomejs/biome": "2.
|
|
56
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.42",
|
|
57
|
+
"@biomejs/biome": "2.4.1",
|
|
58
58
|
"@types/node": "^24",
|
|
59
59
|
"ts-morph": "^25.0.0",
|
|
60
60
|
"tsx": "^4.20.3",
|
package/types/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type { LogEvent, LogEventError, LogEventHandler, LoggerConfig, LogLevel,
|
|
|
13
13
|
export { LOG_LEVELS, Logger, logger } from "./logger.js";
|
|
14
14
|
export type {
|
|
15
15
|
/** @deprecated Use CommonOptions instead */
|
|
16
|
-
BaseOptions, CommonOptions, ExitCode, HookOutput, HookSpecificOutput, NotificationOptions, PermissionRequestAllowDecision, PermissionRequestDecision, PermissionRequestDenyDecision, PermissionRequestHookSpecificOutput, PermissionRequestOptions, PostToolUseFailureHookSpecificOutput, PostToolUseFailureOptions, PostToolUseHookSpecificOutput, PostToolUseOptions, PreCompactOptions, PreToolUseHookSpecificOutput, PreToolUseOptions, SessionEndOptions, SessionStartHookSpecificOutput, SessionStartOptions, SetupHookSpecificOutput, SetupOptions, StopOptions, SubagentStartHookSpecificOutput, SubagentStartOptions, SubagentStopOptions, SyncHookJSONOutput, TaskCompletedOptions, TeammateIdleOptions, UserPromptSubmitHookSpecificOutput, UserPromptSubmitOptions, } from "./outputs.js";
|
|
16
|
+
BaseOptions, CommonOptions, ExitCode, ExitCodeOptions, HookOutput, HookSpecificOutput, NotificationHookSpecificOutput, NotificationOptions, PermissionRequestAllowDecision, PermissionRequestDecision, PermissionRequestDenyDecision, PermissionRequestHookSpecificOutput, PermissionRequestOptions, PostToolUseFailureHookSpecificOutput, PostToolUseFailureOptions, PostToolUseHookSpecificOutput, PostToolUseOptions, PreCompactOptions, PreToolUseHookSpecificOutput, PreToolUseOptions, SessionEndOptions, SessionStartHookSpecificOutput, SessionStartOptions, SetupHookSpecificOutput, SetupOptions, StopOptions, SubagentStartHookSpecificOutput, SubagentStartOptions, SubagentStopOptions, SyncHookJSONOutput, TaskCompletedOptions, TeammateIdleOptions, UserPromptSubmitHookSpecificOutput, UserPromptSubmitOptions, } from "./outputs.js";
|
|
17
17
|
export { EXIT_CODES, notificationOutput, permissionRequestOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, } from "./outputs.js";
|
|
18
18
|
export { execute, } from "./runtime.js";
|
|
19
19
|
export type { ContentContext, PatternCheckResult, ToolUseInput } from "./tool-helpers.js";
|
package/types/outputs.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://code.claude.com/docs/en/hooks
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
import type { PermissionRequestHookSpecificOutput as SDKPermissionRequestHookSpecificOutput, PostToolUseFailureHookSpecificOutput as SDKPostToolUseFailureHookSpecificOutput, PostToolUseHookSpecificOutput as SDKPostToolUseHookSpecificOutput, PreToolUseHookSpecificOutput as SDKPreToolUseHookSpecificOutput, SessionStartHookSpecificOutput as SDKSessionStartHookSpecificOutput, SetupHookSpecificOutput as SDKSetupHookSpecificOutput, SubagentStartHookSpecificOutput as SDKSubagentStartHookSpecificOutput, SyncHookJSONOutput as SDKSyncHookJSONOutput, UserPromptSubmitHookSpecificOutput as SDKUserPromptSubmitHookSpecificOutput } from "@anthropic-ai/claude-agent-sdk/sdk.js";
|
|
10
|
+
import type { NotificationHookSpecificOutput as SDKNotificationHookSpecificOutput, PermissionRequestHookSpecificOutput as SDKPermissionRequestHookSpecificOutput, PostToolUseFailureHookSpecificOutput as SDKPostToolUseFailureHookSpecificOutput, PostToolUseHookSpecificOutput as SDKPostToolUseHookSpecificOutput, PreToolUseHookSpecificOutput as SDKPreToolUseHookSpecificOutput, SessionStartHookSpecificOutput as SDKSessionStartHookSpecificOutput, SetupHookSpecificOutput as SDKSetupHookSpecificOutput, SubagentStartHookSpecificOutput as SDKSubagentStartHookSpecificOutput, SyncHookJSONOutput as SDKSyncHookJSONOutput, UserPromptSubmitHookSpecificOutput as SDKUserPromptSubmitHookSpecificOutput } from "@anthropic-ai/claude-agent-sdk/sdk.js";
|
|
11
11
|
/**
|
|
12
12
|
* Exit codes used by Claude Code hooks.
|
|
13
13
|
*
|
|
@@ -36,7 +36,7 @@ export type { SDKSyncHookJSONOutput };
|
|
|
36
36
|
/**
|
|
37
37
|
* Re-export SDK hook-specific output types (includes hookEventName discriminator).
|
|
38
38
|
*/
|
|
39
|
-
export type { SDKPreToolUseHookSpecificOutput, SDKPostToolUseHookSpecificOutput, SDKPostToolUseFailureHookSpecificOutput, SDKUserPromptSubmitHookSpecificOutput, SDKSessionStartHookSpecificOutput, SDKSetupHookSpecificOutput, SDKSubagentStartHookSpecificOutput, SDKPermissionRequestHookSpecificOutput, };
|
|
39
|
+
export type { SDKNotificationHookSpecificOutput, SDKPreToolUseHookSpecificOutput, SDKPostToolUseHookSpecificOutput, SDKPostToolUseFailureHookSpecificOutput, SDKUserPromptSubmitHookSpecificOutput, SDKSessionStartHookSpecificOutput, SDKSetupHookSpecificOutput, SDKSubagentStartHookSpecificOutput, SDKPermissionRequestHookSpecificOutput, };
|
|
40
40
|
/**
|
|
41
41
|
* PreToolUse hook-specific output fields.
|
|
42
42
|
* Omits `hookEventName` which is added automatically by the builder.
|
|
@@ -98,18 +98,13 @@ export type PermissionRequestDenyDecision = Extract<SDKPermissionRequestHookSpec
|
|
|
98
98
|
export type PermissionRequestDecision = SDKPermissionRequestHookSpecificOutput["decision"];
|
|
99
99
|
/**
|
|
100
100
|
* Notification hook-specific output fields.
|
|
101
|
-
*
|
|
101
|
+
* Omits `hookEventName` which is added automatically by the builder.
|
|
102
102
|
*/
|
|
103
|
-
export
|
|
104
|
-
/** Additional context to add about the notification. */
|
|
105
|
-
additionalContext?: string;
|
|
106
|
-
}
|
|
103
|
+
export type NotificationHookSpecificOutput = Omit<SDKNotificationHookSpecificOutput, "hookEventName">;
|
|
107
104
|
/**
|
|
108
105
|
* Full hook-specific output with hookEventName discriminator.
|
|
109
106
|
*/
|
|
110
|
-
export type HookSpecificOutput = SDKPreToolUseHookSpecificOutput | SDKPostToolUseHookSpecificOutput | SDKPostToolUseFailureHookSpecificOutput | SDKUserPromptSubmitHookSpecificOutput | SDKSessionStartHookSpecificOutput | SDKSetupHookSpecificOutput | SDKSubagentStartHookSpecificOutput | SDKPermissionRequestHookSpecificOutput |
|
|
111
|
-
hookEventName: "Notification";
|
|
112
|
-
} & NotificationHookSpecificOutput);
|
|
107
|
+
export type HookSpecificOutput = SDKPreToolUseHookSpecificOutput | SDKPostToolUseHookSpecificOutput | SDKPostToolUseFailureHookSpecificOutput | SDKUserPromptSubmitHookSpecificOutput | SDKSessionStartHookSpecificOutput | SDKSetupHookSpecificOutput | SDKSubagentStartHookSpecificOutput | SDKPermissionRequestHookSpecificOutput | SDKNotificationHookSpecificOutput;
|
|
113
108
|
/**
|
|
114
109
|
* The JSON output format expected by Claude Code (sync hooks only).
|
|
115
110
|
* Extends SDK's SyncHookJSONOutput to include Notification hook support.
|
|
@@ -137,6 +132,8 @@ export interface SyncHookJSONOutput {
|
|
|
137
132
|
export interface HookOutput {
|
|
138
133
|
/** JSON-serializable output to write to stdout. */
|
|
139
134
|
stdout: SyncHookJSONOutput;
|
|
135
|
+
/** Optional message to write to stderr. When present, the runtime exits with code 2 (BLOCK). */
|
|
136
|
+
stderr?: string;
|
|
140
137
|
}
|
|
141
138
|
/**
|
|
142
139
|
* Common options available to all output builders.
|
|
@@ -152,12 +149,24 @@ export interface CommonOptions {
|
|
|
152
149
|
/** Reason for stopping/blocking (sets exit code to BLOCK). */
|
|
153
150
|
stopReason?: string;
|
|
154
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Options for exit-code-based hooks (TeammateIdle, TaskCompleted).
|
|
154
|
+
*
|
|
155
|
+
* These hooks use exit codes only, not JSON decision control.
|
|
156
|
+
* When `stderr` is provided, the runtime writes it to stderr and exits with code 2 (BLOCK).
|
|
157
|
+
* When absent, the hook exits with code 0 (SUCCESS).
|
|
158
|
+
*/
|
|
159
|
+
export interface ExitCodeOptions {
|
|
160
|
+
/** Message to write to stderr. When present, exits with code 2 (BLOCK). */
|
|
161
|
+
stderr?: string;
|
|
162
|
+
}
|
|
155
163
|
/**
|
|
156
164
|
* Base structure for all specific outputs.
|
|
157
165
|
*/
|
|
158
166
|
interface BaseSpecificOutput<T extends string> {
|
|
159
167
|
readonly _type: T;
|
|
160
168
|
stdout: SyncHookJSONOutput;
|
|
169
|
+
stderr?: string;
|
|
161
170
|
}
|
|
162
171
|
/**
|
|
163
172
|
*
|
|
@@ -611,39 +620,49 @@ export declare const setupOutput: (options?: CommonOptions & {
|
|
|
611
620
|
};
|
|
612
621
|
/**
|
|
613
622
|
* Options for the TeammateIdle output builder.
|
|
614
|
-
* TeammateIdle hooks only
|
|
623
|
+
* TeammateIdle hooks use exit codes only, not JSON decision control.
|
|
615
624
|
*/
|
|
616
|
-
export type TeammateIdleOptions =
|
|
625
|
+
export type TeammateIdleOptions = ExitCodeOptions;
|
|
617
626
|
/**
|
|
618
627
|
* Creates an output for TeammateIdle hooks.
|
|
619
628
|
* @param options - Configuration options for the hook output
|
|
620
629
|
* @returns A TeammateIdleOutput object ready for the runtime
|
|
621
630
|
* @example
|
|
622
631
|
* ```typescript
|
|
632
|
+
* // Allow teammate to go idle
|
|
623
633
|
* teammateIdleOutput({});
|
|
634
|
+
*
|
|
635
|
+
* // Block with feedback
|
|
636
|
+
* teammateIdleOutput({ stderr: 'Continue working: unfinished tasks remain.' });
|
|
624
637
|
* ```
|
|
625
638
|
*/
|
|
626
|
-
export declare const teammateIdleOutput: (
|
|
639
|
+
export declare const teammateIdleOutput: ({ stderr }?: ExitCodeOptions) => {
|
|
627
640
|
readonly _type: "TeammateIdle";
|
|
628
641
|
stdout: SyncHookJSONOutput;
|
|
642
|
+
stderr?: string;
|
|
629
643
|
};
|
|
630
644
|
/**
|
|
631
645
|
* Options for the TaskCompleted output builder.
|
|
632
|
-
* TaskCompleted hooks only
|
|
646
|
+
* TaskCompleted hooks use exit codes only, not JSON decision control.
|
|
633
647
|
*/
|
|
634
|
-
export type TaskCompletedOptions =
|
|
648
|
+
export type TaskCompletedOptions = ExitCodeOptions;
|
|
635
649
|
/**
|
|
636
650
|
* Creates an output for TaskCompleted hooks.
|
|
637
651
|
* @param options - Configuration options for the hook output
|
|
638
652
|
* @returns A TaskCompletedOutput object ready for the runtime
|
|
639
653
|
* @example
|
|
640
654
|
* ```typescript
|
|
655
|
+
* // Allow task completion
|
|
641
656
|
* taskCompletedOutput({});
|
|
657
|
+
*
|
|
658
|
+
* // Block with feedback
|
|
659
|
+
* taskCompletedOutput({ stderr: 'Cannot complete: tests are failing.' });
|
|
642
660
|
* ```
|
|
643
661
|
*/
|
|
644
|
-
export declare const taskCompletedOutput: (
|
|
662
|
+
export declare const taskCompletedOutput: ({ stderr }?: ExitCodeOptions) => {
|
|
645
663
|
readonly _type: "TaskCompleted";
|
|
646
664
|
stdout: SyncHookJSONOutput;
|
|
665
|
+
stderr?: string;
|
|
647
666
|
};
|
|
648
667
|
/**
|
|
649
668
|
* @deprecated Use CommonOptions instead
|
package/types/runtime.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ import type { HookInput } from "./types.js";
|
|
|
24
24
|
/**
|
|
25
25
|
* Converts a SpecificHookOutput to HookOutput for wire format.
|
|
26
26
|
*
|
|
27
|
-
* SpecificHookOutput types have: { _type,
|
|
28
|
-
* HookOutput has: {
|
|
27
|
+
* SpecificHookOutput types have: { _type, stdout, stderr? }
|
|
28
|
+
* HookOutput has: { stdout, stderr? }
|
|
29
29
|
*
|
|
30
30
|
* Since output builders now produce wire-format directly, this function
|
|
31
31
|
* simply strips the `_type` discriminator field.
|
|
@@ -36,7 +36,7 @@ import type { HookInput } from "./types.js";
|
|
|
36
36
|
* ```typescript
|
|
37
37
|
* const specificOutput = preToolUseOutput({ hookSpecificOutput: { permissionDecision: 'allow' } });
|
|
38
38
|
* const hookOutput = convertToHookOutput(specificOutput);
|
|
39
|
-
* // hookOutput: {
|
|
39
|
+
* // hookOutput: { stdout: { hookSpecificOutput: { ... } } }
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
42
|
export declare function convertToHookOutput(specificOutput: SpecificHookOutput): HookOutput;
|
package/types/types.d.ts
CHANGED
|
@@ -45,10 +45,11 @@ export type PreCompactTrigger = "manual" | "auto";
|
|
|
45
45
|
* - `'logout'` - User logged out
|
|
46
46
|
* - `'prompt_input_exit'` - User exited at prompt input
|
|
47
47
|
* - `'other'` - Other reasons
|
|
48
|
+
* - `'bypass_permissions_disabled'` - Session ended because bypass permissions was disabled
|
|
48
49
|
*
|
|
49
50
|
* Note: SDK's ExitReason resolves to string. This type provides concrete literals for better DX.
|
|
50
51
|
*/
|
|
51
|
-
export type SessionEndReason = "clear" | "logout" | "prompt_input_exit" | "other";
|
|
52
|
+
export type SessionEndReason = "clear" | "logout" | "prompt_input_exit" | "other" | "bypass_permissions_disabled";
|
|
52
53
|
/**
|
|
53
54
|
* Common fields present in all hook inputs.
|
|
54
55
|
*
|