@goodfoot/agent-hooks 1.0.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.
Files changed (68) hide show
  1. package/README.md +137 -0
  2. package/dist/agents/antigravity/events.js +42 -0
  3. package/dist/agents/antigravity/hooks.js +59 -0
  4. package/dist/agents/antigravity/index.js +28 -0
  5. package/dist/agents/antigravity/outputs.js +81 -0
  6. package/dist/agents/antigravity/transport.js +84 -0
  7. package/dist/agents/antigravity/types.js +11 -0
  8. package/dist/agents/claude-code/env.js +27 -0
  9. package/dist/agents/claude-code/events.js +87 -0
  10. package/dist/agents/claude-code/hooks.js +1000 -0
  11. package/dist/agents/claude-code/index.js +57 -0
  12. package/dist/agents/claude-code/outputs.js +579 -0
  13. package/dist/agents/claude-code/tool-helpers.js +840 -0
  14. package/dist/agents/claude-code/transport.js +254 -0
  15. package/dist/agents/claude-code/types.js +11 -0
  16. package/dist/agents/codex/cli-support.js +318 -0
  17. package/dist/agents/codex/constants.js +29 -0
  18. package/dist/agents/codex/events.js +68 -0
  19. package/dist/agents/codex/hooks.js +93 -0
  20. package/dist/agents/codex/index.js +21 -0
  21. package/dist/agents/codex/outputs.js +189 -0
  22. package/dist/agents/codex/scaffold.js +273 -0
  23. package/dist/agents/codex/transport.js +139 -0
  24. package/dist/agents/codex/types.js +1 -0
  25. package/dist/cli.js +1357 -0
  26. package/dist/constants.js +39 -0
  27. package/dist/core/define-hook.js +61 -0
  28. package/dist/core/env.js +186 -0
  29. package/dist/core/logger.js +508 -0
  30. package/dist/core/stdin.js +38 -0
  31. package/dist/core/transport.js +231 -0
  32. package/dist/core/types.js +10 -0
  33. package/dist/index.js +17 -0
  34. package/dist/scaffold.js +512 -0
  35. package/package.json +61 -0
  36. package/types/agents/antigravity/events.d.ts +50 -0
  37. package/types/agents/antigravity/hooks.d.ts +76 -0
  38. package/types/agents/antigravity/index.d.ts +27 -0
  39. package/types/agents/antigravity/outputs.d.ts +107 -0
  40. package/types/agents/antigravity/transport.d.ts +47 -0
  41. package/types/agents/antigravity/types.d.ts +58 -0
  42. package/types/agents/claude-code/env.d.ts +27 -0
  43. package/types/agents/claude-code/events.d.ts +69 -0
  44. package/types/agents/claude-code/hooks.d.ts +1182 -0
  45. package/types/agents/claude-code/index.d.ts +23 -0
  46. package/types/agents/claude-code/outputs.d.ts +1160 -0
  47. package/types/agents/claude-code/tool-helpers.d.ts +807 -0
  48. package/types/agents/claude-code/transport.d.ts +119 -0
  49. package/types/agents/claude-code/types.d.ts +557 -0
  50. package/types/agents/codex/cli-support.d.ts +105 -0
  51. package/types/agents/codex/constants.d.ts +10 -0
  52. package/types/agents/codex/events.d.ts +63 -0
  53. package/types/agents/codex/hooks.d.ts +135 -0
  54. package/types/agents/codex/index.d.ts +19 -0
  55. package/types/agents/codex/outputs.d.ts +190 -0
  56. package/types/agents/codex/scaffold.d.ts +14 -0
  57. package/types/agents/codex/transport.d.ts +74 -0
  58. package/types/agents/codex/types.d.ts +131 -0
  59. package/types/cli.d.ts +315 -0
  60. package/types/constants.d.ts +9 -0
  61. package/types/core/define-hook.d.ts +39 -0
  62. package/types/core/env.d.ts +150 -0
  63. package/types/core/logger.d.ts +476 -0
  64. package/types/core/stdin.d.ts +21 -0
  65. package/types/core/transport.d.ts +131 -0
  66. package/types/core/types.d.ts +137 -0
  67. package/types/index.d.ts +18 -0
  68. package/types/scaffold.d.ts +46 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * `@goodfoot/agent-hooks/claude-code` — the Claude Code agent surface.
