@goodfoot/claude-code-hooks 1.0.18 → 1.0.20

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 CHANGED
@@ -16,7 +16,6 @@
16
16
  */
17
17
  import * as crypto from "node:crypto";
18
18
  import * as fs from "node:fs";
19
- import * as os from "node:os";
20
19
  import * as path from "node:path";
21
20
  import * as esbuild from "esbuild";
22
21
  import { glob } from "glob";
@@ -374,51 +373,58 @@ async function discoverHookFiles(pattern, cwd) {
374
373
  /**
375
374
  * Compiles a TypeScript hook file to a self-contained ESM executable.
376
375
  *
376
+ * Uses esbuild's stdin option to avoid writing temporary wrapper files to disk.
377
+ * This produces stable, reproducible builds by:
378
+ * - Using a distinct sourcefile name to avoid import resolution conflicts
379
+ * - Eliminating environment-specific temp paths from source comments
380
+ *
377
381
  * Uses a two-step process to generate stable content hashes:
378
382
  * 1. Compile WITHOUT sourcemaps → generate stable content hash
379
383
  * 2. Compile WITH sourcemaps → final output content
380
384
  *
381
- * This ensures content hashes are reproducible across different build
382
- * environments, since sourcemaps contain file paths that can vary.
383
- *
384
385
  * @param options - Compilation options
385
386
  * @returns Compiled content and stable content hash
386
387
  */
387
388
  async function compileHook(options) {
388
389
  const { sourcePath, logFilePath } = options;
389
- // Create a temporary wrapper file that imports the hook and executes it
390
- // Use system temp directory with deterministic name based on hook basename (not full path)
391
- // This ensures builds are reproducible across different environments/machines
392
- const hashInputs = [path.basename(sourcePath), logFilePath ? "log" : ""].join(":");
393
- const buildHash = crypto.createHash("sha256").update(hashInputs).digest("hex").substring(0, 16);
394
- const tempDir = path.join(os.tmpdir(), "claude-code-hooks-build", buildHash);
395
- const wrapperPath = path.join(tempDir, "wrapper.ts");
396
- const tempOutputNoSourcemap = path.join(tempDir, "output-no-sourcemap.mjs");
397
- const tempOutputWithSourcemap = path.join(tempDir, "output.mjs");
398
- // Get the path to the runtime module (relative to this CLI)
399
- const runtimePath = path.resolve(path.dirname(new URL(import.meta.url).pathname), "./runtime.js");
400
- // Ensure temp directory exists (don't delete - concurrent builds may be using it)
401
- fs.mkdirSync(tempDir, { recursive: true });
390
+ // Get the path to the runtime module (absolute, then converted to relative)
391
+ const runtimePathAbsolute = path.resolve(path.dirname(new URL(import.meta.url).pathname), "./runtime.js");
402
392
  // Build log file injection code if specified
403
393
  const logFileInjection = logFilePath !== undefined
404
394
  ? `process.env['CLAUDE_CODE_HOOKS_CLI_LOG_FILE'] = ${JSON.stringify(logFilePath)};\n`
405
395
  : "";
406
- // Create wrapper that imports the hook and calls execute
396
+ // Compute relative paths from resolveDir to avoid absolute paths in source maps.
397
+ // This ensures reproducible builds regardless of checkout directory.
398
+ const resolveDir = path.dirname(sourcePath);
399
+ const relativeSourcePath = `./${path.basename(sourcePath)}`;
400
+ const relativeRuntimePath = path.relative(resolveDir, runtimePathAbsolute);
401
+ // Create wrapper content that imports the hook and calls execute
402
+ // Uses relative paths to produce reproducible builds
407
403
  const wrapperContent = `${logFileInjection}
408
- import hook from '${sourcePath.replace(/\\/g, "/")}';
409
- import { execute } from '${runtimePath.replace(/\\/g, "/")}';
404
+ import hook from '${relativeSourcePath.replace(/\\/g, "/")}';
405
+ import { execute } from '${relativeRuntimePath.replace(/\\/g, "/")}';
410
406
 
411
407
  execute(hook);
412
408
  `;
413
- fs.writeFileSync(wrapperPath, wrapperContent, "utf-8");
409
+ // Use stdin instead of a temp file - sourcefile becomes the stable reference
410
+ // The sourcefile name must be distinct from the actual source file to avoid
411
+ // esbuild resolving the import to the stdin content instead of the real file
412
+ const baseName = path.basename(sourcePath, path.extname(sourcePath));
413
+ const stdinOptions = {
414
+ contents: wrapperContent,
415
+ resolveDir,
416
+ sourcefile: `${baseName}-entry.ts`,
417
+ loader: "ts",
418
+ };
414
419
  // Common esbuild options
415
420
  const commonOptions = {
416
- entryPoints: [wrapperPath],
421
+ stdin: stdinOptions,
417
422
  format: "esm",
418
423
  platform: "node",
419
424
  target: "node20",
420
425
  bundle: true,
421
426
  minify: false,
427
+ write: false, // Return content directly via outputFiles
422
428
  // Keep node built-ins external
423
429
  external: [
424
430
  "node:*",
@@ -444,22 +450,24 @@ execute(hook);
444
450
  conditions: ["import", "node"],
445
451
  };
446
452
  // Step 1: Compile WITHOUT sourcemaps to generate stable content hash
447
- await esbuild.build({
453
+ const resultNoSourcemap = await esbuild.build({
448
454
  ...commonOptions,
449
- outfile: tempOutputNoSourcemap,
450
455
  sourcemap: false,
451
456
  });
452
- const contentForHash = fs.readFileSync(tempOutputNoSourcemap, "utf-8");
457
+ const contentForHash = resultNoSourcemap.outputFiles?.[0]?.text;
458
+ if (contentForHash === undefined) {
459
+ throw new Error(`esbuild produced no output for ${sourcePath}`);
460
+ }
453
461
  const contentHash = generateContentHash(contentForHash);
454
462
  // Step 2: Compile WITH sourcemaps for final output
455
- await esbuild.build({
463
+ const resultWithSourcemap = await esbuild.build({
456
464
  ...commonOptions,
457
- outfile: tempOutputWithSourcemap,
458
465
  sourcemap: "inline",
459
466
  });
460
- const content = fs.readFileSync(tempOutputWithSourcemap, "utf-8");
461
- // Don't delete temp directory - allows concurrent builds of same source
462
- // and the OS will clean up /tmp periodically
467
+ const content = resultWithSourcemap.outputFiles?.[0]?.text;
468
+ if (content === undefined) {
469
+ throw new Error(`esbuild produced no output for ${sourcePath}`);
470
+ }
463
471
  return { content, contentHash };
464
472
  }
465
473
  /**
package/dist/constants.js CHANGED
@@ -19,4 +19,6 @@ export const HOOK_FACTORY_TO_EVENT = {
19
19
  preCompactHook: "PreCompact",
20
20
  permissionRequestHook: "PermissionRequest",
21
21
  setupHook: "Setup",
22
+ teammateIdleHook: "TeammateIdle",
23
+ taskCompletedHook: "TaskCompleted",
22
24
  };
package/dist/hooks.js CHANGED
@@ -429,3 +429,73 @@ export function permissionRequestHook(config, handler) {
429
429
  export function setupHook(config, handler) {
430
430
  return createHookFunction("Setup", config, handler);
431
431
  }
432
+ // ============================================================================
433
+ // TeammateIdle Hook Factory
434
+ // ============================================================================
435
+ /**
436
+ * Creates a TeammateIdle hook handler.
437
+ *
438
+ * TeammateIdle hooks fire when a teammate in a team is about to go idle,
439
+ * allowing you to:
440
+ * - Assign work to idle teammates
441
+ * - Log team activity
442
+ * - Coordinate multi-agent workflows
443
+ *
444
+ * **Matcher**: No matcher support - fires on all teammate idle events
445
+ * @param config - Hook configuration with optional timeout (matcher is ignored)
446
+ * @param handler - The handler function to execute
447
+ * @returns A hook function that can be exported as the default export
448
+ * @example
449
+ * ```typescript
450
+ * import { teammateIdleHook, teammateIdleOutput } from '@goodfoot/claude-code-hooks';
451
+ *
452
+ * // Log when teammates go idle
453
+ * export default teammateIdleHook({}, async (input, { logger }) => {
454
+ * logger.info('Teammate going idle', {
455
+ * teammateName: input.teammate_name,
456
+ * teamName: input.team_name
457
+ * });
458
+ *
459
+ * return teammateIdleOutput({});
460
+ * });
461
+ * ```
462
+ * @see https://code.claude.com/docs/en/hooks#teammateidle
463
+ */
464
+ export function teammateIdleHook(config, handler) {
465
+ return createHookFunction("TeammateIdle", config, handler);
466
+ }
467
+ // ============================================================================
468
+ // TaskCompleted Hook Factory
469
+ // ============================================================================
470
+ /**
471
+ * Creates a TaskCompleted hook handler.
472
+ *
473
+ * TaskCompleted hooks fire when a task is being marked as completed,
474
+ * allowing you to:
475
+ * - Verify task completion
476
+ * - Log task metrics
477
+ * - Trigger follow-up actions
478
+ *
479
+ * **Matcher**: No matcher support - fires on all task completion events
480
+ * @param config - Hook configuration with optional timeout (matcher is ignored)
481
+ * @param handler - The handler function to execute
482
+ * @returns A hook function that can be exported as the default export
483
+ * @example
484
+ * ```typescript
485
+ * import { taskCompletedHook, taskCompletedOutput } from '@goodfoot/claude-code-hooks';
486
+ *
487
+ * // Log task completion
488
+ * export default taskCompletedHook({}, async (input, { logger }) => {
489
+ * logger.info('Task completed', {
490
+ * taskId: input.task_id,
491
+ * taskSubject: input.task_subject
492
+ * });
493
+ *
494
+ * return taskCompletedOutput({});
495
+ * });
496
+ * ```
497
+ * @see https://code.claude.com/docs/en/hooks#taskcompleted
498
+ */
499
+ export function taskCompletedHook(config, handler) {
500
+ return createHookFunction("TaskCompleted", config, handler);
501
+ }
package/dist/index.js CHANGED
@@ -11,16 +11,16 @@ export {
11
11
  CLAUDE_ENV_VARS, getEnvFilePath,
12
12
  // Getters
13
13
  getProjectDir, isRemoteEnvironment, } from "./env.js";
14
- // Hook factory functions - all 13 hook types
15
- export { notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, userPromptSubmitHook, } from "./hooks.js";
14
+ // Hook factory functions - all 15 hook types
15
+ export { notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, } from "./hooks.js";
16
16
  // Logger exports
17
17
  export { LOG_LEVELS, Logger, logger } from "./logger.js";
18
18
  // Output builder functions
19
19
  export {
20
20
  // Exit codes
21
21
  EXIT_CODES, notificationOutput, permissionRequestOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput,
22
- // All 13 output builder functions
23
- preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, userPromptSubmitOutput, } from "./outputs.js";
22
+ // All 15 output builder functions
23
+ preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, taskCompletedOutput, teammateIdleOutput, userPromptSubmitOutput, } from "./outputs.js";
24
24
  // Runtime exports - execute function
25
25
  export {
26
26
  // Main execute function for compiled hooks
package/dist/outputs.js CHANGED
@@ -297,3 +297,23 @@ export const permissionRequestOutput = /* @__PURE__ */ createHookSpecificOutputB
297
297
  * ```
298
298
  */
299
299
  export const setupOutput = /* @__PURE__ */ createHookSpecificOutputBuilder("Setup");
300
+ /**
301
+ * Creates an output for TeammateIdle hooks.
302
+ * @param options - Configuration options for the hook output
303
+ * @returns A TeammateIdleOutput object ready for the runtime
304
+ * @example
305
+ * ```typescript
306
+ * teammateIdleOutput({});
307
+ * ```
308
+ */
309
+ export const teammateIdleOutput = /* @__PURE__ */ createSimpleOutputBuilder("TeammateIdle");
310
+ /**
311
+ * Creates an output for TaskCompleted hooks.
312
+ * @param options - Configuration options for the hook output
313
+ * @returns A TaskCompletedOutput object ready for the runtime
314
+ * @example
315
+ * ```typescript
316
+ * taskCompletedOutput({});
317
+ * ```
318
+ */
319
+ export const taskCompletedOutput = /* @__PURE__ */ createSimpleOutputBuilder("TaskCompleted");
package/dist/scaffold.js CHANGED
@@ -50,6 +50,8 @@ const EVENT_TO_OUTPUT_FUNCTION = {
50
50
  PreCompact: "preCompactOutput",
51
51
  PermissionRequest: "permissionRequestOutput",
52
52
  Setup: "setupOutput",
53
+ TeammateIdle: "teammateIdleOutput",
54
+ TaskCompleted: "taskCompletedOutput",
53
55
  };
54
56
  // ============================================================================
55
57
  // Validation
package/dist/types.js CHANGED
@@ -33,4 +33,6 @@ export const HOOK_EVENT_NAMES = [
33
33
  "PreCompact",
34
34
  "PermissionRequest",
35
35
  "Setup",
36
+ "TeammateIdle",
37
+ "TaskCompleted",
36
38
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodfoot/claude-code-hooks",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
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,7 +53,7 @@
53
53
  "typescript": "^5.9.3"
54
54
  },
55
55
  "devDependencies": {
56
- "@anthropic-ai/claude-agent-sdk": "^0.2.31",
56
+ "@anthropic-ai/claude-agent-sdk": "^0.2.37",
57
57
  "@biomejs/biome": "2.3.14",
58
58
  "@types/node": "^24",
59
59
  "ts-morph": "^25.0.0",
package/types/cli.d.ts CHANGED
@@ -163,13 +163,15 @@ interface CompileHookResult {
163
163
  /**
164
164
  * Compiles a TypeScript hook file to a self-contained ESM executable.
165
165
  *
166
+ * Uses esbuild's stdin option to avoid writing temporary wrapper files to disk.
167
+ * This produces stable, reproducible builds by:
168
+ * - Using a distinct sourcefile name to avoid import resolution conflicts
169
+ * - Eliminating environment-specific temp paths from source comments
170
+ *
166
171
  * Uses a two-step process to generate stable content hashes:
167
172
  * 1. Compile WITHOUT sourcemaps → generate stable content hash
168
173
  * 2. Compile WITH sourcemaps → final output content
169
174
  *
170
- * This ensures content hashes are reproducible across different build
171
- * environments, since sourcemaps contain file paths that can vary.
172
- *
173
175
  * @param options - Compilation options
174
176
  * @returns Compiled content and stable content hash
175
177
  */
package/types/hooks.d.ts CHANGED
@@ -22,8 +22,8 @@
22
22
  * @see https://code.claude.com/docs/en/hooks
23
23
  */
24
24
  import type { Logger } from "./logger.js";
25
- import type { NotificationOutput, PermissionRequestOutput, PostToolUseFailureOutput, PostToolUseOutput, PreCompactOutput, PreToolUseOutput, SessionEndOutput, SessionStartOutput, SetupOutput, SpecificHookOutput, StopOutput, SubagentStartOutput, SubagentStopOutput, UserPromptSubmitOutput } from "./outputs.js";
26
- import type { HookEventName, KnownToolName, NotificationInput, PermissionRequestInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseInput, SessionEndInput, SessionStartInput, SetupInput, StopInput, SubagentStartInput, SubagentStopInput, ToolInputMap, UserPromptSubmitInput } from "./types.js";
25
+ import type { NotificationOutput, PermissionRequestOutput, PostToolUseFailureOutput, PostToolUseOutput, PreCompactOutput, PreToolUseOutput, SessionEndOutput, SessionStartOutput, SetupOutput, SpecificHookOutput, StopOutput, SubagentStartOutput, SubagentStopOutput, TaskCompletedOutput, TeammateIdleOutput, UserPromptSubmitOutput } from "./outputs.js";
26
+ import type { HookEventName, KnownToolName, NotificationInput, PermissionRequestInput, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseInput, SessionEndInput, SessionStartInput, SetupInput, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput } from "./types.js";
27
27
  /**
28
28
  * Configuration options for hook factories.
29
29
  *
@@ -798,3 +798,63 @@ export declare function permissionRequestHook(config: HookConfig, handler: HookH
798
798
  * @see https://code.claude.com/docs/en/hooks#setup
799
799
  */
800
800
  export declare function setupHook(config: HookConfig, handler: HookHandler<SetupInput, SetupOutput>): HookFunction<SetupInput, SetupOutput>;
801
+ /**
802
+ * Creates a TeammateIdle hook handler.
803
+ *
804
+ * TeammateIdle hooks fire when a teammate in a team is about to go idle,
805
+ * allowing you to:
806
+ * - Assign work to idle teammates
807
+ * - Log team activity
808
+ * - Coordinate multi-agent workflows
809
+ *
810
+ * **Matcher**: No matcher support - fires on all teammate idle events
811
+ * @param config - Hook configuration with optional timeout (matcher is ignored)
812
+ * @param handler - The handler function to execute
813
+ * @returns A hook function that can be exported as the default export
814
+ * @example
815
+ * ```typescript
816
+ * import { teammateIdleHook, teammateIdleOutput } from '@goodfoot/claude-code-hooks';
817
+ *
818
+ * // Log when teammates go idle
819
+ * export default teammateIdleHook({}, async (input, { logger }) => {
820
+ * logger.info('Teammate going idle', {
821
+ * teammateName: input.teammate_name,
822
+ * teamName: input.team_name
823
+ * });
824
+ *
825
+ * return teammateIdleOutput({});
826
+ * });
827
+ * ```
828
+ * @see https://code.claude.com/docs/en/hooks#teammateidle
829
+ */
830
+ export declare function teammateIdleHook(config: HookConfig, handler: HookHandler<TeammateIdleInput, TeammateIdleOutput>): HookFunction<TeammateIdleInput, TeammateIdleOutput>;
831
+ /**
832
+ * Creates a TaskCompleted hook handler.
833
+ *
834
+ * TaskCompleted hooks fire when a task is being marked as completed,
835
+ * allowing you to:
836
+ * - Verify task completion
837
+ * - Log task metrics
838
+ * - Trigger follow-up actions
839
+ *
840
+ * **Matcher**: No matcher support - fires on all task completion events
841
+ * @param config - Hook configuration with optional timeout (matcher is ignored)
842
+ * @param handler - The handler function to execute
843
+ * @returns A hook function that can be exported as the default export
844
+ * @example
845
+ * ```typescript
846
+ * import { taskCompletedHook, taskCompletedOutput } from '@goodfoot/claude-code-hooks';
847
+ *
848
+ * // Log task completion
849
+ * export default taskCompletedHook({}, async (input, { logger }) => {
850
+ * logger.info('Task completed', {
851
+ * taskId: input.task_id,
852
+ * taskSubject: input.task_subject
853
+ * });
854
+ *
855
+ * return taskCompletedOutput({});
856
+ * });
857
+ * ```
858
+ * @see https://code.claude.com/docs/en/hooks#taskcompleted
859
+ */
860
+ export declare function taskCompletedHook(config: HookConfig, handler: HookHandler<TaskCompletedInput, TaskCompletedOutput>): HookFunction<TaskCompletedInput, TaskCompletedOutput>;
package/types/index.d.ts CHANGED
@@ -8,15 +8,15 @@
8
8
  export type * from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
9
9
  export { CLAUDE_ENV_VARS, getEnvFilePath, getProjectDir, isRemoteEnvironment, } from "./env.js";
10
10
  export type { HookConfig, HookContext, HookFunction, HookHandler, SessionStartContext, TypedHookConfig, TypedPermissionRequestInput, TypedPostToolUseFailureInput, TypedPostToolUseInput, TypedPreToolUseInput, } from "./hooks.js";
11
- export { notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, userPromptSubmitHook, } from "./hooks.js";
11
+ export { notificationHook, permissionRequestHook, postToolUseFailureHook, postToolUseHook, preCompactHook, preToolUseHook, sessionEndHook, sessionStartHook, setupHook, stopHook, subagentStartHook, subagentStopHook, taskCompletedHook, teammateIdleHook, userPromptSubmitHook, } from "./hooks.js";
12
12
  export type { LogEvent, LogEventError, LogEventHandler, LoggerConfig, LogLevel, Unsubscribe } from "./logger.js";
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, UserPromptSubmitHookSpecificOutput, UserPromptSubmitOptions, } from "./outputs.js";
17
- export { EXIT_CODES, notificationOutput, permissionRequestOutput, postToolUseFailureOutput, postToolUseOutput, preCompactOutput, preToolUseOutput, sessionEndOutput, sessionStartOutput, setupOutput, stopOutput, subagentStartOutput, subagentStopOutput, userPromptSubmitOutput, } from "./outputs.js";
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";
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";
20
20
  export { checkContentForPattern, forEachContent, getFilePath, isAskUserQuestionTool, isBashTool, isEditTool, isExitPlanModeTool, isFileModifyingTool, isGlobTool, isGrepTool, isJsTsFile, isKillShellTool, isMultiEditTool, isNotebookEditTool, isReadTool, isTaskOutputTool, isTaskTool, isTodoWriteTool, isTsFile, isWebFetchTool, isWebSearchTool, isWriteTool, } from "./tool-helpers.js";
21
- export type { BaseHookInput, FileModifyingToolInput, FileModifyingToolName, HookEventName, HookInput, KnownToolInput, KnownToolName, MultiEditEntry, MultiEditToolInput, NotificationInput, PermissionMode, PermissionRequestInput, PermissionUpdate, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreCompactTrigger, PreToolUseInput, SessionEndInput, SessionEndReason, SessionStartInput, SessionStartSource, SetupInput, SetupTrigger, StopInput, SubagentStartInput, SubagentStopInput, ToolInputMap, UserPromptSubmitInput, } from "./types.js";
21
+ export type { BaseHookInput, FileModifyingToolInput, FileModifyingToolName, HookEventName, HookInput, KnownToolInput, KnownToolName, MultiEditEntry, MultiEditToolInput, NotificationInput, PermissionMode, PermissionRequestInput, PermissionUpdate, PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreCompactTrigger, PreToolUseInput, SessionEndInput, SessionEndReason, SessionStartInput, SessionStartSource, SetupInput, SetupTrigger, StopInput, SubagentStartInput, SubagentStopInput, TaskCompletedInput, TeammateIdleInput, ToolInputMap, UserPromptSubmitInput, } from "./types.js";
22
22
  export { HOOK_EVENT_NAMES } from "./types.js";
@@ -211,10 +211,18 @@ export type PermissionRequestOutput = BaseSpecificOutput<"PermissionRequest">;
211
211
  *
212
212
  */
213
213
  export type SetupOutput = BaseSpecificOutput<"Setup">;
214
+ /**
215
+ *
216
+ */
217
+ export type TeammateIdleOutput = BaseSpecificOutput<"TeammateIdle">;
218
+ /**
219
+ *
220
+ */
221
+ export type TaskCompletedOutput = BaseSpecificOutput<"TaskCompleted">;
214
222
  /**
215
223
  * Union of all specific output types.
216
224
  */
217
- export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PermissionRequestOutput | SetupOutput;
225
+ export type SpecificHookOutput = PreToolUseOutput | PostToolUseOutput | PostToolUseFailureOutput | NotificationOutput | UserPromptSubmitOutput | SessionStartOutput | SessionEndOutput | StopOutput | SubagentStartOutput | SubagentStopOutput | PreCompactOutput | PermissionRequestOutput | SetupOutput | TeammateIdleOutput | TaskCompletedOutput;
218
226
  /**
219
227
  * Options for decision-based hooks (Stop, SubagentStop).
220
228
  */
@@ -601,6 +609,42 @@ export declare const setupOutput: (options?: CommonOptions & {
601
609
  readonly _type: "Setup";
602
610
  stdout: SyncHookJSONOutput;
603
611
  };
612
+ /**
613
+ * Options for the TeammateIdle output builder.
614
+ * TeammateIdle hooks only support common options.
615
+ */
616
+ export type TeammateIdleOptions = CommonOptions;
617
+ /**
618
+ * Creates an output for TeammateIdle hooks.
619
+ * @param options - Configuration options for the hook output
620
+ * @returns A TeammateIdleOutput object ready for the runtime
621
+ * @example
622
+ * ```typescript
623
+ * teammateIdleOutput({});
624
+ * ```
625
+ */
626
+ export declare const teammateIdleOutput: (options?: CommonOptions) => {
627
+ readonly _type: "TeammateIdle";
628
+ stdout: SyncHookJSONOutput;
629
+ };
630
+ /**
631
+ * Options for the TaskCompleted output builder.
632
+ * TaskCompleted hooks only support common options.
633
+ */
634
+ export type TaskCompletedOptions = CommonOptions;
635
+ /**
636
+ * Creates an output for TaskCompleted hooks.
637
+ * @param options - Configuration options for the hook output
638
+ * @returns A TaskCompletedOutput object ready for the runtime
639
+ * @example
640
+ * ```typescript
641
+ * taskCompletedOutput({});
642
+ * ```
643
+ */
644
+ export declare const taskCompletedOutput: (options?: CommonOptions) => {
645
+ readonly _type: "TaskCompleted";
646
+ stdout: SyncHookJSONOutput;
647
+ };
604
648
  /**
605
649
  * @deprecated Use CommonOptions instead
606
650
  */
package/types/types.d.ts CHANGED
@@ -12,8 +12,8 @@
12
12
  * Re-exports types from @anthropic-ai/claude-agent-sdk with "SDK" prefix.
13
13
  * These are used as base types for extension, ensuring synchronization with the SDK.
14
14
  */
15
- export type { BaseHookInput as SDKBaseHookInput, HookEvent as SDKHookEvent, HookInput as SDKHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, } from "@anthropic-ai/claude-agent-sdk";
16
- import type { BaseHookInput as SDKBaseHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput } from "@anthropic-ai/claude-agent-sdk";
15
+ export type { BaseHookInput as SDKBaseHookInput, HookEvent as SDKHookEvent, HookInput as SDKHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput, } from "@anthropic-ai/claude-agent-sdk";
16
+ import type { BaseHookInput as SDKBaseHookInput, NotificationHookInput as SDKNotificationHookInput, PermissionMode as SDKPermissionMode, PermissionRequestHookInput as SDKPermissionRequestHookInput, PermissionUpdate as SDKPermissionUpdate, PostToolUseFailureHookInput as SDKPostToolUseFailureHookInput, PostToolUseHookInput as SDKPostToolUseHookInput, PreCompactHookInput as SDKPreCompactHookInput, PreToolUseHookInput as SDKPreToolUseHookInput, SessionEndHookInput as SDKSessionEndHookInput, SessionStartHookInput as SDKSessionStartHookInput, SetupHookInput as SDKSetupHookInput, StopHookInput as SDKStopHookInput, SubagentStartHookInput as SDKSubagentStartHookInput, SubagentStopHookInput as SDKSubagentStopHookInput, TaskCompletedHookInput as SDKTaskCompletedHookInput, TeammateIdleHookInput as SDKTeammateIdleHookInput, UserPromptSubmitHookInput as SDKUserPromptSubmitHookInput } from "@anthropic-ai/claude-agent-sdk";
17
17
  import type { AgentInput, AskUserQuestionInput, BashInput, ExitPlanModeInput, FileEditInput, FileReadInput, FileWriteInput, GlobInput, GrepInput, TaskStopInput as KillShellInput, NotebookEditInput, TaskOutputInput, TodoWriteInput, WebFetchInput, WebSearchInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
18
18
  /**
19
19
  * Permission mode for controlling how tool executions are handled.
@@ -358,6 +358,46 @@ export interface PermissionRequestInput extends SDKPermissionRequestHookInput {
358
358
  */
359
359
  tool_use_id: string;
360
360
  }
361
+ /**
362
+ * Input for TeammateIdle hooks.
363
+ *
364
+ * Fires when a teammate in a team is about to go idle, allowing you to:
365
+ * - Assign work to idle teammates
366
+ * - Log team activity
367
+ * - Coordinate multi-agent workflows
368
+ *
369
+ * This hook does not support matchers; it fires on all teammate idle events.
370
+ * @example
371
+ * ```typescript
372
+ * // Assign work to an idle teammate
373
+ * teammateIdleHook({}, async (input: TeammateIdleInput) => {
374
+ * console.log(`${input.teammate_name} is idle in team ${input.team_name}`);
375
+ * return teammateIdleOutput({});
376
+ * });
377
+ * ```
378
+ * @see https://code.claude.com/docs/en/hooks#teammateidle
379
+ */
380
+ export type TeammateIdleInput = SDKTeammateIdleHookInput;
381
+ /**
382
+ * Input for TaskCompleted hooks.
383
+ *
384
+ * Fires when a task is being marked as completed, allowing you to:
385
+ * - Verify task completion
386
+ * - Log task metrics
387
+ * - Trigger follow-up actions
388
+ *
389
+ * This hook does not support matchers; it fires on all task completion events.
390
+ * @example
391
+ * ```typescript
392
+ * // Log task completion
393
+ * taskCompletedHook({}, async (input: TaskCompletedInput) => {
394
+ * console.log(`Task ${input.task_id}: ${input.task_subject} completed`);
395
+ * return taskCompletedOutput({});
396
+ * });
397
+ * ```
398
+ * @see https://code.claude.com/docs/en/hooks#taskcompleted
399
+ */
400
+ export type TaskCompletedInput = SDKTaskCompletedHookInput;
361
401
  /**
362
402
  * Trigger type for Setup hooks.
363
403
  */
@@ -415,7 +455,7 @@ export type SetupInput = SDKSetupHookInput;
415
455
  * ```
416
456
  * @see https://code.claude.com/docs/en/hooks
417
457
  */
418
- export type HookInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | NotificationInput | UserPromptSubmitInput | SessionStartInput | SessionEndInput | StopInput | SubagentStartInput | SubagentStopInput | PreCompactInput | PermissionRequestInput | SetupInput;
458
+ export type HookInput = PreToolUseInput | PostToolUseInput | PostToolUseFailureInput | NotificationInput | UserPromptSubmitInput | SessionStartInput | SessionEndInput | StopInput | SubagentStartInput | SubagentStopInput | PreCompactInput | PermissionRequestInput | SetupInput | TeammateIdleInput | TaskCompletedInput;
419
459
  /**
420
460
  * Hook event name literal union.
421
461
  *
@@ -433,7 +473,7 @@ export type HookEventName = HookInput["hook_event_name"];
433
473
  * }
434
474
  * ```
435
475
  */
436
- export declare const HOOK_EVENT_NAMES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest", "Setup"];
476
+ export declare const HOOK_EVENT_NAMES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest", "Setup", "TeammateIdle", "TaskCompleted"];
437
477
  export type { SDKPermissionUpdate as PermissionUpdate };
438
478
  /**
439
479
  * Re-export all tool input types from the official Claude Agent SDK.