MCPcopy Index your code
hub / github.com/codeaashu/claude-code / executeHookCallback

Function executeHookCallback

src/utils/hooks.ts:4840–4896  ·  view source on GitHub ↗
({
  toolUseID,
  hook,
  hookEvent,
  hookInput,
  signal,
  hookIndex,
  toolUseContext,
}: {
  toolUseID: string
  hook: HookCallback
  hookEvent: HookEvent
  hookInput: HookInput
  signal: AbortSignal
  hookIndex?: number
  toolUseContext?: ToolUseContext
})

Source from the content-addressed store, hash-verified

4838}
4839
4840async function executeHookCallback({
4841 toolUseID,
4842 hook,
4843 hookEvent,
4844 hookInput,
4845 signal,
4846 hookIndex,
4847 toolUseContext,
4848}: {
4849 toolUseID: string
4850 hook: HookCallback
4851 hookEvent: HookEvent
4852 hookInput: HookInput
4853 signal: AbortSignal
4854 hookIndex?: number
4855 toolUseContext?: ToolUseContext
4856}): Promise<HookResult> {
4857 // Create context for callbacks that need state access
4858 const context = toolUseContext
4859 ? {
4860 getAppState: toolUseContext.getAppState,
4861 updateAttributionState: toolUseContext.updateAttributionState,
4862 }
4863 : undefined
4864 const json = await hook.callback(
4865 hookInput,
4866 toolUseID,
4867 signal,
4868 hookIndex,
4869 context,
4870 )
4871 if (isAsyncHookJSONOutput(json)) {
4872 return {
4873 outcome: 'success',
4874 hook,
4875 }
4876 }
4877
4878 const processed = processHookJSONOutput({
4879 json,
4880 command: 'callback',
4881 // TODO: If the hook came from a plugin, use the full path to the plugin for easier debugging
4882 hookName: `${hookEvent}:Callback`,
4883 toolUseID,
4884 hookEvent,
4885 expectedHookEvent: hookEvent,
4886 // Callbacks don't have stdout/stderr/exitCode
4887 stdout: undefined,
4888 stderr: undefined,
4889 exitCode: undefined,
4890 })
4891 return {
4892 ...processed,
4893 outcome: 'success',
4894 hook,
4895 }
4896}
4897

Callers 1

executeHooksFunction · 0.85

Calls 2

isAsyncHookJSONOutputFunction · 0.85
processHookJSONOutputFunction · 0.85

Tested by

no test coverage detected