3
+ *
4
+ * Re-exports every hook factory (all 30, including `postToolBatchHook`),
5
+ * their output builders, the input/output types, tool-helper guards, env
6
+ * utilities, the advisory allow-list events module, and the runtime
7
+ * `execute` entry point. No default export.
8
+ * @module
9
+ */
10
+ // Logger exports
11
+ export { LOG_LEVELS, Logger, logger } from "../../core/logger.js";
12
+ // Environment variable utilities
13
+ export { CLAUDE_ENV_VARS, getEnvFilePath, getProjectDir, isRemoteEnvironment, persistEnvVar, persistEnvVars, } from "./env.js";
14
+ // Advisory allow-list events
15
+ export { ADVISORY_EVENTS, EXCLUDED_FROM_ADVISORY, HOOK_EVENT_NAMES } from "./events.js";
16
+ // Hook factory functions - all 30 hook types
17
+ export { configChangeHook, cwdChangedHook, elicitationHook, elicitationResultHook, fileChangedHook, instructionsLoadedHook, messageDisplayHook, notificationHook, permissionDeniedHook, permissionRequestHook, postCompactHook, postToolBatchHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopFailureHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, taskCreatedHook, teammateIdleHook, userPromptExpansionHook, userPromptSubmitHook, worktreeCreateHook, worktreeRemoveHook, } from "./hooks.js";
18
+ // Output builder functions
19
+ export { configChangeOutput, cwdChangedOutput,
20
+ // Exit codes
21
+ EXIT_CODES, elicitationOutput, elicitationResultOutput, fileChangedOutput, instructionsLoadedOutput, messageDisplayOutput, notificationOutput, permissionDeniedOutput, permissionRequestOutput, postCompactOutput, postToolBatchOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopFailureOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, taskCreatedOutput, teammateIdleOutput, userPromptExpansionOutput, userPromptSubmitOutput, worktreeCreateOutput, worktreeRemoveOutput, } from "./outputs.js";
22
+ // Tool helper functions - Type guards and utilities
23
+ export {
24
+ // Content inspection
25
+ checkContentForPattern, forEachContent,
26
+ // File path utilities
27
+ getFilePath,
28
+ // Type guards - User interaction
29
+ isAskUserQuestionTool,
30
+ // Type guards - Commands
31
+ isBashTool,
32
+ // Type guards - Config
33
+ isConfigTool,
34
+ // Type guards - Cron
35
+ isCronCreateTool, isCronDeleteTool, isCronListTool, isEditTool,
36
+ // Type guards - Plan mode & Worktrees
37
+ isEnterPlanModeTool, isEnterWorktreeTool, isExitPlanModeTool, isExitWorktreeTool, isFileModifyingTool,
38
+ // Type guards - Search
39
+ isGlobTool, isGrepTool, isJsTsFile, isKillShellTool,
40
+ // Type guards - MCP
41
+ isListMcpResourcesTool, isMcpTool,
42
+ // Type guards - Monitoring & scheduling
43
+ isMonitorTool, isMultiEditTool, isNotebookEditTool, isPushNotificationTool, isReadMcpResourceTool, isReadTool, isRemoteTriggerTool,
44
+ // Type guards - REPL & Workflow
45
+ isReplTool, isScheduleWakeupTool,
46
+ // Type guards - Task management
47
+ isTaskCreateTool, isTaskGetTool, isTaskListTool, isTaskOutputTool,
48
+ // Type guards - Agents
49
+ isTaskTool, isTaskUpdateTool, isTodoWriteTool, isTsFile,
50
+ // Type guards - Web
51
+ isWebFetchTool, isWebSearchTool, isWorkflowTool,
52
+ // Type guards - File operations
53
+ isWriteTool, } from "./tool-helpers.js";
54
+ // Runtime exports - execute function and wire translation surface
55
+ export { BLOCK_SHAPE_BY_EVENT, convertToHookOutput, createClaudeCodeTransport,
56
+ // Main execute function for compiled hooks
57
+ execute, } from "./transport.js";
@@ -0,0 +1,579 @@
1
+ /**
2
+ * Output types and builders for Claude Code hooks.
3
+ *
4
+ * Provides type-safe output builder functions for all 30 hook types. Each builder
5
+ * accepts options that match the wire format expected by Claude Code, with types
6
+ * derived from the Claude Agent SDK's `SyncHookJSONOutput` type.
7
+ * @see https://code.claude.com/docs/en/hooks
8
+ * @module
9
+ */
10
+ // ============================================================================
11
+ // Exit Code Constants
12
+ // ============================================================================
13
+ /**
14
+ * Exit codes used by Claude Code hooks.
15
+ *
16
+ * | Exit Code | Name | When Used | Claude Code Behavior |
17
+ * |-----------|------|-----------|---------------------|
18
+ * | 0 | Success | Handler returns normally | Continue, parse stdout as JSON |
19
+ * | 1 | Error | Invalid input, non-blocking error | Non-blocking, stderr to user only |
20
+ * | 2 | Block | Handler throws OR `stopReason` set | Blocking, stderr shown to Claude |
21
+ */
22
+ export const EXIT_CODES = {
23
+ /** Handler completed successfully. Claude Code parses stdout as JSON. */
24
+ SUCCESS: 0,
25
+ /** Non-blocking error occurred (e.g., invalid input). stderr shown to user only. */
26
+ ERROR: 1,
27
+ /** Handler threw exception OR blocking action requested. stderr shown to Claude. */
28
+ BLOCK: 2,
29
+ };
30
+ // ============================================================================
31
+ // Output Builder Factories
32
+ // ============================================================================
33
+ /**
34
+ * Factory for hooks that have hookSpecificOutput with a hookEventName discriminator.
35
+ * @param hookType - The hook type name used as the _type discriminator
36
+ * @returns A builder function that creates the output object
37
+ * @internal
38
+ */
39
+ function createHookSpecificOutputBuilder(hookType) {
40
+ return (options = {}) => {
41
+ const { hookSpecificOutput, ...rest } = options;
42
+ const stdout = hookSpecificOutput !== undefined
43
+ ? { ...rest, hookSpecificOutput: { hookEventName: hookType, ...hookSpecificOutput } }
44
+ : rest;
45
+ return { _type: hookType, stdout };
46
+ };
47
+ }
48
+ /**
49
+ * Factory for hooks that only use CommonOptions (simple passthrough).
50
+ * @param hookType - The hook type name used as the _type discriminator
51
+ * @returns A builder function that creates the output object
52
+ * @internal
53
+ */
54
+ function createSimpleOutputBuilder(hookType) {
55
+ return (options = {}) => ({
56
+ _type: hookType,
57
+ stdout: options,
58
+ });
59
+ }
60
+ /**
61
+ * Factory for worktree hooks (WorktreeCreate, WorktreeRemove).
62
+ *
63
+ * These are command hooks whose wire protocol is a **bare path on stdout**, not JSON:
64
+ * Claude Code reads the hook's stdout verbatim and `chdir`s into it. The builder carries
65
+ * the path in `rawStdout` so the runtime emits it as plain text instead of
66
+ * `JSON.stringify(stdout)`.
67
+ * @param hookType - The hook type name used as the _type discriminator
68
+ * @returns A builder function that creates the output object
69
+ * @internal
70
+ */
71
+ function createWorktreeOutputBuilder(hookType) {
72
+ return (options) => {
73
+ const { worktreePath, ...rest } = options;
74
+ return { _type: hookType, stdout: rest, rawStdout: worktreePath };
75
+ };
76
+ }
77
+ /**
78
+ * Factory for hooks that use decision-based options (Stop, SubagentStop).
79
+ * @param hookType - The hook type name used as the _type discriminator
80
+ * @returns A builder function that creates the output object
81
+ * @internal
82
+ */
83
+ function createDecisionOutputBuilder(hookType) {
84
+ return (options = {}) => ({
85
+ _type: hookType,
86
+ stdout: options,
87
+ });
88
+ }
89
+ /**
90
+ * Factory for exit-code-based hooks (TeammateIdle, TaskCompleted).
91
+ *
92
+ * These hooks don't use JSON decision control (no CommonOptions).
93
+ * The only option is `stderr` — when present, it triggers exit code 2 (BLOCK).
94
+ * Stdout always receives `{}` (empty JSON object).
95
+ * @param hookType - The hook type name used as the _type discriminator
96
+ * @returns A builder function that creates the output object
97
+ * @internal
98
+ */
99
+ function createExitCodeOutputBuilder(hookType) {
100
+ return ({ stderr } = {}) => ({
101
+ _type: hookType,
102
+ stdout: {},
103
+ ...(stderr !== undefined ? { stderr } : {}),
104
+ });
105
+ }
106
+ /**
107
+ * Creates an output for PreToolUse hooks.
108
+ * @param options - Configuration options for the hook output
109
+ * @returns A PreToolUseOutput object ready for the runtime
110
+ * @example
111
+ * ```typescript
112
+ * // Allow tool execution
113
+ * preToolUseOutput({
114
+ * hookSpecificOutput: { permissionDecision: 'allow' }
115
+ * });
116
+ *
117
+ * // Deny with reason
118
+ * preToolUseOutput({
119
+ * hookSpecificOutput: {
120
+ * permissionDecision: 'deny',
121
+ * permissionDecisionReason: 'Dangerous command detected'
122
+ * }
123
+ * });
124
+ *
125
+ * // Allow with modified input
126
+ * preToolUseOutput({
127
+ * hookSpecificOutput: {
128
+ * permissionDecision: 'allow',
129
+ * updatedInput: { command: 'ls -la' }
130
+ * }
131
+ * });
132
+ * ```
133
+ */
134
+ export const preToolUseOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("PreToolUse");
135
+ /**
136
+ * Creates an output for PostToolUse hooks.
137
+ * @param options - Configuration options for the hook output
138
+ * @returns A PostToolUseOutput object ready for the runtime
139
+ * @example
140
+ * ```typescript
141
+ * // Add context after a file read
142
+ * postToolUseOutput({
143
+ * hookSpecificOutput: {
144
+ * additionalContext: 'File contains sensitive data'
145
+ * }
146
+ * });
147
+ * ```
148
+ */
149
+ export const postToolUseOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("PostToolUse");
150
+ /**
151
+ * Creates an output for PostToolUseFailure hooks.
152
+ * @param options - Configuration options for the hook output
153
+ * @returns A PostToolUseFailureOutput object ready for the runtime
154
+ * @example
155
+ * ```typescript
156
+ * postToolUseFailureOutput({
157
+ * hookSpecificOutput: {
158
+ * additionalContext: 'Try using a different approach'
159
+ * }
160
+ * });
161
+ * ```
162
+ */
163
+ export const postToolUseFailureOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("PostToolUseFailure");
164
+ /**
165
+ * Creates an output for PostToolBatch hooks.
166
+ * @param options - Configuration options for the hook output
167
+ * @returns A PostToolBatchOutput object ready for the runtime
168
+ * @example
169
+ * ```typescript
170
+ * postToolBatchOutput({
171
+ * hookSpecificOutput: {
172
+ * additionalContext: 'All edits in the batch were applied successfully'
173
+ * }
174
+ * });
175
+ * ```
176
+ */
177
+ export const postToolBatchOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("PostToolBatch");
178
+ /**
179
+ * Creates an output for UserPromptExpansion hooks.
180
+ * @param options - Configuration options for the hook output
181
+ * @returns A UserPromptExpansionOutput object ready for the runtime
182
+ * @example
183
+ * ```typescript
184
+ * userPromptExpansionOutput({
185
+ * hookSpecificOutput: {
186
+ * additionalContext: 'Slash command expanded with additional context'
187
+ * }
188
+ * });
189
+ * ```
190
+ */
191
+ export const userPromptExpansionOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("UserPromptExpansion");
192
+ /**
193
+ * Creates an output for UserPromptSubmit hooks.
194
+ * @param options - Configuration options for the hook output
195
+ * @returns A UserPromptSubmitOutput object ready for the runtime
196
+ * @example
197
+ * ```typescript
198
+ * userPromptSubmitOutput({
199
+ * hookSpecificOutput: {
200
+ * additionalContext: 'This project uses TypeScript strict mode'
201
+ * }
202
+ * });
203
+ * ```
204
+ */
205
+ export const userPromptSubmitOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("UserPromptSubmit");
206
+ /**
207
+ * Creates an output for SessionStart hooks.
208
+ * @param options - Configuration options for the hook output
209
+ * @returns A SessionStartOutput object ready for the runtime
210
+ * @example
211
+ * ```typescript
212
+ * sessionStartOutput({
213
+ * hookSpecificOutput: {
214
+ * additionalContext: JSON.stringify({ project: 'my-project' })
215
+ * }
216
+ * });
217
+ * ```
218
+ */
219
+ export const sessionStartOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("SessionStart");
220
+ /**
221
+ * Creates an output for SessionEnd hooks.
222
+ * @param options - Configuration options for the hook output
223
+ * @returns A SessionEndOutput object ready for the runtime
224
+ * @example
225
+ * ```typescript
226
+ * sessionEndOutput({});
227
+ * ```
228
+ */
229
+ export const sessionEndOutput = /* @__PURE__ */ createSimpleOutputBuilder("SessionEnd");
230
+ /**
231
+ * Creates an output for Stop hooks.
232
+ * @param options - Configuration options for the hook output
233
+ * @returns A StopOutput object ready for the runtime
234
+ * @example
235
+ * ```typescript
236
+ * // Allow the stop
237
+ * stopOutput({ decision: 'approve' });
238
+ *
239
+ * // Block with reason
240
+ * stopOutput({
241
+ * decision: 'block',
242
+ * reason: 'There are uncommitted changes'
243
+ * });
244
+ * ```
245
+ */
246
+ export const stopOutput = /* @__PURE__ */ createDecisionOutputBuilder("Stop");
247
+ /**
248
+ * Creates an output for StopFailure hooks.
249
+ * @param options - Configuration options for the hook output
250
+ * @returns A StopFailureOutput object ready for the runtime
251
+ * @example
252
+ * ```typescript
253
+ * stopFailureOutput({});
254
+ * ```
255
+ */
256
+ export const stopFailureOutput = /* @__PURE__ */ createSimpleOutputBuilder("StopFailure");
257
+ /**
258
+ * Creates an output for SubagentStart hooks.
259
+ * @param options - Configuration options for the hook output
260
+ * @returns A SubagentStartOutput object ready for the runtime
261
+ * @example
262
+ * ```typescript
263
+ * subagentStartOutput({
264
+ * hookSpecificOutput: {
265
+ * additionalContext: 'Focus on finding patterns'
266
+ * }
267
+ * });
268
+ * ```
269
+ */
270
+ export const subagentStartOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("SubagentStart");
271
+ /**
272
+ * Creates an output for SubagentStop hooks.
273
+ * @param options - Configuration options for the hook output
274
+ * @returns A SubagentStopOutput object ready for the runtime
275
+ * @example
276
+ * ```typescript
277
+ * // Block with reason
278
+ * subagentStopOutput({
279
+ * decision: 'block',
280
+ * reason: 'Task not complete'
281
+ * });
282
+ * ```
283
+ */
284
+ export const subagentStopOutput = /* @__PURE__ */ createDecisionOutputBuilder("SubagentStop");
285
+ /**
286
+ * Creates an output for Notification hooks.
287
+ * @param options - Configuration options for the hook output
288
+ * @returns A NotificationOutput object ready for the runtime
289
+ * @example
290
+ * ```typescript
291
+ * // Add context about the notification
292
+ * notificationOutput({
293
+ * hookSpecificOutput: {
294
+ * additionalContext: 'Notification forwarded to Slack #alerts channel'
295
+ * }
296
+ * });
297
+ *
298
+ * // Suppress the notification
299
+ * notificationOutput({ suppressOutput: true });
300
+ * ```
301
+ */
302
+ export const notificationOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("Notification");
303
+ /**
304
+ * Creates an output for PreCompact hooks.
305
+ * @param options - Configuration options for the hook output
306
+ * @returns A PreCompactOutput object ready for the runtime
307
+ * @example
308
+ * ```typescript
309
+ * preCompactOutput({
310
+ * systemMessage: 'Remember: strict mode is enabled'
311
+ * });
312
+ * ```
313
+ */
314
+ export const preCompactOutput = /* @__PURE__ */ createSimpleOutputBuilder("PreCompact");
315
+ /**
316
+ * Creates an output for PostCompact hooks.
317
+ * @param options - Configuration options for the hook output
318
+ * @returns A PostCompactOutput object ready for the runtime
319
+ * @example
320
+ * ```typescript
321
+ * postCompactOutput({});
322
+ * ```
323
+ */
324
+ export const postCompactOutput = /* @__PURE__ */ createSimpleOutputBuilder("PostCompact");
325
+ /**
326
+ * Creates an output for PermissionRequest hooks.
327
+ * @param options - Configuration options for the hook output
328
+ * @returns A PermissionRequestOutput object ready for the runtime
329
+ * @example
330
+ * ```typescript
331
+ * // Auto-approve
332
+ * permissionRequestOutput({
333
+ * hookSpecificOutput: {
334
+ * decision: { behavior: 'allow' }
335
+ * }
336
+ * });
337
+ *
338
+ * // Auto-approve with modified input
339
+ * permissionRequestOutput({
340
+ * hookSpecificOutput: {
341
+ * decision: {
342
+ * behavior: 'allow',
343
+ * updatedInput: { file_path: '/safe/path' }
344
+ * }
345
+ * }
346
+ * });
347
+ *
348
+ * // Auto-deny
349
+ * permissionRequestOutput({
350
+ * hookSpecificOutput: {
351
+ * decision: {
352
+ * behavior: 'deny',
353
+ * message: 'Not allowed',
354
+ * interrupt: true
355
+ * }
356
+ * }
357
+ * });
358
+ *
359
+ * // Fall through to normal prompt
360
+ * permissionRequestOutput({});
361
+ * ```
362
+ */
363
+ export const permissionRequestOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("PermissionRequest");
364
+ /**
365
+ * Creates an output for PermissionDenied hooks.
366
+ * @param options - Configuration options for the hook output
367
+ * @returns A PermissionDeniedOutput object ready for the runtime
368
+ * @example
369
+ * ```typescript
370
+ * // Log and allow retry
371
+ * permissionDeniedOutput({
372
+ * hookSpecificOutput: { retry: true }
373
+ * });
374
+ *
375
+ * // Log without retry
376
+ * permissionDeniedOutput({});
377
+ * ```
378
+ */
379
+ export const permissionDeniedOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("PermissionDenied");
380
+ /**
381
+ * Creates an output for Setup hooks.
382
+ * @param options - Configuration options for the hook output
383
+ * @returns A SetupOutput object ready for the runtime
384
+ * @example
385
+ * ```typescript
386
+ * // Add context during setup
387
+ * setupOutput({
388
+ * hookSpecificOutput: {
389
+ * additionalContext: 'Project initialized with custom settings'
390
+ * }
391
+ * });
392
+ *
393
+ * // Simple passthrough
394
+ * setupOutput({});
395
+ * ```
396
+ */
397
+ export const setupOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("Setup");
398
+ /**
399
+ * Creates an output for TeammateIdle hooks.
400
+ * @param options - Configuration options for the hook output
401
+ * @returns A TeammateIdleOutput object ready for the runtime
402
+ * @example
403
+ * ```typescript
404
+ * // Allow teammate to go idle
405
+ * teammateIdleOutput({});
406
+ *
407
+ * // Block with feedback
408
+ * teammateIdleOutput({ stderr: 'Continue working: unfinished tasks remain.' });
409
+ * ```
410
+ */
411
+ export const teammateIdleOutput = /* @__PURE__ */ createExitCodeOutputBuilder("TeammateIdle");
412
+ /**
413
+ * Creates an output for TaskCreated hooks.
414
+ * @param options - Configuration options for the hook output
415
+ * @returns A TaskCreatedOutput object ready for the runtime
416
+ * @example
417
+ * ```typescript
418
+ * // Allow task creation
419
+ * taskCreatedOutput({});
420
+ *
421
+ * // Block with feedback
422
+ * taskCreatedOutput({ stderr: 'Cannot create task: missing required fields.' });
423
+ * ```
424
+ */
425
+ export const taskCreatedOutput = /* @__PURE__ */ createExitCodeOutputBuilder("TaskCreated");
426
+ /**
427
+ * Creates an output for TaskCompleted hooks.
428
+ * @param options - Configuration options for the hook output
429
+ * @returns A TaskCompletedOutput object ready for the runtime
430
+ * @example
431
+ * ```typescript
432
+ * // Allow task completion
433
+ * taskCompletedOutput({});
434
+ *
435
+ * // Block with feedback
436
+ * taskCompletedOutput({ stderr: 'Cannot complete: tests are failing.' });
437
+ * ```
438
+ */
439
+ export const taskCompletedOutput = /* @__PURE__ */ createExitCodeOutputBuilder("TaskCompleted");
440
+ /**
441
+ * Creates an output for Elicitation hooks.
442
+ * @param options - Configuration options for the hook output
443
+ * @returns An ElicitationOutput object ready for the runtime
444
+ * @example
445
+ * ```typescript
446
+ * // Accept the elicitation
447
+ * elicitationOutput({
448
+ * hookSpecificOutput: { action: 'accept', content: { username: 'alice' } }
449
+ * });
450
+ *
451
+ * // Decline the elicitation
452
+ * elicitationOutput({
453
+ * hookSpecificOutput: { action: 'decline' }
454
+ * });
455
+ * ```
456
+ */
457
+ export const elicitationOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("Elicitation");
458
+ /**
459
+ * Creates an output for ElicitationResult hooks.
460
+ * @param options - Configuration options for the hook output
461
+ * @returns An ElicitationResultOutput object ready for the runtime
462
+ * @example
463
+ * ```typescript
464
+ * elicitationResultOutput({});
465
+ * ```
466
+ */
467
+ export const elicitationResultOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("ElicitationResult");
468
+ /**
469
+ * Creates an output for ConfigChange hooks.
470
+ * @param options - Configuration options for the hook output
471
+ * @returns A ConfigChangeOutput object ready for the runtime
472
+ * @example
473
+ * ```typescript
474
+ * configChangeOutput({});
475
+ * ```
476
+ */
477
+ export const configChangeOutput = /* @__PURE__ */ createSimpleOutputBuilder("ConfigChange");
478
+ /**
479
+ * Creates an output for InstructionsLoaded hooks.
480
+ * @param options - Configuration options for the hook output
481
+ * @returns An InstructionsLoadedOutput object ready for the runtime
482
+ * @example
483
+ * ```typescript
484
+ * instructionsLoadedOutput({});
485
+ * ```
486
+ */
487
+ export const instructionsLoadedOutput =
488
+ /* @__PURE__ */ createSimpleOutputBuilder("InstructionsLoaded");
489
+ /**
490
+ * Creates an output for WorktreeCreate hooks.
491
+ *
492
+ * The runtime writes `worktreePath` to stdout as plain text (not JSON) so Claude Code
493
+ * can `chdir` into the created worktree.
494
+ * @param options - Configuration options for the hook output
495
+ * @returns A WorktreeCreateOutput object ready for the runtime
496
+ * @example
497
+ * ```typescript
498
+ * worktreeCreateOutput({ worktreePath: '/abs/path/to/worktree' });
499
+ * ```
500
+ */
501
+ export const worktreeCreateOutput = /* @__PURE__ */ createWorktreeOutputBuilder("WorktreeCreate");
502
+ /**
503
+ * Creates an output for WorktreeRemove hooks.
504
+ *
505
+ * When `worktreePath` is supplied, the runtime writes it to stdout as plain text (not
506
+ * JSON), matching the worktree command-hook protocol.
507
+ * @param options - Configuration options for the hook output
508
+ * @returns A WorktreeRemoveOutput object ready for the runtime
509
+ * @example
510
+ * ```typescript
511
+ * // Plain-text path protocol
512
+ * worktreeRemoveOutput({ worktreePath: '/abs/path/to/worktree' });
513
+ *
514
+ * // No path payload
515
+ * worktreeRemoveOutput({});
516
+ * ```
517
+ */
518
+ export const worktreeRemoveOutput = (options = {}) => {
519
+ const { worktreePath, ...rest } = options;
520
+ return worktreePath !== undefined
521
+ ? { _type: "WorktreeRemove", stdout: rest, rawStdout: worktreePath }
522
+ : { _type: "WorktreeRemove", stdout: rest };
523
+ };
524
+ /**
525
+ * Creates an output for CwdChanged hooks.
526
+ * @param options - Configuration options for the hook output
527
+ * @returns A CwdChangedOutput object ready for the runtime
528
+ * @example
529
+ * ```typescript
530
+ * // Return additional paths to watch after the cwd change
531
+ * cwdChangedOutput({
532
+ * hookSpecificOutput: {
533
+ * watchPaths: ['/new/path/to/watch']
534
+ * }
535
+ * });
536
+ *
537
+ * // Simple passthrough
538
+ * cwdChangedOutput({});
539
+ * ```
540
+ */
541
+ export const cwdChangedOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("CwdChanged");
542
+ /**
543
+ * Creates an output for FileChanged hooks.
544
+ * @param options - Configuration options for the hook output
545
+ * @returns A FileChangedOutput object ready for the runtime
546
+ * @example
547
+ * ```typescript
548
+ * // Update the set of watched paths
549
+ * fileChangedOutput({
550
+ * hookSpecificOutput: {
551
+ * watchPaths: ['/path/to/watch', '/another/path']
552
+ * }
553
+ * });
554
+ *
555
+ * // Simple passthrough
556
+ * fileChangedOutput({});
557
+ * ```
558
+ */
559
+ export const fileChangedOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("FileChanged");
560
+ /**
561
+ * Creates an output for MessageDisplay hooks.
562
+ *
563
+ * MessageDisplay is display-only: the `displayContent` field replaces the delta on
564
+ * screen without changing the stored message or what the model sees. Omit
565
+ * `displayContent` (or set it to the original delta) to leave the display unchanged.
566
+ * @param options - Configuration options for the hook output
567
+ * @returns A MessageDisplayOutput object ready for the runtime
568
+ * @example
569
+ * ```typescript
570
+ * // Replace the delta shown on screen
571
+ * messageDisplayOutput({
572
+ * hookSpecificOutput: { displayContent: "[redacted]" }
573
+ * });
574
+ *
575
+ * // Passthrough (no display modification)
576
+ * messageDisplayOutput({});
577
+ * ```
578
+ */
579
+ export const messageDisplayOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("MessageDisplay");