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

Function registerPendingAsyncHook

src/utils/hooks/AsyncHookRegistry.ts:30–83  ·  view source on GitHub ↗
({
  processId,
  hookId,
  asyncResponse,
  hookName,
  hookEvent,
  command,
  shellCommand,
  toolName,
  pluginId,
}: {
  processId: string
  hookId: string
  asyncResponse: AsyncHookJSONOutput
  hookName: string
  hookEvent: HookEvent | 'StatusLine' | 'FileSuggestion'
  command: string
  shellCommand: ShellCommand
  toolName?: string
  pluginId?: string
})

Source from the content-addressed store, hash-verified

28const pendingHooks = new Map<string, PendingAsyncHook>()
29
30export function registerPendingAsyncHook({
31 processId,
32 hookId,
33 asyncResponse,
34 hookName,
35 hookEvent,
36 command,
37 shellCommand,
38 toolName,
39 pluginId,
40}: {
41 processId: string
42 hookId: string
43 asyncResponse: AsyncHookJSONOutput
44 hookName: string
45 hookEvent: HookEvent | 'StatusLine' | 'FileSuggestion'
46 command: string
47 shellCommand: ShellCommand
48 toolName?: string
49 pluginId?: string
50}): void {
51 const timeout = asyncResponse.asyncTimeout || 15000 // Default 15s
52 logForDebugging(
53 `Hooks: Registering async hook ${processId} (${hookName}) with timeout ${timeout}ms`,
54 )
55 const stopProgressInterval = startHookProgressInterval({
56 hookId,
57 hookName,
58 hookEvent,
59 getOutput: async () => {
60 const taskOutput = pendingHooks.get(processId)?.shellCommand?.taskOutput
61 if (!taskOutput) {
62 return { stdout: '', stderr: '', output: '' }
63 }
64 const stdout = await taskOutput.getStdout()
65 const stderr = taskOutput.getStderr()
66 return { stdout, stderr, output: stdout + stderr }
67 },
68 })
69 pendingHooks.set(processId, {
70 processId,
71 hookId,
72 hookName,
73 hookEvent,
74 toolName,
75 pluginId,
76 command,
77 startTime: Date.now(),
78 timeout,
79 responseAttachmentSent: false,
80 shellCommand,
81 stopProgressInterval,
82 })
83}
84
85export function getPendingAsyncHooks(): PendingAsyncHook[] {
86 return Array.from(pendingHooks.values()).filter(

Callers 1

executeInBackgroundFunction · 0.85

Calls 6

logForDebuggingFunction · 0.85
getStdoutMethod · 0.80
getStderrMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected